diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-04-27 08:57:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-27 08:57:57 +0200 |
commit | 031101c66f152a1885ece1d7620071cb049edf51 (patch) | |
tree | 0ea0ddac4e5a173be5cbb80fa60fc4e9792c8f3c /clang/lib/AST/ByteCode/InterpBuiltin.cpp | |
parent | 2e230f5685391bd07bd2ef41dfdc832df86d4181 (diff) | |
download | llvm-031101c66f152a1885ece1d7620071cb049edf51.zip llvm-031101c66f152a1885ece1d7620071cb049edf51.tar.gz llvm-031101c66f152a1885ece1d7620071cb049edf51.tar.bz2 |
[clang][bytecode] Diagnose delete of non-heap-allocated blocks (#137475)
With std::allocator::deallocate() calls
Diffstat (limited to 'clang/lib/AST/ByteCode/InterpBuiltin.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/InterpBuiltin.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 770511f..045e79c 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1641,6 +1641,13 @@ static bool interp__builtin_operator_delete(InterpState &S, CodePtr OpPC, Source = Ptr.getDeclDesc()->asExpr(); BlockToDelete = Ptr.block(); + + if (!BlockToDelete->isDynamic()) { + S.FFDiag(Call, diag::note_constexpr_delete_not_heap_alloc) + << Ptr.toDiagnosticString(S.getASTContext()); + if (const auto *D = Ptr.getFieldDesc()->asDecl()) + S.Note(D->getLocation(), diag::note_declared_at); + } } assert(BlockToDelete); |