[clang] f34ff31 - [clang][bytecode] Check `diagnosing()` in `Invalid()` (#227640)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 05:10:26 PDT 2026


Author: Timm Baeder
Date: 2026-09-30T14:10:19+02:00
New Revision: f34ff31c6521b4fa62a24122743d1e76a6756087

URL: https://github.com/llvm/llvm-project/commit/f34ff31c6521b4fa62a24122743d1e76a6756087
DIFF: https://github.com/llvm/llvm-project/commit/f34ff31c6521b4fa62a24122743d1e76a6756087.diff

LOG: [clang][bytecode] Check `diagnosing()` in `Invalid()` (#227640)

In large C TUs, it happens pretty frequently that we reject something
via `Invalid()`, but nobody ever gets to see the diagnostics we emit.
Just don't emit a diagnostic in that case.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/InterpHelpers.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/InterpHelpers.h b/clang/lib/AST/ByteCode/InterpHelpers.h
index 50f0462a93f16..25881bbfe1a3b 100644
--- a/clang/lib/AST/ByteCode/InterpHelpers.h
+++ b/clang/lib/AST/ByteCode/InterpHelpers.h
@@ -126,9 +126,10 @@ static inline llvm::RoundingMode getRoundingMode(FPOptions FPO) {
 }
 
 inline bool Invalid(InterpState &S, CodePtr OpPC) {
-  const SourceLocation &Loc = S.Current->getLocation(OpPC);
-  S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr)
-      << S.Current->getRange(OpPC);
+  if (S.diagnosing())
+    S.FFDiag(S.Current->getSource(OpPC),
+             diag::note_invalid_subexpr_in_const_expr)
+        << S.Current->getRange(OpPC);
   return false;
 }
 


        


More information about the cfe-commits mailing list