summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTConsumers.cpp
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2018-05-14 18:41:44 +0000
committerJoel E. Denny <jdenny.ornl@gmail.com>2018-05-14 18:41:44 +0000
commit7bcc21027d3b3697611de48261f0fa562bd2ed37 (patch)
tree1eea1450a959694fc1e709ac54542c99305063a4 /clang/lib/Frontend/ASTConsumers.cpp
parent215ce4a1cadd10d2533efe601c0e1e665df6bba4 (diff)
downloadbcm5719-llvm-7bcc21027d3b3697611de48261f0fa562bd2ed37.tar.gz
bcm5719-llvm-7bcc21027d3b3697611de48261f0fa562bd2ed37.zip
[AST] Fix -ast-print for _Bool when have diagnostics
For example, given: #define bool _Bool _Bool i; void fn() { 1; } -ast-print produced: tmp.c:3:13: warning: expression result unused void fn() { 1; } ^ bool i; void fn() { 1; } That fails to compile because bool is undefined. Details: Diagnostics print _Bool as bool when the latter is defined as the former. However, diagnostics were altering the printing policy for -ast-print as well. The printed source was then invalid because the preprocessor eats the bool definition. Problematic diagnostics included suppressed warnings (e.g., add -Wno-unused-value to the above example), including those that are suppressed by default. This patch fixes this bug and cleans up some related comments. Reviewed by: aaron.ballman, rsmith Differential Revision: https://reviews.llvm.org/D45093 llvm-svn: 332275
Diffstat (limited to 'clang/lib/Frontend/ASTConsumers.cpp')
-rw-r--r--clang/lib/Frontend/ASTConsumers.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp
index a51d5b4a151..b67c019baed 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -87,9 +87,10 @@ namespace {
<< DC->getPrimaryContext() << "\n";
} else
Out << "Not a DeclContext\n";
- } else if (OutputKind == Print)
- D->print(Out, /*Indentation=*/0, /*PrintInstantiation=*/true);
- else if (OutputKind != None)
+ } else if (OutputKind == Print) {
+ PrintingPolicy Policy(D->getASTContext().getLangOpts());
+ D->print(Out, Policy, /*Indentation=*/0, /*PrintInstantiation=*/true);
+ } else if (OutputKind != None)
D->dump(Out, OutputKind == DumpFull);
}
OpenPOWER on IntegriCloud