[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

David Goldman via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 09:20:26 PST 2024


================
@@ -543,6 +550,45 @@ std::optional<InvalidName> checkName(const NamedDecl &RenameDecl,
   return Result;
 }
 
+clangd::Range tokenRangeForLoc(ParsedAST &AST, SourceLocation TokLoc,
+                               const SourceManager &SM,
+                               const LangOptions &LangOpts) {
+  const auto *Token = AST.getTokens().spelledTokenAt(TokLoc);
+  assert(Token && "got inclusion at wrong offset");
+  clangd::Range Result;
+  Result.start = sourceLocToPosition(SM, Token->location());
+  Result.end = sourceLocToPosition(SM, Token->endLocation());
+  return Result;
+}
+
+// AST-based ObjC method rename, it renames all occurrences in the main file
+// even for selectors which may have multiple tokens.
----------------
DavidGoldman wrote:

Done

https://github.com/llvm/llvm-project/pull/76466


More information about the cfe-commits mailing list