Author: vmiklos Date: Tue Aug 30 02:23:24 2016 New Revision: 280062 URL: http://llvm.org/viewvc/llvm-project?rev=280062&view=rev Log: clang-rename: improve error message when -old-name is used and could not find symbol
Old output was: clang-rename: could not find symbol at tools/clang/tools/extra/test/clang-rename/ClassFindByName.cpp:1:1 (offset 0). Reviewers: omtcyfz Differential Revision: https://reviews.llvm.org/D24002 Added: clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=280062&r1=280061&r2=280062&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original) +++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Tue Aug 30 02:23:24 2016 @@ -157,12 +157,15 @@ struct NamedDeclFindingConsumer : public 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; } Added: clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp?rev=280062&view=auto ============================================================================== --- clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp (added) +++ clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp Tue Aug 30 02:23:24 2016 @@ -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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits