diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-11 22:11:07 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-11 22:11:07 +0000 |
commit | 35f986d3cd6942cff0fc7f78062924ebebd6988d (patch) | |
tree | e525c53745feffb78574b060559e63c1659c697e /clang/lib/AST/ASTDumper.cpp | |
parent | dffd85371606c095882a31dc3cb315c7260a27bf (diff) | |
download | bcm5719-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/AST/ASTDumper.cpp')
-rw-r--r-- | clang/lib/AST/ASTDumper.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index ac3c652d470..5d6e18a4506 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -220,7 +220,7 @@ namespace { void dumpName(const NamedDecl *D); bool hasNodes(const DeclContext *DC); void dumpDeclContext(const DeclContext *DC); - void dumpLookups(const DeclContext *DC); + void dumpLookups(const DeclContext *DC, bool DumpDecls); void dumpAttr(const Attr *A); // C++ Utilities @@ -569,7 +569,7 @@ void ASTDumper::dumpDeclContext(const DeclContext *DC) { } } -void ASTDumper::dumpLookups(const DeclContext *DC) { +void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) { IndentScope Indent(*this); OS << "StoredDeclsMap "; @@ -602,9 +602,26 @@ void ASTDumper::dumpLookups(const DeclContext *DC) { RI != RE; ++RI) { if (RI + 1 == RE) lastChild(); - dumpDeclRef(*RI); + + IndentScope LookupIndent(*this); + dumpBareDeclRef(*RI); + if ((*RI)->isHidden()) OS << " hidden"; + + // If requested, dump the redecl chain for this lookup. + if (DumpDecls) { + // Dump earliest decl first. + std::function<void(Decl*)> DumpPrev = [&](Decl *D) { + if (Decl *Prev = D->getPreviousDecl()) { + DumpPrev(Prev); + dumpDecl(Prev); + } + }; + DumpPrev(*RI); + lastChild(); + dumpDecl(*RI); + } } } @@ -2169,13 +2186,14 @@ LLVM_DUMP_METHOD void DeclContext::dumpLookups() const { dumpLookups(llvm::errs()); } -LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream &OS) const { +LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream &OS, + bool DumpDecls) const { const DeclContext *DC = this; while (!DC->isTranslationUnit()) DC = DC->getParent(); ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext(); ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &Ctx.getSourceManager()); - P.dumpLookups(this); + P.dumpLookups(this, DumpDecls); } //===----------------------------------------------------------------------===// |