diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -418,6 +418,11 @@ StringRef getCurrentMainFile() const { return Context->getCurrentFile(); } /// Returns the language options from the context. const LangOptions &getLangOpts() const { return Context->getLangOpts(); } + /// Returns true when the check is run in a use case when only 1 fix will be + /// applied at a time. + bool areDiagsSelfContained() const { + return Context->areDiagsSelfContained(); + } }; /// Read a named option from the ``Context`` and parse it as a bool. diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h @@ -173,6 +173,10 @@ return AllowEnablingAnalyzerAlphaCheckers; } + void setSelfContainedDiags(bool Value) { SelfContainedDiags = Value; } + + bool areDiagsSelfContained() const { return SelfContainedDiags; } + using DiagLevelAndFormatString = std::pair; DiagLevelAndFormatString getDiagLevelAndFormatString(unsigned DiagnosticID, SourceLocation Loc) { @@ -208,6 +212,7 @@ std::string ProfilePrefix; bool AllowEnablingAnalyzerAlphaCheckers; + bool SelfContainedDiags; }; /// Check whether a given diagnostic should be suppressed due to the presence diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -160,7 +160,8 @@ bool AllowEnablingAnalyzerAlphaCheckers) : DiagEngine(nullptr), OptionsProvider(std::move(OptionsProvider)), Profile(false), - AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers) { + AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers), + SelfContainedDiags(false) { // Before the first translation unit we can get errors related to command-line // parsing, use empty string for the file name in this case. setCurrentFile(""); diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -27,7 +27,8 @@ StringLikeClasses(utils::options::parseStringList( Options.get("StringLikeClasses", "::std::basic_string"))), IncludeInserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)), + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()), AbseilStringsMatchHeader( Options.get("AbseilStringsMatchHeader", "absl/strings/match.h")) {} diff --git a/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp @@ -43,8 +43,8 @@ Options.get("UseCXXStaticCastsInCppSources", true)), UseCXXHeadersInCppSources(Options.get("UseCXXHeadersInCppSources", true)), IncludeInserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)) { -} + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} void ImplicitWideningOfMultiplicationResultCheck::registerPPCallbacks( const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) { diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -27,7 +27,8 @@ ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeInserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)), + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()), MathHeader(Options.get("MathHeader", "")) {} void InitVariablesCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp @@ -284,7 +284,7 @@ Diag << FixItHint::CreateInsertion(InsertPos, Insertion, FirstToCtorInits) << FixItHint::CreateRemoval(StmtRange); - FirstToCtorInits = false; + FirstToCtorInits = areDiagsSelfContained(); } } } diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp @@ -22,7 +22,8 @@ StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)) {} + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} void ProBoundsConstantArrayIndexCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp --- a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp @@ -20,7 +20,8 @@ StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)) {} + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} void UniqueptrResetReleaseCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -463,7 +463,8 @@ MinConfidence(Options.get("MinConfidence", Confidence::CL_Reasonable)), NamingStyle(Options.get("NamingStyle", VariableNamer::NS_CamelCase)), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)), + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()), UseCxx20IfAvailable(Options.get("UseCxx20ReverseRanges", true)), ReverseFunction(Options.get("MakeReverseRangeFunction", "")), ReverseHeader(Options.get("MakeReverseRangeHeader", "")) { @@ -800,9 +801,12 @@ const ast_matchers::BoundNodes &Nodes, const ForStmt *Loop, LoopFixerKind FixerKind) { - // If we already modified the range of this for loop, don't do any further - // updates on this iteration. - if (TUInfo->getReplacedVars().count(Loop)) + // In self contained diagnosics mode we don't want dependancies on other + // loops, otherwise, If we already modified the range of this for loop, don't + // do any further updates on this iteration. + if (areDiagsSelfContained()) + TUInfo = std::make_unique(); + else if (TUInfo->getReplacedVars().count(Loop)) return false; // Check that we have exactly one index variable and at most one end variable. diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp @@ -44,7 +44,8 @@ StringRef MakeSmartPtrFunctionName) : ClangTidyCheck(Name, Context), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)), + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()), MakeSmartPtrFunctionHeader( Options.get("MakeSmartPtrFunctionHeader", "")), MakeSmartPtrFunctionName( diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -121,7 +121,8 @@ PassByValueCheck::PassByValueCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)), + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()), ValuesOnly(Options.get("ValuesOnly", false)) {} void PassByValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp @@ -41,7 +41,8 @@ ClangTidyContext *Context) : ClangTidyCheck(Name, Context), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)) {} + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} void ReplaceAutoPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "IncludeStyle", Inserter.getStyle()); diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp @@ -24,8 +24,8 @@ ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeInserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)) { -} + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} void ReplaceRandomShuffleCheck::registerMatchers(MatchFinder *Finder) { const auto Begin = hasArgument(0, expr()); diff --git a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp --- a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp @@ -32,8 +32,8 @@ StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeInserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)) { -} + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} void TypePromotionInMathFnCheck::registerPPCallbacks( const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) { diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -69,7 +69,8 @@ StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), Inserter(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::IS_LLVM)), + utils::IncludeSorter::IS_LLVM), + areDiagsSelfContained()), AllowedTypes( utils::options::parseStringList(Options.get("AllowedTypes", ""))) {} diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h --- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h +++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h @@ -59,7 +59,8 @@ /// using \code /// Options.getLocalOrGlobal("IncludeStyle", ) /// \endcode - explicit IncludeInserter(IncludeSorter::IncludeStyle Style); + explicit IncludeInserter(IncludeSorter::IncludeStyle Style, + bool SelfContainedDiags); /// Registers this with the Preprocessor \p PP, must be called before this /// class is used. @@ -93,6 +94,7 @@ llvm::DenseMap> InsertedHeaders; const SourceManager *SourceMgr{nullptr}; const IncludeSorter::IncludeStyle Style; + const bool SelfContainedDiags; friend class IncludeInserterCallback; }; diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp --- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp +++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp @@ -36,8 +36,9 @@ IncludeInserter *Inserter; }; -IncludeInserter::IncludeInserter(IncludeSorter::IncludeStyle Style) - : Style(Style) {} +IncludeInserter::IncludeInserter(IncludeSorter::IncludeStyle Style, + bool SelfContainedDiags) + : Style(Style), SelfContainedDiags(SelfContainedDiags) {} void IncludeInserter::registerPreprocessor(Preprocessor *PP) { assert(PP && "PP shouldn't be null"); @@ -73,7 +74,9 @@ return llvm::None; // We assume the same Header will never be included both angled and not // angled. - if (!InsertedHeaders[FileID].insert(Header).second) + // In self contained diags mode we don't track what headers we have already + // inserted. + if (!SelfContainedDiags && !InsertedHeaders[FileID].insert(Header).second) return llvm::None; return getOrCreate(FileID).createIncludeInsertion(Header, IsAngled); diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp --- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp @@ -30,8 +30,8 @@ TransformerClangTidyCheck::TransformerClangTidyCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - Inserter( - Options.getLocalOrGlobal("IncludeStyle", IncludeSorter::IS_LLVM)) {} + Inserter(Options.getLocalOrGlobal("IncludeStyle", IncludeSorter::IS_LLVM), + areDiagsSelfContained()) {} // This constructor cannot dispatch to the simpler one (below), because, in // order to get meaningful results from `getLangOpts` and `Options`, we need the diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -360,6 +360,7 @@ CTContext->setDiagnosticsEngine(&Clang->getDiagnostics()); CTContext->setASTContext(&Clang->getASTContext()); CTContext->setCurrentFile(Filename); + CTContext->setSelfContainedDiags(true); CTChecks = CTFactories.createChecks(CTContext.getPointer()); llvm::erase_if(CTChecks, [&](const auto &Check) { return !Check->isLanguageVersionSupported(CTContext->getLangOpts()); diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp --- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp +++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp @@ -595,6 +595,67 @@ Diag(Main.range(), "do not use 'else' after 'return'")))); } +TEST(DiagnosticTest, ClangTidySelfContainedDiags) { + Annotations Main(R"cpp($MathHeader[[]] + struct Foo{ + int A, B; + Foo()$Fix[[]] { + $A[[A = 1;]] + $B[[B = 1;]] + } + }; + void InitVariables() { + float $C[[C]]$CFix[[]]; + double $D[[D]]$DFix[[]]; + } + )cpp"); + TestTU TU = TestTU::withCode(Main.code()); + TU.ClangTidyProvider = + addTidyChecks("cppcoreguidelines-prefer-member-initializer," + "cppcoreguidelines-init-variables"); + clangd::Fix ExpectedAFix; + ExpectedAFix.Message = + "'A' should be initialized in a member initializer of the constructor"; + ExpectedAFix.Edits.push_back(TextEdit{Main.range("Fix"), " : A(1)"}); + ExpectedAFix.Edits.push_back(TextEdit{Main.range("A"), ""}); + + // When invoking clang-tidy normally, this code would produce `, B(1)` as the + // fix the `B` member, as it would think its already included the ` : ` from + // the previous `A` fix. + clangd::Fix ExpectedBFix; + ExpectedBFix.Message = + "'B' should be initialized in a member initializer of the constructor"; + ExpectedBFix.Edits.push_back(TextEdit{Main.range("Fix"), " : B(1)"}); + ExpectedBFix.Edits.push_back(TextEdit{Main.range("B"), ""}); + + clangd::Fix ExpectedCFix; + ExpectedCFix.Message = "variable 'C' is not initialized"; + ExpectedCFix.Edits.push_back(TextEdit{Main.range("CFix"), " = NAN"}); + ExpectedCFix.Edits.push_back( + TextEdit{Main.range("MathHeader"), "#include \n\n"}); + + // Again in clang-tidy only the include directive would be emitted for the + // first warning. However we need the include attaching for both warnings. + clangd::Fix ExpectedDFix; + ExpectedDFix.Message = "variable 'D' is not initialized"; + ExpectedDFix.Edits.push_back(TextEdit{Main.range("DFix"), " = NAN"}); + ExpectedDFix.Edits.push_back( + TextEdit{Main.range("MathHeader"), "#include \n\n"}); + EXPECT_THAT( + *TU.build().getDiagnostics(), + UnorderedElementsAre( + AllOf(Diag(Main.range("A"), "'A' should be initialized in a member " + "initializer of the constructor"), + WithFix(EqualToFix(ExpectedAFix))), + AllOf(Diag(Main.range("B"), "'B' should be initialized in a member " + "initializer of the constructor"), + WithFix(EqualToFix(ExpectedBFix))), + AllOf(Diag(Main.range("C"), "variable 'C' is not initialized"), + WithFix(EqualToFix(ExpectedCFix))), + AllOf(Diag(Main.range("D"), "variable 'D' is not initialized"), + WithFix(EqualToFix(ExpectedDFix))))); +} + TEST(DiagnosticsTest, Preprocessor) { // This looks like a preamble, but there's an #else in the middle! // Check that: diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp --- a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp @@ -30,8 +30,10 @@ public: IncludeInserterCheckBase(StringRef CheckName, ClangTidyContext *Context, utils::IncludeSorter::IncludeStyle Style = - utils::IncludeSorter::IS_Google) - : ClangTidyCheck(CheckName, Context), Inserter(Style) {} + utils::IncludeSorter::IS_Google, + bool SelfContainedDiags = false) + : ClangTidyCheck(CheckName, Context), + Inserter(Style, SelfContainedDiags) {} void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override { @@ -85,6 +87,19 @@ } }; +class MultipleHeaderSingleInserterCheck : public IncludeInserterCheckBase { +public: + MultipleHeaderSingleInserterCheck(StringRef CheckName, + ClangTidyContext *Context) + : IncludeInserterCheckBase(CheckName, Context, + utils::IncludeSorter::IS_Google, + /*SelfContainedDiags=*/true) {} + + std::vector headersToInclude() const override { + return {"path/to/header.h", "path/to/header2.h", "path/to/header.h"}; + } +}; + class CSystemIncludeInserterCheck : public IncludeInserterCheckBase { public: CSystemIncludeInserterCheck(StringRef CheckName, ClangTidyContext *Context) @@ -246,6 +261,41 @@ PreCode, "clang_tidy/tests/insert_includes_test_input2.cc")); } +TEST(IncludeInserterTest, InsertMultipleIncludesNoDeduplicate) { + const char *PreCode = R"( +#include "clang_tidy/tests/insert_includes_test_header.h" + +#include +#include + +#include "path/to/a/header.h" + +void foo() { + int a = 0; +})"; + // FIXME: ClangFormat bug - https://bugs.llvm.org/show_bug.cgi?id=49298 + // clang-format off + const char *PostCode = R"( +#include "clang_tidy/tests/insert_includes_test_header.h" + +#include +#include + +#include "path/to/a/header.h" +#include "path/to/header.h" +#include "path/to/header2.h" +#include "path/to/header.h" + +void foo() { + int a = 0; +})"; + // clang-format on + + EXPECT_EQ(PostCode, + runCheckOnCode( + PreCode, "clang_tidy/tests/insert_includes_test_input2.cc")); +} + TEST(IncludeInserterTest, InsertBeforeFirstNonSystemInclude) { const char *PreCode = R"( #include "clang_tidy/tests/insert_includes_test_header.h"