summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/aggrinit-cfg-output.cpp
diff options
context:
space:
mode:
authorGabor Horvath <xazax@google.com>2019-12-17 17:53:26 -0800
committerGabor Horvath <xazax@google.com>2019-12-17 17:56:06 -0800
commitea93d7d6421612e9ea51b321eaf97fbdd64fe39b (patch)
tree0e4a65aaa8fb9d74ec52da9d193fe0f934c7202c /clang/test/Analysis/aggrinit-cfg-output.cpp
parent547659ae56f5827055f71b495d7b08c10badadb5 (diff)
downloadbcm5719-llvm-ea93d7d6421612e9ea51b321eaf97fbdd64fe39b.tar.gz
bcm5719-llvm-ea93d7d6421612e9ea51b321eaf97fbdd64fe39b.zip
[CFG] Add an option to expand CXXDefaultInitExpr into aggregate initialization
This is useful for clients that are relying on linearized CFGs for evaluating subexpressions and want the default initializer to be evaluated properly. The upcoming lifetime analysis is using this but it might also be useful for the static analyzer at some point. Differential Revision: https://reviews.llvm.org/D71642
Diffstat (limited to 'clang/test/Analysis/aggrinit-cfg-output.cpp')
-rw-r--r--clang/test/Analysis/aggrinit-cfg-output.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/Analysis/aggrinit-cfg-output.cpp b/clang/test/Analysis/aggrinit-cfg-output.cpp
new file mode 100644
index 00000000000..2e95a7f9e24
--- /dev/null
+++ b/clang/test/Analysis/aggrinit-cfg-output.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-expand-default-aggr-inits=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+static char a[] = "foobar";
+
+struct StringRef {
+ const char *member = nullptr;
+ int len = 3;
+};
+
+int main() {
+ StringRef s{a};
+ (void)s;
+}
+
+// CHECK: [B1]
+// CHECK-NEXT: 1: a
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, ArrayToPointerDecay, char *)
+// CHECK-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const char *)
+// CHECK-NEXT: 4: 3
+// CHECK-NEXT: 5:
+// CHECK-NEXT: 6: {[B1.1]}
+// CHECK-NEXT: 7: StringRef s{a};
+// CHECK-NEXT: 8: s
+// CHECK-NEXT: 9: (void)[B1.8] (CStyleCastExpr, ToVoid, void)
+// CHECK-NEXT: Preds (1): B2
+// CHECK-NEXT: Succs (1): B0
+
OpenPOWER on IntegriCloud