summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-06-25 20:48:28 +0000
committerJordan Rose <jordan_rose@apple.com>2012-06-25 20:48:28 +0000
commit4688e608612d9582e150815f39a2b6a5d60596fd (patch)
treedba18bcf2b9bb52c91cdbbe519609cb7ea3d5d7a /clang/test
parent55ce352d4d0119913a9c51ba81fd2659e76cab84 (diff)
downloadbcm5719-llvm-4688e608612d9582e150815f39a2b6a5d60596fd.tar.gz
bcm5719-llvm-4688e608612d9582e150815f39a2b6a5d60596fd.zip
[analyzer] Be careful about implicitly-declared operator new/delete. (PR13090)
The implicit global allocation functions do not have valid source locations, but we still want to treat them as being "system header" functions for the purposes of how they affect program state. llvm-svn: 159160
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/new.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Analysis/new.cpp b/clang/test/Analysis/new.cpp
index 8093eff3a1c..723d033bc79 100644
--- a/clang/test/Analysis/new.cpp
+++ b/clang/test/Analysis/new.cpp
@@ -5,6 +5,21 @@ void clang_analyzer_eval(bool);
typedef typeof(sizeof(int)) size_t;
extern "C" void *malloc(size_t);
+int someGlobal;
+void testImplicitlyDeclaredGlobalNew() {
+ if (someGlobal != 0)
+ return;
+
+ // This used to crash because the global operator new is being implicitly
+ // declared and it does not have a valid source location. (PR13090)
+ void *x = ::operator new(0);
+ ::operator delete(x);
+
+ // Check that the new/delete did not invalidate someGlobal;
+ clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}}
+}
+
+
// This is the standard placement new.
inline void* operator new(size_t, void* __p) throw()
{
OpenPOWER on IntegriCloud