[cfe-commits] r166226 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/SemaCXX/ast-print.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Oct 18 13:54:37 PDT 2012
Author: efriedma
Date: Thu Oct 18 15:54:37 2012
New Revision: 166226
URL: http://llvm.org/viewvc/llvm-project?rev=166226&view=rev
Log:
Fix AST pretty-printing for C++ new expressions with placement arguments with default values.
Based on patch by Grzegorz Jablonski.
Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=166226&r1=166225&r2=166226&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Oct 18 15:54:37 2012
@@ -1415,10 +1415,12 @@
OS << "::";
OS << "new ";
unsigned NumPlace = E->getNumPlacementArgs();
- if (NumPlace > 0) {
+ if (NumPlace > 0 && !isa<CXXDefaultArgExpr>(E->getPlacementArg(0))) {
OS << "(";
PrintExpr(E->getPlacementArg(0));
for (unsigned i = 1; i < NumPlace; ++i) {
+ if (isa<CXXDefaultArgExpr>(E->getPlacementArg(i)))
+ break;
OS << ", ";
PrintExpr(E->getPlacementArg(i));
}
Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=166226&r1=166225&r2=166226&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Oct 18 15:54:37 2012
@@ -30,3 +30,14 @@
switch (int a = 1) { }
}
+// CHECK: new (1) int;
+void *operator new (typeof(sizeof(1)), int, int = 2);
+void f2() {
+ new (1) int;
+}
+
+// CHECK: new X;
+struct X {
+ void *operator new (typeof(sizeof(1)), int = 2);
+};
+void f2() { new X; }
More information about the cfe-commits
mailing list