@@ -207,21 +207,25 @@ class RenameRangeCollector : public IndexDataConsumer {
207
207
bool finishDependency (bool isClangModule) override { return true ; }
208
208
209
209
Action startSourceEntity (const IndexSymbol &symbol) override {
210
- if (symbol.USR == usr) {
211
- if (auto loc = indexSymbolToRenameLoc (symbol)) {
212
- // Inside capture lists like `{ [test] in }`, 'test' refers to both the
213
- // newly declared, captured variable and the referenced variable it is
214
- // initialized from. Make sure to only rename it once.
215
- auto existingLoc = llvm::find_if (locations, [&](RenameLoc searchLoc) {
216
- return searchLoc.Line == loc->Line && searchLoc.Column == loc->Column ;
217
- });
218
- if (existingLoc == locations.end ()) {
219
- locations.push_back (std::move (*loc));
220
- } else {
221
- assert (existingLoc->OldName == loc->OldName &&
222
- " Asked to do a different rename for the same location?" );
223
- }
224
- }
210
+ if (symbol.USR != usr) {
211
+ return IndexDataConsumer::Continue;
212
+ }
213
+ auto loc = indexSymbolToRenameLoc (symbol);
214
+ if (!loc) {
215
+ return IndexDataConsumer::Continue;
216
+ }
217
+
218
+ // Inside capture lists like `{ [test] in }`, 'test' refers to both the
219
+ // newly declared, captured variable and the referenced variable it is
220
+ // initialized from. Make sure to only rename it once.
221
+ auto existingLoc = llvm::find_if (locations, [&](RenameLoc searchLoc) {
222
+ return searchLoc.Line == loc->Line && searchLoc.Column == loc->Column ;
223
+ });
224
+ if (existingLoc == locations.end ()) {
225
+ locations.push_back (std::move (*loc));
226
+ } else {
227
+ assert (existingLoc->OldName == loc->OldName &&
228
+ " Asked to do a different rename for the same location?" );
225
229
}
226
230
return IndexDataConsumer::Continue;
227
231
}
0 commit comments