Skip to content

Commit

Permalink
[clang][Interp][NFC] Add sanity checks to This op
Browse files Browse the repository at this point in the history
The instance pointer must be casted to the right base.
  • Loading branch information
tbaederr committed Apr 9, 2024
1 parent acff0b0 commit 11ba795
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clang/lib/AST/Interp/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,15 @@ inline bool This(InterpState &S, CodePtr OpPC) {
if (!CheckThis(S, OpPC, This))
return false;

// Ensure the This pointer has been cast to the correct base.
if (!This.isDummy()) {
assert(isa<CXXMethodDecl>(S.Current->getFunction()->getDecl()));
assert(This.getRecord());
assert(
This.getRecord()->getDecl() ==
cast<CXXMethodDecl>(S.Current->getFunction()->getDecl())->getParent());
}

S.Stk.push<Pointer>(This);
return true;
}
Expand Down

0 comments on commit 11ba795

Please sign in to comment.