Index: lib/Tooling/Refactoring/Rename/RenamingAction.cpp =================================================================== --- lib/Tooling/Refactoring/Rename/RenamingAction.cpp +++ lib/Tooling/Refactoring/Rename/RenamingAction.cpp @@ -84,8 +84,13 @@ FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {} void HandleTranslationUnit(ASTContext &Context) override { - for (unsigned I = 0; I < NewNames.size(); ++I) + for (unsigned I = 0; I < NewNames.size(); ++I) { + // If the previous name was not found, ignore this rename request. + if (PrevNames[I].empty()) + continue; + HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]); + } } void HandleOneRename(ASTContext &Context, const std::string &NewName, Index: lib/Tooling/Refactoring/Rename/USRFindingAction.cpp =================================================================== --- lib/Tooling/Refactoring/Rename/USRFindingAction.cpp +++ lib/Tooling/Refactoring/Rename/USRFindingAction.cpp @@ -198,8 +198,11 @@ return false; } - if (Force) + if (Force) { + SpellingNames.push_back(std::string()); + USRList.push_back(std::vector()); return true; + } unsigned CouldNotFindSymbolNamed = Engine.getCustomDiagID( DiagnosticsEngine::Error, "clang-rename could not find symbol %0"); Index: test/clang-rename/ForceMulti.cpp =================================================================== --- /dev/null +++ test/clang-rename/ForceMulti.cpp @@ -0,0 +1,8 @@ +class B /* Test 1 */ { // CHECK: class B2 /* Test 1 */ { +}; + +class D : public B /* Test 1 */ { // CHECK: class D : public B2 /* Test 1 */ { +}; + +// Test 1. +// RUN: clang-rename -force -qualified-name B -new-name B2 -qualified-name E -new-name E2 %s -- | sed 's,//.*,,' | FileCheck %s Index: tools/clang-rename/ClangRename.cpp =================================================================== --- tools/clang-rename/ClangRename.cpp +++ tools/clang-rename/ClangRename.cpp @@ -175,12 +175,6 @@ return 1; } - if (Force && PrevNames.size() < NewNames.size()) { - // No matching PrevName for all NewNames. Without Force this is an error - // above already. - return 0; - } - // Perform the renaming. tooling::RenamingAction RenameAction(NewNames, PrevNames, USRList, Tool.getReplacements(), PrintLocations);