r193208 - CFG: Properly print delegating initializer CFG elements.
Jordan Rose
jordan_rose at apple.com
Tue Oct 22 16:19:47 PDT 2013
Author: jrose
Date: Tue Oct 22 18:19:47 2013
New Revision: 193208
URL: http://llvm.org/viewvc/llvm-project?rev=193208&view=rev
Log:
CFG: Properly print delegating initializer CFG elements.
...rather than segfaulting.
Patch by Enrico P!
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/initializers-cfg-output.cpp
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=193208&r1=193207&r2=193208&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Oct 22 18:19:47 2013
@@ -3762,6 +3762,8 @@ static void print_elem(raw_ostream &OS,
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,
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 =
Modified: cfe/trunk/test/Analysis/initializers-cfg-output.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/initializers-cfg-output.cpp?rev=193208&r1=193207&r2=193208&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/initializers-cfg-output.cpp (original)
+++ cfe/trunk/test/Analysis/initializers-cfg-output.cpp Tue Oct 22 18:19:47 2013
@@ -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
More information about the cfe-commits
mailing list