aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/StmtPrinter.cpp4
-rw-r--r--tools/clang-cc/ASTConsumers.cpp27
2 files changed, 16 insertions, 15 deletions
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index cf1a255236..380634daf3 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -289,9 +289,9 @@ void StmtPrinter::VisitDoStmt(DoStmt *Node) {
Indent();
}
- OS << "while ";
+ OS << "while (";
PrintExpr(Node->getCond());
- OS << ";\n";
+ OS << ");\n";
}
void StmtPrinter::VisitForStmt(ForStmt *Node) {
diff --git a/tools/clang-cc/ASTConsumers.cpp b/tools/clang-cc/ASTConsumers.cpp
index d68b61cc3d..48bf85b4dc 100644
--- a/tools/clang-cc/ASTConsumers.cpp
+++ b/tools/clang-cc/ASTConsumers.cpp
@@ -141,19 +141,20 @@ void DeclPrinter:: PrintDecl(Decl *D) {
if (const IdentifierInfo *II = TD->getIdentifier())
Out << II->getName();
- Out << " {\n";
- ChangeIndent(1);
- // FIXME: Shouldn't pass a NULL context
- ASTContext *Context = 0;
- for (DeclContext::decl_iterator i = TD->decls_begin(*Context);
- i != TD->decls_end(*Context);
- ++i)
- PrintDecl(*i);
- ChangeIndent(-1);
- Indent();
- Out << "}";
-
- Out << "\n";
+ if (TD->isDefinition()) {
+ Out << " {\n";
+ ChangeIndent(1);
+ // FIXME: Shouldn't pass a NULL context
+ ASTContext *Context = 0;
+ for (DeclContext::decl_iterator i = TD->decls_begin(*Context);
+ i != TD->decls_end(*Context);
+ ++i)
+ PrintDecl(*i);
+ ChangeIndent(-1);
+ Indent();
+ Out << "}";
+ }
+ Out << ";\n";
} else if (TemplateDecl *TempD = dyn_cast<TemplateDecl>(D)) {
PrintTemplateDecl(TempD);
} else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {