Skip to content

Commit

Permalink
[clang][Interp] Don't explicitly call InterpState destructor()
Browse files Browse the repository at this point in the history
This broke the msan builders because the destructor will be called
twice. Should've guessed.
  • Loading branch information
tbaederr committed Oct 24, 2023
1 parent d68826d commit 684e4c0
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions clang/lib/AST/Interp/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,18 @@ const llvm::fltSemantics &Context::getFloatSemantics(QualType T) const {
}

bool Context::Run(State &Parent, const Function *Func, APValue &Result) {
InterpState State(Parent, *P, Stk, *this);
State.Current = new InterpFrame(State, Func, /*Caller=*/nullptr, {});
if (Interpret(State, Result)) {
assert(Stk.empty());
return true;
}

// We explicitly delete our state here, so the Stk.clear() call
// below doesn't violently free values the destructor would
// otherwise access.
State.~InterpState();
{
InterpState State(Parent, *P, Stk, *this);
State.Current = new InterpFrame(State, Func, /*Caller=*/nullptr, {});
if (Interpret(State, Result)) {
assert(Stk.empty());
return true;
}

// State gets destroyed here, so the Stk.clear() below doesn't accidentally
// remove values the State's destructor might accedd.
}

Stk.clear();
return false;
Expand Down

0 comments on commit 684e4c0

Please sign in to comment.