[cfe-commits] r39549 - /cfe/cfe/trunk/AST/StmtPrinter.cpp
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:45:29 PDT 2007
Author: clattner
Date: Wed Jul 11 11:45:29 2007
New Revision: 39549
URL: http://llvm.org/viewvc/llvm-project?rev=39549&view=rev
Log:
Generalize this to support printing any valuedecl, e.g. function definitions.
We now print:
extern void blah();
as:
void (blah)();
Strange, but ok :)
Modified:
cfe/cfe/trunk/AST/StmtPrinter.cpp
Modified: cfe/cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/StmtPrinter.cpp?rev=39549&r1=39548&r2=39549&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/cfe/trunk/AST/StmtPrinter.cpp Wed Jul 11 11:45:29 2007
@@ -94,14 +94,16 @@
void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
// FIXME: Need to complete/beautify this...this code simply shows the
// nodes are where they need to be.
- if (BlockVarDecl *localVar = dyn_cast<BlockVarDecl>(Node->getDecl())) {
- Indent() << localVar->getType().getAsString();
- OS << " " << localVar->getName() << ";\n";
- } else if (TypedefDecl *localType = dyn_cast<TypedefDecl>(Node->getDecl())) {
+ if (TypedefDecl *localType = dyn_cast<TypedefDecl>(Node->getDecl())) {
Indent() << "typedef " << localType->getUnderlyingType().getAsString();
OS << " " << localType->getName() << ";\n";
- } else
- assert(0 && "Unexpected decl (expecting BlockVarDecl or TypedefDecl");
+ } else if (ValueDecl *VD = dyn_cast<ValueDecl>(Node->getDecl())) {
+ std::string Name = VD->getName();
+ VD->getType().getAsStringInternal(Name);
+ Indent() << Name << ";\n";
+ } else
+ // FIXME: "struct x;"
+ assert(0 && "Unexpected decl");
}
void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
More information about the cfe-commits
mailing list