diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-06 18:39:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-06 18:39:36 +0000 |
commit | 15e6b40832aa0d83bd3f8d9b5b287632535e67ae (patch) | |
tree | b27f834f16950261613b483c958aeff9f714556f /clang/lib/AST/StmtPrinter.cpp | |
parent | 62408480d9236c9555e865c0456a8d54d7ab97e6 (diff) | |
download | bcm5719-llvm-15e6b40832aa0d83bd3f8d9b5b287632535e67ae.tar.gz bcm5719-llvm-15e6b40832aa0d83bd3f8d9b5b287632535e67ae.zip |
Added PrintRawDeclStmt; use this method to print out DeclStmt instead of using PrintRawDecl (which falsely assumes DeclStmts have only one Decl).
llvm-svn: 57191
Diffstat (limited to 'clang/lib/AST/StmtPrinter.cpp')
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index e95b8c84096..844a3e85601 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -50,6 +50,7 @@ namespace { void PrintRawCompoundStmt(CompoundStmt *S); void PrintRawDecl(Decl *D); + void PrintRawDeclStmt(DeclStmt *S); void PrintRawIfStmt(IfStmt *If); void PrintExpr(Expr *E) { @@ -144,15 +145,28 @@ void StmtPrinter::PrintRawDecl(Decl *D) { } } +void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) { + bool isFirst = false; + + for (DeclStmt::decl_iterator I = S->decl_begin(), E = S->decl_end(); + I != E; ++I) { + + if (!isFirst) OS << ", "; + else isFirst = false; + + PrintRawDecl(*I); + } +} void StmtPrinter::VisitNullStmt(NullStmt *Node) { Indent() << ";\n"; } void StmtPrinter::VisitDeclStmt(DeclStmt *Node) { - for (ScopedDecl *D = Node->getDecl(); D; D = D->getNextDeclarator()) { + for (DeclStmt::decl_iterator I = Node->decl_begin(), E = Node->decl_end(); + I!=E; ++I) { Indent(); - PrintRawDecl(D); + PrintRawDecl(*I); OS << ";\n"; } } @@ -268,7 +282,7 @@ void StmtPrinter::VisitForStmt(ForStmt *Node) { Indent() << "for ("; if (Node->getInit()) { if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit())) - PrintRawDecl(DS->getDecl()); + PrintRawDeclStmt(DS); else PrintExpr(cast<Expr>(Node->getInit())); } @@ -296,7 +310,7 @@ void StmtPrinter::VisitForStmt(ForStmt *Node) { void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) { Indent() << "for ("; if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getElement())) - PrintRawDecl(DS->getDecl()); + PrintRawDeclStmt(DS); else PrintExpr(cast<Expr>(Node->getElement())); OS << " in "; @@ -418,7 +432,7 @@ void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) { Indent() << "@catch("; if (catchStmt->getCatchParamStmt()) { if (DeclStmt *DS = dyn_cast<DeclStmt>(catchStmt->getCatchParamStmt())) - PrintRawDecl(DS->getDecl()); + PrintRawDeclStmt(DS); } OS << ")"; if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) |