summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTConsumers.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-08-11 22:11:07 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-08-11 22:11:07 +0000
commit35f986d3cd6942cff0fc7f78062924ebebd6988d (patch)
treee525c53745feffb78574b060559e63c1659c697e /clang/lib/Frontend/ASTConsumers.cpp
parentdffd85371606c095882a31dc3cb315c7260a27bf (diff)
downloadbcm5719-llvm-35f986d3cd6942cff0fc7f78062924ebebd6988d.tar.gz
bcm5719-llvm-35f986d3cd6942cff0fc7f78062924ebebd6988d.zip
Modify behavior of -ast-dump-lookups: if -ast-dump is not also provided, dump
anyway. If -ast-dump *is* also provided, then dump the AST declarations as well as the lookup results. This is invaluable for cross-correlating the lookup information with the declarations actually found. llvm-svn: 215393
Diffstat (limited to 'clang/lib/Frontend/ASTConsumers.cpp')
-rw-r--r--clang/lib/Frontend/ASTConsumers.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp
index d836ed42d6b..f53c614b0a3 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -57,7 +57,8 @@ namespace {
bool ShowColors = Out.has_colors();
if (ShowColors)
Out.changeColor(raw_ostream::BLUE);
- Out << (Dump ? "Dumping " : "Printing ") << getName(D) << ":\n";
+ Out << ((Dump || DumpLookups) ? "Dumping " : "Printing ") << getName(D)
+ << ":\n";
if (ShowColors)
Out.resetColor();
print(D);
@@ -79,9 +80,13 @@ namespace {
}
void print(Decl *D) {
if (DumpLookups) {
- if (DeclContext *DC = dyn_cast<DeclContext>(D))
- DC->dumpLookups(Out);
- else
+ if (DeclContext *DC = dyn_cast<DeclContext>(D)) {
+ if (DC == DC->getPrimaryContext())
+ DC->dumpLookups(Out, Dump);
+ else
+ Out << "Lookup map is in primary DeclContext "
+ << DC->getPrimaryContext() << "\n";
+ } else
Out << "Not a DeclContext\n";
} else if (Dump)
D->dump(Out);
@@ -124,8 +129,10 @@ std::unique_ptr<ASTConsumer> clang::CreateASTPrinter(raw_ostream *Out,
}
std::unique_ptr<ASTConsumer> clang::CreateASTDumper(StringRef FilterString,
+ bool DumpDecls,
bool DumpLookups) {
- return llvm::make_unique<ASTPrinter>(nullptr, /*Dump=*/true, FilterString,
+ assert((DumpDecls || DumpLookups) && "nothing to dump");
+ return llvm::make_unique<ASTPrinter>(nullptr, DumpDecls, FilterString,
DumpLookups);
}
OpenPOWER on IntegriCloud