mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 12:36:37 +00:00

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
29 lines
742 B
C++
29 lines
742 B
C++
// 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
|
|
|