Author: Timm Baeder
Date: 2026-02-10T09:24:11+01:00
New Revision: 8ab034fa1531b5b45bab7d582155d395ff28b043

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

LOG: [clang][bytecode] Handle invalid UnaryExprOrTypeTraitExprs (#180692)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 52776d2a94dba..526e1aee9ce3d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2255,6 +2255,10 @@ static CharUnits AlignOfType(QualType T, const 
ASTContext &ASTCtx,
 template <class Emitter>
 bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr(
     const UnaryExprOrTypeTraitExpr *E) {
+
+  if (E->containsErrors())
+    return false;
+
   UnaryExprOrTypeTrait Kind = E->getKind();
   const ASTContext &ASTCtx = Ctx.getASTContext();
 

diff  --git a/clang/test/AST/ByteCode/invalid.cpp 
b/clang/test/AST/ByteCode/invalid.cpp
index f7d11a9be3f8e..8c641a20a0bd4 100644
--- a/clang/test/AST/ByteCode/invalid.cpp
+++ b/clang/test/AST/ByteCode/invalid.cpp
@@ -164,3 +164,9 @@ namespace NamedLoops {
     } while (0);
   }
 }
+
+constexpr int invalidUnaryOrTypeTrait() {
+  return __builtin_vectorelements * 10; // both-error {{indirection requires 
pointer operand}}
+}
+
+static_assert(invalidUnaryOrTypeTrait() == 11, ""); // both-error {{not an 
integral constant expression}}


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to