Author: Timm Baeder
Date: 2025-07-08T17:14:02+02:00
New Revision: 65f94d75187bdab5c853e31fbf35267258f0be67

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

LOG: [clang][bytecode] Don't crash on erroneous switch conditions (#147533)

Not attaching a test since I've only seen this when compiling a large
c++26 test case as c++17.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Compiler.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 51c234d0d0471..ee9c3890794af 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5629,6 +5629,9 @@ bool Compiler<Emitter>::visitContinueStmt(const 
ContinueStmt *S) {
 template <class Emitter>
 bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
   const Expr *Cond = S->getCond();
+  if (Cond->containsErrors())
+    return false;
+
   PrimType CondT = this->classifyPrim(Cond->getType());
   LocalScope<Emitter> LS(this);
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to