Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h =================================================================== --- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h +++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h @@ -10,7 +10,6 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UPGRADEGOOGLETESTCASECHECK_H #include "../ClangTidyCheck.h" - #include namespace clang { Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp +++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp @@ -15,13 +15,13 @@ namespace clang { namespace tidy { namespace google { -namespace { -const llvm::StringRef CheckMessage = +static const llvm::StringRef CheckMessage = "Googletest APIs named with 'case' are deprecated; use equivalent APIs " "named with 'suite'"; -llvm::Optional getNewMacroName(llvm::StringRef MacroName) { +static llvm::Optional +getNewMacroName(llvm::StringRef MacroName) { std::pair ReplacementMap[] = { {"TYPED_TEST_CASE", "TYPED_TEST_SUITE"}, {"TYPED_TEST_CASE_P", "TYPED_TEST_SUITE_P"}, @@ -38,6 +38,8 @@ return llvm::None; } +namespace { + class UpgradeGoogletestCasePPCallback : public PPCallbacks { public: UpgradeGoogletestCasePPCallback(UpgradeGoogletestCaseCheck *Check, @@ -81,7 +83,7 @@ if (!Replacement) return; - StringRef FileName = PP->getSourceManager().getFilename( + llvm::StringRef FileName = PP->getSourceManager().getFilename( MD.getMacroInfo()->getDefinitionLoc()); if (!FileName.endswith("gtest/gtest-typed-test.h")) return; @@ -165,9 +167,7 @@ this); } -namespace { - -llvm::StringRef getNewMethodName(llvm::StringRef CurrentName) { +static llvm::StringRef getNewMethodName(llvm::StringRef CurrentName) { std::pair ReplacementMap[] = { {"SetUpTestCase", "SetUpTestSuite"}, {"TearDownTestCase", "TearDownTestSuite"}, @@ -190,21 +190,22 @@ } template -bool isInInstantiation(const NodeType &Node, - const MatchFinder::MatchResult &Result) { +static bool isInInstantiation(const NodeType &Node, + const MatchFinder::MatchResult &Result) { return !match(isInTemplateInstantiation(), Node, *Result.Context).empty(); } template -bool isInTemplate(const NodeType &Node, - const MatchFinder::MatchResult &Result) { +static bool isInTemplate(const NodeType &Node, + const MatchFinder::MatchResult &Result) { internal::Matcher IsInsideTemplate = hasAncestor(decl(anyOf(classTemplateDecl(), functionTemplateDecl()))); return !match(IsInsideTemplate, Node, *Result.Context).empty(); } -bool derivedTypeHasReplacementMethod(const MatchFinder::MatchResult &Result, - llvm::StringRef ReplacementMethod) { +static bool +derivedTypeHasReplacementMethod(const MatchFinder::MatchResult &Result, + llvm::StringRef ReplacementMethod) { const auto *Class = Result.Nodes.getNodeAs("class"); return !match(cxxRecordDecl( unless(isExpansionInFileMatching( @@ -214,7 +215,8 @@ .empty(); } -CharSourceRange getAliasNameRange(const MatchFinder::MatchResult &Result) { +static CharSourceRange +getAliasNameRange(const MatchFinder::MatchResult &Result) { if (const auto *Using = Result.Nodes.getNodeAs("using")) { return CharSourceRange::getTokenRange( Using->getNameInfo().getSourceRange()); @@ -223,8 +225,6 @@ Result.Nodes.getNodeAs("typeloc")->getSourceRange()); } -} // namespace - void UpgradeGoogletestCaseCheck::check(const MatchFinder::MatchResult &Result) { llvm::StringRef ReplacementText; CharSourceRange ReplacementRange;