summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-08-20 02:22:37 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-08-20 02:22:37 +0000
commit8cf3dfea54187769b9c3feeb032f084857e8c79c (patch)
tree2f8a88ea9f55c6612e3b0df1e7067de8c71fe68e /clang/test/Analysis
parentee92f12fd18e42dd417174bcbb6429da60f47afa (diff)
downloadbcm5719-llvm-8cf3dfea54187769b9c3feeb032f084857e8c79c.tar.gz
bcm5719-llvm-8cf3dfea54187769b9c3feeb032f084857e8c79c.zip
[CallGraph] Take into accound calls that aren't within any function bodies.
This patch improves Clang call graph analysis by adding in expressions that are not found in regular function bodies, such as default arguments or member initializers. Patch by Joshua Cranmer! Differential Revision: https://reviews.llvm.org/D65453 llvm-svn: 369321
Diffstat (limited to 'clang/test/Analysis')
-rw-r--r--clang/test/Analysis/cxx-callgraph.cpp29
-rw-r--r--clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp1
2 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/Analysis/cxx-callgraph.cpp b/clang/test/Analysis/cxx-callgraph.cpp
new file mode 100644
index 00000000000..4a48e422ce0
--- /dev/null
+++ b/clang/test/Analysis/cxx-callgraph.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCallGraph %s 2>&1 | FileCheck %s
+
+static int aaa() {
+ return 0;
+}
+
+static int bbb(int param=aaa()) {
+ return 1;
+}
+
+int ddd();
+
+struct c {
+ c(int param=2) : val(bbb(param)) {}
+ int val;
+ int val2 = ddd();
+};
+
+int ddd() {
+ c c;
+ return bbb();
+}
+
+// CHECK:--- Call graph Dump ---
+// CHECK-NEXT: {{Function: < root > calls: aaa bbb c::c ddd}}
+// CHECK-NEXT: {{Function: c::c calls: bbb ddd $}}
+// CHECK-NEXT: {{Function: ddd calls: c::c bbb aaa $}}
+// CHECK-NEXT: {{Function: bbb calls: $}}
+// CHECK-NEXT: {{Function: aaa calls: $}}
diff --git a/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp b/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
index b3d4aef8bc8..e4d256247f9 100644
--- a/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
+++ b/clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
@@ -1,5 +1,6 @@
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
+// RUN: -analyze-function "test()" \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
OpenPOWER on IntegriCloud