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

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 06:50:45 PST 2026


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

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

>From b960fcf31cc1107e34b1d111f5a260b71603e2ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 2 Mar 2026 15:49:51 +0100
Subject: [PATCH] [clang][bytecode] Reject non-VarDecl DeclRefExprs

I have no idea how to test this, but this is what the current
interpreter does.
---
 clang/lib/AST/ByteCode/Compiler.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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) {



More information about the cfe-commits mailing list