[cfe-commits] r166237 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/SemaCXX/ast-print.cpp

Eli Friedman eli.friedman at gmail.com
Thu Oct 18 14:53:46 PDT 2012


Author: efriedma
Date: Thu Oct 18 16:53:46 2012
New Revision: 166237

URL: http://llvm.org/viewvc/llvm-project?rev=166237&view=rev
Log:
Use the type as written when pretty-printing C-style casts.  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=166237&r1=166236&r2=166237&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Oct 18 16:53:46 2012
@@ -936,7 +936,7 @@
   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) {

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=166237&r1=166236&r2=166237&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Oct 18 16:53:46 2012
@@ -13,8 +13,7 @@
     MyClass* operator ->() { return object; }
 };
 
-int main()
-{
+void test1() {
     Reference r;
     (r->method());
 }
@@ -23,7 +22,7 @@
 // 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 @@
 
 // CHECK: new (1) int;
 void *operator new (typeof(sizeof(1)), int, int = 2);
-void f2() {
+void test3() {
   new (1) int;
 }
 
@@ -40,9 +39,16 @@
 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);
+}





More information about the cfe-commits mailing list