diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-10-22 23:19:47 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-10-22 23:19:47 +0000 |
commit | 69d0aed6f17a352da5a5f1bbddf6c2508b1e586a (patch) | |
tree | 8f708c24182dc3224acfb541f3e460fb5c236df9 /clang | |
parent | af589f70d090df47e80b176bbf6d9c0e754c34c9 (diff) | |
download | bcm5719-llvm-69d0aed6f17a352da5a5f1bbddf6c2508b1e586a.tar.gz bcm5719-llvm-69d0aed6f17a352da5a5f1bbddf6c2508b1e586a.zip |
CFG: Properly print delegating initializer CFG elements.
...rather than segfaulting.
Patch by Enrico P!
llvm-svn: 193208
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 4 | ||||
-rw-r--r-- | clang/test/Analysis/initializers-cfg-output.cpp | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index c7fe9f3a886..5b48a15def0 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -3762,6 +3762,8 @@ static void print_elem(raw_ostream &OS, StmtPrinterHelper* Helper, const CXXCtorInitializer *I = IE->getInitializer(); if (I->isBaseInitializer()) OS << I->getBaseClass()->getAsCXXRecordDecl()->getName(); + else if (I->isDelegatingInitializer()) + OS << I->getTypeSourceInfo()->getType()->getAsCXXRecordDecl()->getName(); else OS << I->getAnyMember()->getName(); OS << "("; @@ -3771,6 +3773,8 @@ static void print_elem(raw_ostream &OS, StmtPrinterHelper* Helper, if (I->isBaseInitializer()) OS << " (Base initializer)\n"; + else if (I->isDelegatingInitializer()) + OS << " (Delegating initializer)\n"; else OS << " (Member initializer)\n"; } else if (Optional<CFGAutomaticObjDtor> DE = diff --git a/clang/test/Analysis/initializers-cfg-output.cpp b/clang/test/Analysis/initializers-cfg-output.cpp index b62d979d5bf..db3c0fb9900 100644 --- a/clang/test/Analysis/initializers-cfg-output.cpp +++ b/clang/test/Analysis/initializers-cfg-output.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s class A { public: @@ -43,6 +43,13 @@ TestControlFlow::TestControlFlow(bool b) int v; } +class TestDelegating { + int x, z; + public: + TestDelegating() : TestDelegating(2, 3) {} + TestDelegating(int x, int z) : x(x), z(z) {} +}; + // CHECK: [B2 (ENTRY)] // CHECK: Succs (1): B1 // CHECK: [B1] @@ -95,3 +102,14 @@ TestControlFlow::TestControlFlow(bool b) // CHECK: Succs (2): B2 B3 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: 2 +// CHECK: 2: 3 +// CHECK: 3: [B1.1], [B1.2] (CXXConstructExpr, class TestDelegating) +// CHECK: 4: TestDelegating([B1.3]) (Delegating initializer) +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 |