Skip to content

Commit 11ba795

Browse files
committed
[clang][Interp][NFC] Add sanity checks to This op
The instance pointer must be casted to the right base.
1 parent acff0b0 commit 11ba795

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,15 @@ inline bool This(InterpState &S, CodePtr OpPC) {
18461846
if (!CheckThis(S, OpPC, This))
18471847
return false;
18481848

1849+
// Ensure the This pointer has been cast to the correct base.
1850+
if (!This.isDummy()) {
1851+
assert(isa<CXXMethodDecl>(S.Current->getFunction()->getDecl()));
1852+
assert(This.getRecord());
1853+
assert(
1854+
This.getRecord()->getDecl() ==
1855+
cast<CXXMethodDecl>(S.Current->getFunction()->getDecl())->getParent());
1856+
}
1857+
18491858
S.Stk.push<Pointer>(This);
18501859
return true;
18511860
}

0 commit comments

Comments
 (0)