diff options
author | Anton Yartsev <anton.yartsev@gmail.com> | 2015-04-14 14:18:04 +0000 |
---|---|---|
committer | Anton Yartsev <anton.yartsev@gmail.com> | 2015-04-14 14:18:04 +0000 |
commit | b50f4ba461bcee9c3961646cb58ba440bbf99acb (patch) | |
tree | 8eaf7e845cc426ecd3a6dbafdeac15ab711df336 /clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp | |
parent | bc929b80dc5a1a7112015854ed3301c56203adbb (diff) | |
download | bcm5719-llvm-b50f4ba461bcee9c3961646cb58ba440bbf99acb.tar.gz bcm5719-llvm-b50f4ba461bcee9c3961646cb58ba440bbf99acb.zip |
[analyzer] This implements potential undefbehavior.ZeroAllocDereference checker.
TODO: support realloc(). Currently it is not possible due to the present realloc() handling. Currently RegionState is not being attached to realloc() in case of a zero Size argument.
llvm-svn: 234889
Diffstat (limited to 'clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp')
-rw-r--r-- | clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp b/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp index 639790d31a9..bca223b6e04 100644 --- a/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp +++ b/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp @@ -24,5 +24,16 @@ void testNewDeleteNoWarn() { int *p4 = new int; delete p4; - int j = *p4; // no-warning + int j = *p4; // no-warning +} + +void testUseZeroAllocNoWarn() { + int *p1 = (int *)operator new(0); + *p1 = 1; // no-warning + + int *p2 = (int *)operator new[](0); + p2[0] = 1; // no-warning + + int *p3 = new int[0]; + p3[0] = 1; // no-warning } |