[PATCH] D24002: clang-rename: improve error message when -old-name is used and could not find symbol

Miklos Vajna via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 00:31:49 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL280062: clang-rename: improve error message when -old-name is used and could not find… (authored by vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D24002?vs=69644&id=69646#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24002

Files:
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp

Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===================================================================
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -157,12 +157,15 @@
       FoundDecl = getNamedDeclFor(Context, OldName);
     }
     if (FoundDecl == nullptr) {
-      FullSourceLoc FullLoc(Point, SourceMgr);
-      errs() << "clang-rename: could not find symbol at "
-             << SourceMgr.getFilename(Point) << ":"
-             << FullLoc.getSpellingLineNumber() << ":"
-             << FullLoc.getSpellingColumnNumber() << " (offset " << SymbolOffset
-             << ").\n";
+      if (OldName.empty()) {
+        FullSourceLoc FullLoc(Point, SourceMgr);
+        errs() << "clang-rename: could not find symbol at "
+               << SourceMgr.getFilename(Point) << ":"
+               << FullLoc.getSpellingLineNumber() << ":"
+               << FullLoc.getSpellingColumnNumber() << " (offset "
+               << SymbolOffset << ").\n";
+      } else
+        errs() << "clang-rename: could not find symbol " << OldName << ".\n";
       return;
     }
 
Index: clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | FileCheck %s
+// CHECK: clang-rename: could not find symbol Bar.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24002.69646.patch
Type: text/x-patch
Size: 1603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160830/06183d95/attachment.bin>


More information about the cfe-commits mailing list