Index: clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h =================================================================== --- clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h +++ clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h @@ -24,8 +24,8 @@ /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.html class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck { const std::string GslHeader; - const IncludeSorter::IncludeStyle IncludeStyle; - std::unique_ptr Inserter; + const utils::IncludeSorter::IncludeStyle IncludeStyle; + std::unique_ptr Inserter; public: ProBoundsConstantArrayIndexCheck(StringRef Name, ClangTidyContext *Context); Index: clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp =================================================================== --- clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +++ clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp @@ -22,7 +22,7 @@ ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck( StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")), - IncludeStyle(IncludeSorter::parseIncludeStyle( + IncludeStyle(utils::IncludeSorter::parseIncludeStyle( Options.get("IncludeStyle", "llvm"))) {} void ProBoundsConstantArrayIndexCheck::storeOptions( @@ -36,8 +36,8 @@ if (!getLangOpts().CPlusPlus) return; - Inserter.reset(new IncludeInserter(Compiler.getSourceManager(), - Compiler.getLangOpts(), IncludeStyle)); + Inserter.reset(new utils::IncludeInserter( + Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle)); Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks()); } Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp =================================================================== --- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -33,7 +33,7 @@ for (const FieldDecl *F : Fields) { QualType Type = F->getType(); if (!F->hasInClassInitializer() && - type_traits::isTriviallyDefaultConstructible(Type, Context)) + utils::type_traits::isTriviallyDefaultConstructible(Type, Context)) FieldsToInit.insert(F); } } @@ -112,12 +112,12 @@ SourceLocation Location; switch (Placement) { case InitializerPlacement::New: - Location = lexer_utils::getPreviousNonCommentToken( + Location = utils::lexer::getPreviousNonCommentToken( Context, Constructor.getBody()->getLocStart()) .getLocation(); break; case InitializerPlacement::Before: - Location = lexer_utils::getPreviousNonCommentToken( + Location = utils::lexer::getPreviousNonCommentToken( Context, Where->getSourceRange().getBegin()) .getLocation(); break; @@ -387,7 +387,8 @@ if (const auto *BaseClassDecl = getCanonicalRecordDecl(Base.getType())) { AllBases.emplace_back(BaseClassDecl); if (!BaseClassDecl->field_empty() && - type_traits::isTriviallyDefaultConstructible(Base.getType(), Context)) + utils::type_traits::isTriviallyDefaultConstructible( + Base.getType(), Context)) BasesToInit.insert(BaseClassDecl); } } Index: clang-tidy/llvm/HeaderGuardCheck.h =================================================================== --- clang-tidy/llvm/HeaderGuardCheck.h +++ clang-tidy/llvm/HeaderGuardCheck.h @@ -17,7 +17,7 @@ namespace llvm { /// Finds and fixes header guards that do not adhere to LLVM style. -class LLVMHeaderGuardCheck : public HeaderGuardCheck { +class LLVMHeaderGuardCheck : public utils::HeaderGuardCheck { public: LLVMHeaderGuardCheck(StringRef Name, ClangTidyContext *Context) : HeaderGuardCheck(Name, Context) {} Index: clang-tidy/misc/MoveConstructorInitCheck.h =================================================================== --- clang-tidy/misc/MoveConstructorInitCheck.h +++ clang-tidy/misc/MoveConstructorInitCheck.h @@ -38,8 +38,8 @@ void handleParamNotMoved(const ast_matchers::MatchFinder::MatchResult &Result); - std::unique_ptr Inserter; - const IncludeSorter::IncludeStyle IncludeStyle; + std::unique_ptr Inserter; + const utils::IncludeSorter::IncludeStyle IncludeStyle; const bool UseCERTSemantics; }; Index: clang-tidy/misc/MoveConstructorInitCheck.cpp =================================================================== --- clang-tidy/misc/MoveConstructorInitCheck.cpp +++ clang-tidy/misc/MoveConstructorInitCheck.cpp @@ -42,7 +42,7 @@ MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - IncludeStyle(IncludeSorter::parseIncludeStyle( + IncludeStyle(utils::IncludeSorter::parseIncludeStyle( Options.get("IncludeStyle", "llvm"))), UseCERTSemantics(Context->isCheckEnabled("cert-oop11-cpp")) {} @@ -167,13 +167,14 @@ } void MoveConstructorInitCheck::registerPPCallbacks(CompilerInstance &Compiler) { - Inserter.reset(new IncludeInserter(Compiler.getSourceManager(), - Compiler.getLangOpts(), IncludeStyle)); + Inserter.reset(new utils::IncludeInserter( + Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle)); Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks()); } void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeSorter::toString(IncludeStyle)); + Options.store(Opts, "IncludeStyle", + utils::IncludeSorter::toString(IncludeStyle)); } } // namespace misc Index: clang-tidy/misc/SuspiciousSemicolonCheck.cpp =================================================================== --- clang-tidy/misc/SuspiciousSemicolonCheck.cpp +++ clang-tidy/misc/SuspiciousSemicolonCheck.cpp @@ -40,7 +40,7 @@ return; ASTContext &Ctxt = *Result.Context; - auto Token = lexer_utils::getPreviousNonCommentToken(Ctxt, LocStart); + auto Token = utils::lexer::getPreviousNonCommentToken(Ctxt, LocStart); auto &SM = *Result.SourceManager; unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart); Index: clang-tidy/modernize/PassByValueCheck.h =================================================================== --- clang-tidy/modernize/PassByValueCheck.h +++ clang-tidy/modernize/PassByValueCheck.h @@ -28,8 +28,8 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - std::unique_ptr Inserter; - const IncludeSorter::IncludeStyle IncludeStyle; + std::unique_ptr Inserter; + const utils::IncludeSorter::IncludeStyle IncludeStyle; }; } // namespace modernize Index: clang-tidy/modernize/PassByValueCheck.cpp =================================================================== --- clang-tidy/modernize/PassByValueCheck.cpp +++ clang-tidy/modernize/PassByValueCheck.cpp @@ -118,11 +118,12 @@ PassByValueCheck::PassByValueCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - IncludeStyle(IncludeSorter::parseIncludeStyle( + IncludeStyle(utils::IncludeSorter::parseIncludeStyle( Options.get("IncludeStyle", "llvm"))) {} void PassByValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeSorter::toString(IncludeStyle)); + Options.store(Opts, "IncludeStyle", + utils::IncludeSorter::toString(IncludeStyle)); } void PassByValueCheck::registerMatchers(MatchFinder *Finder) { @@ -162,8 +163,8 @@ // currently does not provide any benefit to other languages, despite being // benign. if (getLangOpts().CPlusPlus) { - Inserter.reset(new IncludeInserter(Compiler.getSourceManager(), - Compiler.getLangOpts(), IncludeStyle)); + Inserter.reset(new utils::IncludeInserter( + Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle)); Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks()); } } Index: clang-tidy/modernize/ReplaceAutoPtrCheck.h =================================================================== --- clang-tidy/modernize/ReplaceAutoPtrCheck.h +++ clang-tidy/modernize/ReplaceAutoPtrCheck.h @@ -50,8 +50,8 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - std::unique_ptr Inserter; - const IncludeSorter::IncludeStyle IncludeStyle; + std::unique_ptr Inserter; + const utils::IncludeSorter::IncludeStyle IncludeStyle; }; } // namespace modernize Index: clang-tidy/modernize/ReplaceAutoPtrCheck.cpp =================================================================== --- clang-tidy/modernize/ReplaceAutoPtrCheck.cpp +++ clang-tidy/modernize/ReplaceAutoPtrCheck.cpp @@ -189,11 +189,12 @@ ReplaceAutoPtrCheck::ReplaceAutoPtrCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - IncludeStyle(IncludeSorter::parseIncludeStyle( + IncludeStyle(utils::IncludeSorter::parseIncludeStyle( Options.get("IncludeStyle", "llvm"))) {} void ReplaceAutoPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeSorter::toString(IncludeStyle)); + Options.store(Opts, "IncludeStyle", + utils::IncludeSorter::toString(IncludeStyle)); } void ReplaceAutoPtrCheck::registerMatchers(MatchFinder *Finder) { @@ -211,8 +212,8 @@ // currently does not provide any benefit to other languages, despite being // benign. if (getLangOpts().CPlusPlus) { - Inserter.reset(new IncludeInserter(Compiler.getSourceManager(), - Compiler.getLangOpts(), IncludeStyle)); + Inserter.reset(new utils::IncludeInserter( + Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle)); Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks()); } } Index: clang-tidy/performance/ForRangeCopyCheck.cpp =================================================================== --- clang-tidy/performance/ForRangeCopyCheck.cpp +++ clang-tidy/performance/ForRangeCopyCheck.cpp @@ -59,16 +59,16 @@ return false; } llvm::Optional Expensive = - type_traits::isExpensiveToCopy(LoopVar.getType(), Context); + utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context); if (!Expensive || !*Expensive) return false; auto Diagnostic = diag(LoopVar.getLocation(), "the loop variable's type is not a reference type; this creates a " "copy in each iteration; consider making this a reference") - << utils::create_fix_it::changeVarDeclToReference(LoopVar, Context); + << utils::fixit::changeVarDeclToReference(LoopVar, Context); if (!LoopVar.getType().isConstQualified()) - Diagnostic << utils::create_fix_it::changeVarDeclToConst(LoopVar); + Diagnostic << utils::fixit::changeVarDeclToConst(LoopVar); return true; } @@ -76,16 +76,17 @@ const VarDecl &LoopVar, const CXXForRangeStmt &ForRange, ASTContext &Context) { llvm::Optional Expensive = - type_traits::isExpensiveToCopy(LoopVar.getType(), Context); + utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context); if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive) return false; - if (!decl_ref_expr_utils::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(), Context)) + if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(), + Context)) return false; diag(LoopVar.getLocation(), "loop variable is copied but only used as const reference; consider " "making it a const reference") - << utils::create_fix_it::changeVarDeclToConst(LoopVar) - << utils::create_fix_it::changeVarDeclToReference(LoopVar, Context); + << utils::fixit::changeVarDeclToConst(LoopVar) + << utils::fixit::changeVarDeclToReference(LoopVar, Context); return true; } Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp =================================================================== --- clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -24,16 +24,16 @@ if (Var.getLocation().isMacroID()) return; - Diagnostic << utils::create_fix_it::changeVarDeclToReference(Var, Context); + Diagnostic << utils::fixit::changeVarDeclToReference(Var, Context); if (!Var.getType().isLocalConstQualified()) - Diagnostic << utils::create_fix_it::changeVarDeclToConst(Var); + Diagnostic << utils::fixit::changeVarDeclToConst(Var); } } // namespace using namespace ::clang::ast_matchers; -using decl_ref_expr_utils::isOnlyUsedAsConst; +using utils::decl_ref_expr::isOnlyUsedAsConst; void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) { auto ConstReference = referenceType(pointee(qualType(isConstQualified()))); Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp =================================================================== --- clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -61,7 +61,7 @@ // 2. they are not only used as const. if (!IsConstQualified && (llvm::isa(Function) || !Function->doesThisDeclarationHaveABody() || - !decl_ref_expr_utils::isOnlyUsedAsConst( + !utils::decl_ref_expr::isOnlyUsedAsConst( *Param, *Function->getBody(), *Result.Context))) return; auto Diag = @@ -79,10 +79,10 @@ for (const auto *FunctionDecl = Function; FunctionDecl != nullptr; FunctionDecl = FunctionDecl->getPreviousDecl()) { const auto &CurrentParam = *FunctionDecl->getParamDecl(Index); - Diag << utils::create_fix_it::changeVarDeclToReference(CurrentParam, + Diag << utils::fixit::changeVarDeclToReference(CurrentParam, *Result.Context); if (!IsConstQualified) - Diag << utils::create_fix_it::changeVarDeclToConst(CurrentParam); + Diag << utils::fixit::changeVarDeclToConst(CurrentParam); } } Index: clang-tidy/utils/DeclRefExprUtils.h =================================================================== --- clang-tidy/utils/DeclRefExprUtils.h +++ clang-tidy/utils/DeclRefExprUtils.h @@ -15,7 +15,8 @@ namespace clang { namespace tidy { -namespace decl_ref_expr_utils { +namespace utils { +namespace decl_ref_expr { /// \brief Returns true if all DeclRefExpr to the variable within Stmt do not /// modify it. @@ -25,7 +26,8 @@ bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt, ASTContext &Context); -} // namespace decl_ref_expr_utils +} // namespace decl_ref_expr +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/DeclRefExprUtils.cpp =================================================================== --- clang-tidy/utils/DeclRefExprUtils.cpp +++ clang-tidy/utils/DeclRefExprUtils.cpp @@ -15,7 +15,8 @@ namespace clang { namespace tidy { -namespace decl_ref_expr_utils { +namespace utils { +namespace decl_ref_expr { using namespace ::clang::ast_matchers; using llvm::SmallPtrSet; @@ -93,6 +94,7 @@ return isSetDifferenceEmpty(AllDeclRefs, ConstReferenceDeclRefs); } -} // namespace decl_ref_expr_utils +} // namespace decl_ref_expr +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/FixItHintUtils.h =================================================================== --- clang-tidy/utils/FixItHintUtils.h +++ clang-tidy/utils/FixItHintUtils.h @@ -16,7 +16,7 @@ namespace clang { namespace tidy { namespace utils { -namespace create_fix_it { +namespace fixit { /// \brief Creates fix to make VarDecl a reference by adding '&'. FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context); @@ -24,8 +24,8 @@ /// \brief Creates fix to make VarDecl const qualified. FixItHint changeVarDeclToConst(const VarDecl &Var); -} // namespace create_fix_it -} // utils +} // namespace fixit +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/FixItHintUtils.cpp =================================================================== --- clang-tidy/utils/FixItHintUtils.cpp +++ clang-tidy/utils/FixItHintUtils.cpp @@ -14,11 +14,11 @@ namespace clang { namespace tidy { namespace utils { -namespace create_fix_it { +namespace fixit { FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context) { SourceLocation AmpLocation = Var.getLocation(); - auto Token = lexer_utils::getPreviousNonCommentToken(Context, AmpLocation); + auto Token = utils::lexer::getPreviousNonCommentToken(Context, AmpLocation); if (!Token.is(tok::unknown)) AmpLocation = Lexer::getLocForEndOfToken(Token.getLocation(), 0, Context.getSourceManager(), @@ -30,7 +30,7 @@ return FixItHint::CreateInsertion(Var.getTypeSpecStartLoc(), "const "); } -} // namespace create_fix_it +} // namespace fixit } // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/HeaderGuard.h =================================================================== --- clang-tidy/utils/HeaderGuard.h +++ clang-tidy/utils/HeaderGuard.h @@ -14,6 +14,7 @@ namespace clang { namespace tidy { +namespace utils { /// Finds and fixes header guards. class HeaderGuardCheck : public ClangTidyCheck { @@ -40,6 +41,7 @@ StringRef OldGuard = StringRef()) = 0; }; +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/HeaderGuard.cpp =================================================================== --- clang-tidy/utils/HeaderGuard.cpp +++ clang-tidy/utils/HeaderGuard.cpp @@ -16,6 +16,7 @@ namespace clang { namespace tidy { +namespace utils { /// \brief canonicalize a path by removing ./ and ../ components. // FIXME: Consider moving this to llvm::sys::path. @@ -299,5 +300,6 @@ return "endif // " + HeaderGuard.str(); } +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/IncludeInserter.h =================================================================== --- clang-tidy/utils/IncludeInserter.h +++ clang-tidy/utils/IncludeInserter.h @@ -20,6 +20,7 @@ namespace clang { namespace tidy { +namespace utils { // IncludeInserter can be used by ClangTidyChecks in the following fashion: // class MyCheck : public ClangTidyCheck { @@ -70,6 +71,7 @@ friend class IncludeInserterCallback; }; +} // namespace utils } // namespace tidy } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDEINSERTER_H Index: clang-tidy/utils/IncludeInserter.cpp =================================================================== --- clang-tidy/utils/IncludeInserter.cpp +++ clang-tidy/utils/IncludeInserter.cpp @@ -12,6 +12,7 @@ namespace clang { namespace tidy { +namespace utils { class IncludeInserterCallback : public PPCallbacks { public: @@ -80,5 +81,6 @@ end_location); } +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/IncludeSorter.h =================================================================== --- clang-tidy/utils/IncludeSorter.h +++ clang-tidy/utils/IncludeSorter.h @@ -15,6 +15,7 @@ namespace clang { namespace tidy { +namespace utils { // Class used by IncludeSorterCallback and IncludeInserterCallback to record the // names of the inclusions in a given source file being processed and generate @@ -83,6 +84,7 @@ SmallVector IncludeBucket[IK_InvalidInclude]; }; +} // namespace utils } // namespace tidy } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H Index: clang-tidy/utils/IncludeSorter.cpp =================================================================== --- clang-tidy/utils/IncludeSorter.cpp +++ clang-tidy/utils/IncludeSorter.cpp @@ -12,6 +12,7 @@ namespace clang { namespace tidy { +namespace utils { namespace { @@ -291,5 +292,6 @@ return Style == IS_LLVM ? "llvm" : "google"; } +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/LexerUtils.h =================================================================== --- clang-tidy/utils/LexerUtils.h +++ clang-tidy/utils/LexerUtils.h @@ -15,14 +15,16 @@ namespace clang { namespace tidy { -namespace lexer_utils { +namespace utils { +namespace lexer { // Returns previous non-comment token skipping over any comment text or // tok::unknown if not found. Token getPreviousNonCommentToken(const ASTContext &Context, SourceLocation Location); -} // namespace lexer_utils +} // namespace lexer +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/LexerUtils.cpp =================================================================== --- clang-tidy/utils/LexerUtils.cpp +++ clang-tidy/utils/LexerUtils.cpp @@ -11,7 +11,8 @@ namespace clang { namespace tidy { -namespace lexer_utils { +namespace utils { +namespace lexer { Token getPreviousNonCommentToken(const ASTContext &Context, SourceLocation Location) { @@ -34,6 +35,7 @@ return Token; } -} // namespace lexer_utils +} // namespace lexer +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/Matchers.h =================================================================== --- clang-tidy/utils/Matchers.h +++ clang-tidy/utils/Matchers.h @@ -31,12 +31,12 @@ AST_MATCHER(QualType, isExpensiveToCopy) { llvm::Optional IsExpensive = - type_traits::isExpensiveToCopy(Node, Finder->getASTContext()); + utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext()); return IsExpensive && *IsExpensive; } AST_MATCHER(RecordDecl, isTriviallyDefaultConstructible) { - return type_traits::recordIsTriviallyDefaultConstructible( + return utils::type_traits::recordIsTriviallyDefaultConstructible( Node, Finder->getASTContext()); } Index: clang-tidy/utils/TypeTraits.h =================================================================== --- clang-tidy/utils/TypeTraits.h +++ clang-tidy/utils/TypeTraits.h @@ -15,6 +15,7 @@ namespace clang { namespace tidy { +namespace utils { namespace type_traits { // \brief Returns true If \c Type is expensive to copy. @@ -28,6 +29,7 @@ const ASTContext &Context); } // type_traits +} // namespace utils } // namespace tidy } // namespace clang Index: clang-tidy/utils/TypeTraits.cpp =================================================================== --- clang-tidy/utils/TypeTraits.cpp +++ clang-tidy/utils/TypeTraits.cpp @@ -13,6 +13,7 @@ namespace clang { namespace tidy { +namespace utils { namespace type_traits { namespace { @@ -106,6 +107,7 @@ return false; } -} // type_traits +} // namespace type_traits +} // namespace utils } // namespace tidy } // namespace clang