summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/cxxnewexpr-callback-inline.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-01-18 00:53:50 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-01-18 00:53:50 +0000
commite941daef399e07ed1d6a4df6bcbb376d485c05e5 (patch)
tree9001bb19a3f644e35e689dfcf2efa37f5f7a5199 /clang/test/Analysis/cxxnewexpr-callback-inline.cpp
parent1c64e617f57297e53abc3d48bedb5a4e3375f644 (diff)
downloadbcm5719-llvm-e941daef399e07ed1d6a4df6bcbb376d485c05e5.tar.gz
bcm5719-llvm-e941daef399e07ed1d6a4df6bcbb376d485c05e5.zip
[analyzer] operator new: Fix callback order for CXXNewExpr.
PreStmt<CXXNewExpr> was never called. Additionally, under c++-allocator-inlining=true, PostStmt<CXXNewExpr> was called twice when the allocator was inlined: once after evaluating the new-expression itself, once after evaluating the allocator call which, for the lack of better options, uses the new-expression as the call site. This patch fixes both problems. Differential Revision: https://reviews.llvm.org/D41934 rdar://problem/12180598 llvm-svn: 322797
Diffstat (limited to 'clang/test/Analysis/cxxnewexpr-callback-inline.cpp')
-rw-r--r--clang/test/Analysis/cxxnewexpr-callback-inline.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/test/Analysis/cxxnewexpr-callback-inline.cpp b/clang/test/Analysis/cxxnewexpr-callback-inline.cpp
new file mode 100644
index 00000000000..c823de85821
--- /dev/null
+++ b/clang/test/Analysis/cxxnewexpr-callback-inline.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config c++-allocator-inlining=true,debug.AnalysisOrder:PreStmtCXXNewExpr=true,debug.AnalysisOrder:PostStmtCXXNewExpr=true,debug.AnalysisOrder:PreCall=true,debug.AnalysisOrder:PostCall=true,debug.AnalysisOrder:NewAllocator=true %s 2>&1 | FileCheck %s
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+namespace std {
+ void *malloc(size_t);
+}
+
+void *operator new(size_t size) { return std::malloc(size); }
+
+struct S {
+ S() {}
+};
+
+void foo();
+
+void test() {
+ S *s = new S();
+ foo();
+}
+
+// CHECK: PreCall (operator new)
+// CHECK-NEXT: PreCall (std::malloc)
+// CHECK-NEXT: PostCall (std::malloc)
+// CHECK-NEXT: PostCall (operator new)
+// CHECK-NEXT: NewAllocator
+// CHECK-NEXT: PreCall (S::S)
+// CHECK-NEXT: PostCall (S::S)
+// CHECK-NEXT: PreStmt<CXXNewExpr>
+// CHECK-NEXT: PostStmt<CXXNewExpr>
+// CHECK-NEXT: PreCall (foo)
+// CHECK-NEXT: PostCall (foo)
OpenPOWER on IntegriCloud