]> granicus.if.org Git - clang/commitdiff
CFG: use Visit instead of VisitStmt to look through parens.
authorJordan Rose <jordan_rose@apple.com>
Tue, 14 Jan 2014 17:29:12 +0000 (17:29 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 14 Jan 2014 17:29:12 +0000 (17:29 +0000)
PR18472

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199227 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp
test/Analysis/cfg.cpp

index 79966fd887dc8e8624bb487366038d25bf25deb4..6d12ea762db5dfd73ba98e858c9e444acb0572de 100644 (file)
@@ -3136,15 +3136,16 @@ CFGBlock *CFGBuilder::VisitCXXNewExpr(CXXNewExpr *NE,
 
   autoCreateBlock();
   appendStmt(Block, NE);
+
   if (NE->getInitializer())
-    Block = VisitStmt(NE->getInitializer(), asc);
+    Block = Visit(NE->getInitializer());
   if (BuildOpts.AddCXXNewAllocator)
     appendNewAllocator(Block, NE);
   if (NE->isArray())
-    Block = VisitStmt(NE->getArraySize(), asc);
+    Block = Visit(NE->getArraySize());
   for (CXXNewExpr::arg_iterator I = NE->placement_arg_begin(),
        E = NE->placement_arg_end(); I != E; ++I)
-    Block = VisitStmt(*I, asc);
+    Block = Visit(*I);
   return Block;
 }
 
index 40bc3138b66ba30a99441b4bbdbc1465e533fe02..374912d2d885edffee1d7f4fd687f74f21471dd4 100644 (file)
@@ -372,3 +372,32 @@ void test_placement_new_array() {
   int buffer[16];
   MyClass* obj = new (buffer) MyClass[5];
 }
+
+
+// For the helper function; see below.
+// CHECK: [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+
+// CHECK: [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK: [B1]
+// CHECK-NEXT:   1: 0
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, NullToPointer, PR18472_t)
+// CHECK-NEXT:   3: (PR18472_t)[B1.2] (CStyleCastExpr, NoOp, PR18472_t)
+// CHECK-NEXT:   4: CFGNewAllocator(int *)
+// CHECK-NEXT:   5: new (([B1.3])) int
+// CHECK-NEXT:   6: return [B1.5];
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+
+extern "C" typedef int *PR18472_t;
+void *operator new (unsigned long, PR18472_t);
+template <class T> T *PR18472() {
+  return new (((PR18472_t) 0)) T;
+}
+void PR18472_helper() {
+  PR18472<int>();
+}
+