[PATCH] D20216: clang-rename: check that the source location we find actually has the old name

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Fri May 13 01:20:14 PDT 2016


klimek added inline comments.

================
Comment at: clang-rename/USRLocFinder.cpp:75
@@ +74,3 @@
+          StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Range), Context.getSourceManager(), Context.getLangOpts());
+          if (TokenName.startswith(PrevName)) {
+            // The token of the source location we find actually has the old name.
----------------
vmiklos wrote:
> klimek wrote:
> > Why startswith as opposed to ==?
> The source range is "foo(0)", the old name is "foo". Or is there a way to get the range of the name part of the initializer, without the "(0)" part?
> 
> I'll fix the rest, those are easy. :-)
Yep, if you want to get an identifier, you just get the code for the range getLocation(), getLocation() (note that ranges are inclusive token-ranges by default)


http://reviews.llvm.org/D20216





More information about the cfe-commits mailing list