diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-08-26 13:03:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-26 13:03:17 +0200 |
commit | 0eebb8bbe545eb0a045ed07091b3e4eda3e68a53 (patch) | |
tree | 0a5292d7bc4b9191441cd33e32440ecf23830286 /clang/lib/AST/ByteCode/Interp.cpp | |
parent | 93b05dd07697cad258128fdabecaa1d54f1aea8c (diff) | |
download | llvm-0eebb8bbe545eb0a045ed07091b3e4eda3e68a53.zip llvm-0eebb8bbe545eb0a045ed07091b3e4eda3e68a53.tar.gz llvm-0eebb8bbe545eb0a045ed07091b3e4eda3e68a53.tar.bz2 |
[clang][bytecode][NFC] Check hasTrivialDtor() in RunDestructors (#155381)
We do this when calling Free() on dynamically allocated memory.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index d4525c8..06b2bdc 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1207,17 +1207,15 @@ static bool runRecordDestructor(InterpState &S, CodePtr OpPC, } // Destructor of this record. - if (const CXXDestructorDecl *Dtor = R->getDestructor(); - Dtor && !Dtor->isTrivial()) { - const Function *DtorFunc = S.getContext().getOrCreateFunction(Dtor); - if (!DtorFunc) - return false; + const CXXDestructorDecl *Dtor = R->getDestructor(); + assert(Dtor); + assert(!Dtor->isTrivial()); + const Function *DtorFunc = S.getContext().getOrCreateFunction(Dtor); + if (!DtorFunc) + return false; - S.Stk.push<Pointer>(BasePtr); - if (!Call(S, OpPC, DtorFunc, 0)) - return false; - } - return true; + S.Stk.push<Pointer>(BasePtr); + return Call(S, OpPC, DtorFunc, 0); } static bool RunDestructors(InterpState &S, CodePtr OpPC, const Block *B) { @@ -1229,6 +1227,9 @@ static bool RunDestructors(InterpState &S, CodePtr OpPC, const Block *B) { assert(Desc->isRecord() || Desc->isCompositeArray()); + if (Desc->hasTrivialDtor()) + return true; + if (Desc->isCompositeArray()) { unsigned N = Desc->getNumElems(); if (N == 0) |