aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/InterpBuiltin.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-27 08:57:57 +0200
committerGitHub <noreply@github.com>2025-04-27 08:57:57 +0200
commit031101c66f152a1885ece1d7620071cb049edf51 (patch)
tree0ea0ddac4e5a173be5cbb80fa60fc4e9792c8f3c /clang/lib/AST/ByteCode/InterpBuiltin.cpp
parent2e230f5685391bd07bd2ef41dfdc832df86d4181 (diff)
downloadllvm-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.cpp7
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);