[clang] [clang][bytecode] Reject non-VarDecl DeclRefExprs (PR #184141)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 06:51:21 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

I have no idea how to test this, but this is what the current interpreter does.

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


1 Files Affected:

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


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 70d3d80b806d1..eadeb900ec845 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -7292,8 +7292,8 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
   // Try to lazily visit (or emit dummy pointers for) declarations
   // we haven't seen yet.
   const auto *VD = dyn_cast<VarDecl>(D);
-  if (!VD)
-    return this->emitDummyPtr(D, E);
+  if (!VD
+    return this->emitInvalid(E);
 
   // For C.
   if (!Ctx.getLangOpts().CPlusPlus) {

``````````

</details>


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


More information about the cfe-commits mailing list