Skip to content

Commit e1365ce

Browse files
authored
[clang][bytecode][NFC] Add type assertions to ArrayElem{,Pop} (#109829)
So we don't accidentally try to use those with the wrong type.
1 parent 470e5af commit e1365ce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clang/lib/AST/ByteCode/Interp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,6 +2573,7 @@ inline bool ArrayElem(InterpState &S, CodePtr OpPC, uint32_t Index) {
25732573
if (!CheckLoad(S, OpPC, Ptr))
25742574
return false;
25752575

2576+
assert(Ptr.atIndex(Index).getFieldDesc()->getPrimType() == Name);
25762577
S.Stk.push<T>(Ptr.atIndex(Index).deref<T>());
25772578
return true;
25782579
}
@@ -2584,6 +2585,7 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
25842585
if (!CheckLoad(S, OpPC, Ptr))
25852586
return false;
25862587

2588+
assert(Ptr.atIndex(Index).getFieldDesc()->getPrimType() == Name);
25872589
S.Stk.push<T>(Ptr.atIndex(Index).deref<T>());
25882590
return true;
25892591
}

0 commit comments

Comments
 (0)