[clang] ac63824 - [clang][bytecode] Check for invalid call expressions (#181327)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 13 01:16:39 PST 2026


Author: Timm Baeder
Date: 2026-02-13T10:16:34+01:00
New Revision: ac6382425e6c9849387ae0fc4bbaa6127c458af0

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

LOG: [clang][bytecode] Check for invalid call expressions (#181327)

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 16f339e4af816..15e65a4d96581 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5272,6 +5272,8 @@ bool Compiler<Emitter>::VisitBuiltinCallExpr(const CallExpr *E,
 
 template <class Emitter>
 bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
+  if (E->containsErrors())
+    return false;
   const FunctionDecl *FuncDecl = E->getDirectCallee();
 
   if (FuncDecl) {

diff  --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp
index 497f193c5dd82..9f157db889a22 100644
--- a/clang/test/AST/ByteCode/invalid.cpp
+++ b/clang/test/AST/ByteCode/invalid.cpp
@@ -179,3 +179,12 @@ constexpr int invalidUnaryOrTypeTrait2() {
 /// Pointer::toRValue() of a function type.
 void foo() { *(void (*)()) ""; } // both-warning {{expression result unused}}
 
+namespace InvalidCallExpr {
+  constexpr bool foo() {
+    struct A {};
+    A a;
+    a.~A(__builtin_popcountg == 0, ""); // both-error {{builtin functions must be directly called}}
+
+    return true;
+  }
+}


        


More information about the cfe-commits mailing list