From: Eli Friedman Date: Thu, 18 Oct 2012 21:53:46 +0000 (+0000) Subject: Use the type as written when pretty-printing C-style casts. Patch by Grzegorz Jablonski. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25c9bc117d8825dce7911f6fddf3725d1914a7c6;p=clang Use the type as written when pretty-printing C-style casts. Patch by Grzegorz Jablonski. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166237 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index d7392af808..5d3b83a150 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -936,7 +936,7 @@ void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) { OS << Node->getAccessor().getName(); } void StmtPrinter::VisitCStyleCastExpr(CStyleCastExpr *Node) { - OS << "(" << Node->getType().getAsString(Policy) << ")"; + OS << "(" << Node->getTypeAsWritten().getAsString(Policy) << ")"; PrintExpr(Node->getSubExpr()); } void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) { diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp index 15fdabfe32..5e89c8b548 100644 --- a/test/SemaCXX/ast-print.cpp +++ b/test/SemaCXX/ast-print.cpp @@ -13,8 +13,7 @@ struct Reference MyClass* operator ->() { return object; } }; -int main() -{ +void test1() { Reference r; (r->method()); } @@ -23,7 +22,7 @@ int main() // CHECK: while (int a = 1) // CHECK: switch (int a = 1) -void f() +void test2() { if (int a = 1) { } while (int a = 1) { } @@ -32,7 +31,7 @@ void f() // CHECK: new (1) int; void *operator new (typeof(sizeof(1)), int, int = 2); -void f2() { +void test3() { new (1) int; } @@ -40,9 +39,16 @@ void f2() { struct X { void *operator new (typeof(sizeof(1)), int = 2); }; -void f2() { new X; } +void test4() { new X; } // CHECK: for (int i = 2097, j = 42; false;) -void forInit() { +void test5() { for (int i = 2097, j = 42; false;) {} } + +// CHECK: test6fn((int &)y); +void test6fn(int& x); +void test6() { + unsigned int y = 0; + test6fn((int&)y); +}