Teach the AST dumper to dump the canonical declaration for a mergeable declaration.

llvm-svn: 192739
This commit is contained in:
Richard Smith 2013-10-15 21:58:30 +00:00
parent 6c6a29000e
commit 71bec06c36
1 changed files with 16 additions and 9 deletions

View File

@ -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();