[PATCH] D142277: [clang][Interp] Clear metadata when destroying locals
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 21 02:53:22 PST 2023
tbaeder updated this revision to Diff 491060.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142277/new/
https://reviews.llvm.org/D142277
Files:
clang/lib/AST/Interp/EvalEmitter.cpp
clang/lib/AST/Interp/InterpFrame.cpp
Index: clang/lib/AST/Interp/InterpFrame.cpp
===================================================================
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -75,6 +75,10 @@
void InterpFrame::destroy(unsigned Idx) {
for (auto &Local : Func->getScope(Idx).locals()) {
S.deallocate(reinterpret_cast<Block *>(localBlock(Local.Offset)));
+ // Just make sure we're runnnig into some kind of error when a
+ // local variable is used after being destroyed.
+ InlineDescriptor *ID = localInlineDesc(Local.Offset);
+ std::memset(ID, 0, sizeof(InlineDescriptor));
}
}
Index: clang/lib/AST/Interp/EvalEmitter.cpp
===================================================================
--- clang/lib/AST/Interp/EvalEmitter.cpp
+++ clang/lib/AST/Interp/EvalEmitter.cpp
@@ -253,7 +253,12 @@
for (auto &Local : Descriptors[I]) {
auto It = Locals.find(Local.Offset);
assert(It != Locals.end() && "Missing local variable");
- S.deallocate(reinterpret_cast<Block *>(It->second.get()));
+ Block *B = reinterpret_cast<Block *>(It->second.get());
+ S.deallocate(B);
+ // Just make sure we're runnnig into some kind of error when a
+ // local variable is used after being destroyed.
+ InlineDescriptor &ID = *reinterpret_cast<InlineDescriptor *>(B->rawData());
+ std::memset(&ID, 0, sizeof(InlineDescriptor));
}
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142277.491060.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230121/5830a491/attachment.bin>
More information about the cfe-commits
mailing list