diff options
author | macurtis-amd <macurtis@amd.com> | 2025-06-10 11:54:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-10 11:54:50 -0500 |
commit | 2ddf0caaed192495cac99e703cef2fe50191cf49 (patch) | |
tree | 933e5de00f72883f506eda87e436bc72164851e9 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 88f041f3e05e26617856cc096d2e2864dfaa1c7b (diff) | |
download | llvm-2ddf0caaed192495cac99e703cef2fe50191cf49.zip llvm-2ddf0caaed192495cac99e703cef2fe50191cf49.tar.gz llvm-2ddf0caaed192495cac99e703cef2fe50191cf49.tar.bz2 |
[clang][driver] Suppress gnu-line-marker when saving temps (#134621)
When passing `-save-temps` to clang, the generated preprocessed output
uses gnu line markers. This unexpectedly triggers gnu-line-marker
warnings when used with `-Weverything` or `-pedantic`. Even worse,
compilation fails if `-Werror` is used.
This change suppresses gnu-line-marker warnings when invoking clang with
input from a preprocessor job and the user has not otherwise explictly
specified `-Wgnu-line-marker` somewhere on the command line. Note that
this does apply to user provided preprocessed files.
fixes #63802
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 69a91ee..f64613f 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/Basic/DiagnosticLex.h" #include "clang/Basic/HLSLRuntime.h" #include "clang/Basic/MacroBuilder.h" #include "clang/Basic/SourceManager.h" @@ -1644,4 +1645,11 @@ void clang::InitializePreprocessor(Preprocessor &PP, // Copy PredefinedBuffer into the Preprocessor. PP.setPredefines(std::move(PredefineBuffer)); + + // Match gcc behavior regarding gnu-line-directive diagnostics, assuming that + // '-x <*>-cpp-output' is analogous to '-fpreprocessed'. + if (FEOpts.DashX.isPreprocessed()) { + PP.getDiagnostics().setSeverity(diag::ext_pp_gnu_line_directive, + diag::Severity::Ignored, SourceLocation()); + } } |