Hi,
I tried out the pretty printer for

co...@schleptop:~/remote/llvm/llvm-mainline-git-cmake-build/bin$ cat test.cpp
#include <cstdio>
int main() {
printf("hello");
return 0;
}

and it crashed with an assertation, the attached patch fixes it.
This is my first patch to clang, and i've no idea whether my approach is actually right, kills kittens or breaks your computer ;)
Cornelius
>From 0c933122edb5ac8f99228a76945e81ba0db4ba5e Mon Sep 17 00:00:00 2001
From: Cornelius Riemenschneider <[email protected]>
Date: Tue, 15 Dec 2009 14:44:14 +0100
Subject: [PATCH] Fix the pretty printer for a hello, world example.

---
 lib/AST/DeclPrinter.cpp |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git lib/AST/DeclPrinter.cpp lib/AST/DeclPrinter.cpp
index 32ac53d..9080430 100644
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -100,6 +100,8 @@ static QualType GetBaseType(QualType T) {
       BaseType = FTy->getResultType();
     else if (const VectorType *VTy = BaseType->getAs<VectorType>())
       BaseType = VTy->getElementType();
+    else if (const ElaboratedType *ETy= BaseType->getAs<ElaboratedType>())
+      BaseType = ETy->getUnderlyingType();
     else
       assert(0 && "Unknown declarator!");
   }
-- 
1.6.2.2

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to