]> granicus.if.org Git - clang/commitdiff
Correct pretty printing of array new expressions.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Tue, 2 Dec 2008 22:08:59 +0000 (22:08 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Tue, 2 Dec 2008 22:08:59 +0000 (22:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60444 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtPrinter.cpp

index 445e3e47552e127969cc1f5e0b80cec08c3c88d4..8cd79a8347d60949c4a7ccc3bed7c6fa0ea20d7d 100644 (file)
@@ -953,10 +953,15 @@ void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
   }
   if (E->isParenTypeId())
     OS << "(";
-  // FIXME: This doesn't print the dynamic array size. We'd have to split up
-  // the allocated type to correctly emit that, but without an ASTContext,
-  // that's not possible.
-  OS << E->getAllocatedType().getAsString();
+  std::string TypeS;
+  if (Expr *Size = E->getArraySize()) {
+    llvm::raw_string_ostream s(TypeS);
+    Size->printPretty(s);
+    s.flush();
+    TypeS = "[" + TypeS + "]";
+  }
+  E->getAllocatedType().getAsStringInternal(TypeS);
+  OS << TypeS;
   if (E->isParenTypeId())
     OS << ")";