Index: clang-rename/RenamingAction.cpp =================================================================== --- clang-rename/RenamingAction.cpp +++ clang-rename/RenamingAction.cpp @@ -49,7 +49,8 @@ std::vector NewCandidates; for (const auto &USR : USRs) { - NewCandidates = getLocationsOfUSR(USR, PrevName, Context.getTranslationUnitDecl()); + NewCandidates = getLocationsOfUSR(USR, PrevName, + Context.getTranslationUnitDecl()); RenamingCandidates.insert(RenamingCandidates.end(), NewCandidates.begin(), NewCandidates.end()); NewCandidates.clear(); Index: clang-rename/USRLocFinder.h =================================================================== --- clang-rename/USRLocFinder.h +++ clang-rename/USRLocFinder.h @@ -35,4 +35,4 @@ } } -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_LOC_FINDER_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_LOC_FINDER_H Index: clang-rename/USRLocFinder.cpp =================================================================== --- clang-rename/USRLocFinder.cpp +++ clang-rename/USRLocFinder.cpp @@ -33,9 +33,9 @@ // translation unit and stores them for later usage. class USRLocFindingASTVisitor : public clang::RecursiveASTVisitor { -public: - explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) : USR(USR), PrevName(PrevName) { - } + public: + explicit USRLocFindingASTVisitor(StringRef USR, StringRef PrevName) + : USR(USR), PrevName(PrevName) {} // Declaration visitors: @@ -60,8 +60,10 @@ bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) { const ASTContext &Context = ConstructorDecl->getASTContext(); - for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) { - const clang::CXXCtorInitializer* Initializer = *it; + for (clang::CXXConstructorDecl::init_const_iterator it = + ConstructorDecl->init_begin(); + it != ConstructorDecl->init_end(); ++it) { + const clang::CXXCtorInitializer *Initializer = *it; if (Initializer->getSourceOrder() == -1) { // Ignore implicit initializers. continue; @@ -71,9 +73,12 @@ if (getUSRForDecl(FieldDecl) == USR) { // The initializer refers to a field that is to be renamed. SourceLocation Location = Initializer->getSourceLocation(); - StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(Location), Context.getSourceManager(), Context.getLangOpts()); + StringRef TokenName = Lexer::getSourceText( + CharSourceRange::getTokenRange(Location), + Context.getSourceManager(), Context.getLangOpts()); if (TokenName == PrevName) { - // The token of the source location we find actually has the old name. + // The token of the source location we find actually has the old + // name. LocationsFound.push_back(Initializer->getSourceLocation()); } } @@ -169,7 +174,7 @@ return LocationsFound; } -private: + private: // Namespace traversal: void checkNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) { while (NameLoc) { @@ -183,14 +188,15 @@ bool handleCXXNamedCastExpr(clang::CXXNamedCastExpr *Expr) { clang::QualType Type = Expr->getType(); // See if this a cast of a pointer. - const RecordDecl* Decl = Type->getPointeeCXXRecordDecl(); + const RecordDecl *Decl = Type->getPointeeCXXRecordDecl(); if (!Decl) { // See if this is a cast of a reference. Decl = Type->getAsCXXRecordDecl(); } if (Decl && getUSRForDecl(Decl) == USR) { - SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc(); + SourceLocation Location = + Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc(); LocationsFound.push_back(Location); } @@ -203,10 +209,9 @@ const std::string PrevName; std::vector LocationsFound; }; -} // namespace +} // namespace -std::vector getLocationsOfUSR(StringRef USR, - StringRef PrevName, +std::vector getLocationsOfUSR(StringRef USR, StringRef PrevName, Decl *Decl) { USRLocFindingASTVisitor visitor(USR, PrevName); @@ -214,5 +219,5 @@ return visitor.getLocationsFound(); } -} // namespace rename -} // namespace clang +} // namespace rename +} // namespace clang Index: clang-rename/tool/ClangRename.cpp =================================================================== --- clang-rename/tool/ClangRename.cpp +++ clang-rename/tool/ClangRename.cpp @@ -36,7 +36,6 @@ #include "clang/Tooling/Tooling.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/Host.h" -#include #include using namespace llvm; @@ -83,7 +82,7 @@ #define CLANG_RENAME_VERSION "0.0.1" static void PrintVersion() { - outs() << "clang-rename version " << CLANG_RENAME_VERSION << "\n"; + outs() << "clang-rename version " << CLANG_RENAME_VERSION << '\n'; } using namespace clang; @@ -101,7 +100,6 @@ if (NewName.empty()) { errs() << "clang-rename: no new name provided.\n\n"; - cl::PrintHelpMessage(); exit(1); } @@ -115,12 +113,14 @@ const auto &USRs = USRAction.getUSRs(); const auto &PrevName = USRAction.getUSRSpelling(); - if (PrevName.empty()) + if (PrevName.empty()) { // An error should have already been printed. exit(1); + } - if (PrintName) - errs() << "clang-rename: found name: " << PrevName << "\n"; + if (PrintName) { + errs() << "clang-rename: found name: " << PrevName << '\n'; + } // Perform the renaming. rename::RenamingAction RenameAction(NewName, PrevName, USRs,