[clang] [clang][bytecode][NFC] Add type assertions to ArrayElem{, Pop} (PR #109829)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 13:13:47 PDT 2024
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/109829
>From c73181c82f7c2568bf9d792269c3e35423ed04f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 24 Sep 2024 18:36:11 +0200
Subject: [PATCH] [clang][bytecode][NFC] Add type assertions to ArrayElem{,Pop}
So we don't accidentally try to use those with the wrong type.
---
clang/lib/AST/ByteCode/Interp.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 1f4c302b26197f..b029399a1554b8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2573,6 +2573,7 @@ inline bool ArrayElem(InterpState &S, CodePtr OpPC, uint32_t Index) {
if (!CheckLoad(S, OpPC, Ptr))
return false;
+ assert(Ptr.atIndex(Index).getFieldDesc()->getPrimType() == Name);
S.Stk.push<T>(Ptr.atIndex(Index).deref<T>());
return true;
}
@@ -2584,6 +2585,7 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
if (!CheckLoad(S, OpPC, Ptr))
return false;
+ assert(Ptr.atIndex(Index).getFieldDesc()->getPrimType() == Name);
S.Stk.push<T>(Ptr.atIndex(Index).deref<T>());
return true;
}
More information about the cfe-commits
mailing list