diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp')
| -rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp | 24 | 
1 files changed, 20 insertions, 4 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp b/contrib/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp index d83128adb511..1b91c86f9139 100644 --- a/contrib/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp @@ -728,6 +728,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,      Builder.defineMacro("__cpp_size_t_suffix", "202011L");      Builder.defineMacro("__cpp_if_consteval", "202106L");      Builder.defineMacro("__cpp_multidimensional_subscript", "202211L"); +    Builder.defineMacro("__cpp_auto_cast", "202110L");    }    // We provide those C++23 features as extensions in earlier language modes, so @@ -1364,12 +1365,22 @@ static void InitializePredefinedMacros(const TargetInfo &TI,    TI.getTargetDefines(LangOpts, Builder);  } +static void InitializePGOProfileMacros(const CodeGenOptions &CodeGenOpts, +                                       MacroBuilder &Builder) { +  if (CodeGenOpts.hasProfileInstr()) +    Builder.defineMacro("__LLVM_INSTR_PROFILE_GENERATE"); + +  if (CodeGenOpts.hasProfileIRUse() || CodeGenOpts.hasProfileClangUse()) +    Builder.defineMacro("__LLVM_INSTR_PROFILE_USE"); +} +  /// InitializePreprocessor - Initialize the preprocessor getting it and the  /// environment ready to process a single file. -void clang::InitializePreprocessor( -    Preprocessor &PP, const PreprocessorOptions &InitOpts, -    const PCHContainerReader &PCHContainerRdr, -    const FrontendOptions &FEOpts) { +void clang::InitializePreprocessor(Preprocessor &PP, +                                   const PreprocessorOptions &InitOpts, +                                   const PCHContainerReader &PCHContainerRdr, +                                   const FrontendOptions &FEOpts, +                                   const CodeGenOptions &CodeGenOpts) {    const LangOptions &LangOpts = PP.getLangOpts();    std::string PredefineBuffer;    PredefineBuffer.reserve(4080); @@ -1416,6 +1427,11 @@ void clang::InitializePreprocessor(    InitializeStandardPredefinedMacros(PP.getTargetInfo(), PP.getLangOpts(),                                       FEOpts, Builder); +  // The PGO instrumentation profile macros are driven by options +  // -fprofile[-instr]-generate/-fcs-profile-generate/-fprofile[-instr]-use, +  // hence they are not guarded by InitOpts.UsePredefines. +  InitializePGOProfileMacros(CodeGenOpts, Builder); +    // Add on the predefines from the driver.  Wrap in a #line directive to report    // that they come from the command line.    Builder.append("# 1 \"<command line>\" 1");  | 
