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

via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 23:51:40 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/181327.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2) 
- (modified) clang/test/AST/ByteCode/invalid.cpp (+9) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index dd10ad7d82653..2bb94f3ca2354 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;
+  }
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/181327


More information about the cfe-commits mailing list