summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-17 01:05:34 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-17 01:05:34 +0000
commit8f1d33e21890f9afd5dce7435952ba147e25a2fd (patch)
tree7936677a88e4fc97681e8e81fcb18184633bac33 /clang/tools
parent3c01271e93ffc3cf4348127a865a9a02430dd89d (diff)
downloadbcm5719-llvm-8f1d33e21890f9afd5dce7435952ba147e25a2fd.tar.gz
bcm5719-llvm-8f1d33e21890f9afd5dce7435952ba147e25a2fd.zip
A couple of tweaks to make -ast-print produce code that's closer to
valid C code. llvm-svn: 71971
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/clang-cc/ASTConsumers.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/clang/tools/clang-cc/ASTConsumers.cpp b/clang/tools/clang-cc/ASTConsumers.cpp
index d68b61cc3d5..48bf85b4dcc 100644
--- a/clang/tools/clang-cc/ASTConsumers.cpp
+++ b/clang/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)) {
OpenPOWER on IntegriCloud