[cfe-commits] r71971 - in /cfe/trunk: lib/AST/StmtPrinter.cpp tools/clang-cc/ASTConsumers.cpp
Eli Friedman
eli.friedman at gmail.com
Sat May 16 18:05:35 PDT 2009
Author: efriedma
Date: Sat May 16 20:05:34 2009
New Revision: 71971
URL: http://llvm.org/viewvc/llvm-project?rev=71971&view=rev
Log:
A couple of tweaks to make -ast-print produce code that's closer to
valid C code.
Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/tools/clang-cc/ASTConsumers.cpp
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=71971&r1=71970&r2=71971&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Sat May 16 20:05:34 2009
@@ -289,9 +289,9 @@
Indent();
}
- OS << "while ";
+ OS << "while (";
PrintExpr(Node->getCond());
- OS << ";\n";
+ OS << ");\n";
}
void StmtPrinter::VisitForStmt(ForStmt *Node) {
Modified: cfe/trunk/tools/clang-cc/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/ASTConsumers.cpp?rev=71971&r1=71970&r2=71971&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/ASTConsumers.cpp (original)
+++ cfe/trunk/tools/clang-cc/ASTConsumers.cpp Sat May 16 20:05:34 2009
@@ -141,19 +141,20 @@
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)) {
More information about the cfe-commits
mailing list