diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-10-15 21:58:30 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-10-15 21:58:30 +0000 |
| commit | 71bec06c3641006ab5d8bc30018de795425702e7 (patch) | |
| tree | be0d37c9d1076fe4a77becc8beb8f7c871748311 /clang/lib/AST/ASTDumper.cpp | |
| parent | 6c6a29000ee4ebc09c2b0fd1c9a2d6842d4664b7 (diff) | |
| download | bcm5719-llvm-71bec06c3641006ab5d8bc30018de795425702e7.tar.gz bcm5719-llvm-71bec06c3641006ab5d8bc30018de795425702e7.zip | |
Teach the AST dumper to dump the canonical declaration for a mergeable declaration.
llvm-svn: 192739
Diffstat (limited to 'clang/lib/AST/ASTDumper.cpp')
| -rw-r--r-- | clang/lib/AST/ASTDumper.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index bdadbeddbaf..0ed699a12d4 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -578,21 +578,29 @@ void ASTDumper::dumpAttr(const Attr *A) { #include "clang/AST/AttrDump.inc" } -static Decl *getPreviousDeclImpl(...) { - return 0; +static void dumpPreviousDeclImpl(raw_ostream &OS, ...) {} + +template<typename T> +static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) { + const T *First = D->getFirstDeclaration(); + if (First != D) + OS << " first " << First; } template<typename T> -static const Decl *getPreviousDeclImpl(const Redeclarable<T> *D) { - return D->getPreviousDecl(); +static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) { + const T *Prev = D->getPreviousDecl(); + if (Prev) + OS << " prev " << Prev; } -/// Get the previous declaration in the redeclaration chain for a declaration. -static const Decl *getPreviousDecl(const Decl *D) { +/// Dump the previous declaration in the redeclaration chain for a declaration, +/// if any. +static void dumpPreviousDecl(raw_ostream &OS, const Decl *D) { switch (D->getKind()) { #define DECL(DERIVED, BASE) \ case Decl::DERIVED: \ - return getPreviousDeclImpl(cast<DERIVED##Decl>(D)); + return dumpPreviousDeclImpl(OS, cast<DERIVED##Decl>(D)); #define ABSTRACT_DECL(DECL) #include "clang/AST/DeclNodes.inc" } @@ -729,8 +737,7 @@ void ASTDumper::dumpDecl(const Decl *D) { dumpPointer(D); if (D->getLexicalDeclContext() != D->getDeclContext()) OS << " parent " << cast<Decl>(D->getDeclContext()); - if (const Decl *Prev = getPreviousDecl(D)) - OS << " prev " << Prev; + dumpPreviousDecl(OS, D); dumpSourceRange(D->getSourceRange()); bool HasAttrs = D->attr_begin() != D->attr_end(); |

