Skip to content

Commit 9df7824

Browse files
authored
[clang][bytecode][NFC] Check InitializingBlocks in _within_lifetime (#155378)
This kind of check is exactly why InterpState::InitializingBlocks exists.
1 parent 943a00e commit 9df7824

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,12 +2505,8 @@ static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC,
25052505
}
25062506

25072507
// Check if we're currently running an initializer.
2508-
for (InterpFrame *Frame = S.Current; Frame; Frame = Frame->Caller) {
2509-
if (const Function *F = Frame->getFunction();
2510-
F && F->isConstructor() && Frame->getThis().block() == Ptr.block()) {
2511-
return Error(2);
2512-
}
2513-
}
2508+
if (llvm::is_contained(S.InitializingBlocks, Ptr.block()))
2509+
return Error(2);
25142510
if (S.EvaluatingDecl && Ptr.getDeclDesc()->asVarDecl() == S.EvaluatingDecl)
25152511
return Error(2);
25162512

0 commit comments

Comments
 (0)