aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2024-06-04 13:32:11 -0400
committerGitHub <noreply@github.com>2024-06-04 13:32:11 -0400
commite5f7123dfef3a80937d088d846ddb3b2bb1869b9 (patch)
tree0791b3e51594baac8b1d27677960081f5c778ecd /clang/lib/Frontend/CompilerInvocation.cpp
parent7dc84e225e11e37925db6f4f08269f447d2f2347 (diff)
downloadllvm-e5f7123dfef3a80937d088d846ddb3b2bb1869b9.zip
llvm-e5f7123dfef3a80937d088d846ddb3b2bb1869b9.tar.gz
llvm-e5f7123dfef3a80937d088d846ddb3b2bb1869b9.tar.bz2
Disable constexpr function body checking in more situations (#94347)
Before C++23, we would check a constexpr function body to diagnose if the function can never be evaluated in a constant expression context. This was previously required standards behavior, but C++23 relaxed the restrictions with P2448R2. While this checking is useful, it is also quite expensive, especially in pathological cases (see #92924 for an example), because it means the mere presence of a constexpr function definition will require constant evaluation even if the function is not used within the TU. Clang suppresses diagnostics in system headers by default and system headers (like STL implementations) can be full of constexpr function bodies. Now we suppress the check for a diagnostic if the function definition is in a system header or if the `-Winvalid-constexpr` diagnostic is disabled. This should have some mild compile time performance improvements. Also, the previous implementation would disable the diagnostic in C++23 mode entirely. Due to the benefit of the check, this patch now makes it possible to enable the diagnostic explicitly in C++23 mode.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 14ee02c..58694e5 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2407,6 +2407,9 @@ void CompilerInvocationBase::GenerateDiagnosticArgs(
// This option is automatically generated from UndefPrefixes.
if (Warning == "undef-prefix")
continue;
+ // This option is automatically generated from CheckConstexprFunctionBodies.
+ if (Warning == "invalid-constexpr" || Warning == "no-invalid-constexpr")
+ continue;
Consumer(StringRef("-W") + Warning);
}