summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTDumper.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-02-07 01:35:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-02-07 01:35:44 +0000
commitf5f43546b3d63380bbb5fda4e4b012a0cf9c0a34 (patch)
tree8d1adf5d8542ea3cdba2cf9fd509253fa25d23f6 /clang/lib/AST/ASTDumper.cpp
parent10f2055812816fa1d295fa36df57826e1f14a7cd (diff)
downloadbcm5719-llvm-f5f43546b3d63380bbb5fda4e4b012a0cf9c0a34.tar.gz
bcm5719-llvm-f5f43546b3d63380bbb5fda4e4b012a0cf9c0a34.zip
AST dumping: indicate the previous declaration for a redeclaration, and
indicate the semantic DC if it's not the lexical DC. In passing, correct the ascii-art child marker for a child of a FriendDecl. llvm-svn: 174570
Diffstat (limited to 'clang/lib/AST/ASTDumper.cpp')
-rw-r--r--clang/lib/AST/ASTDumper.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 646cb16dd8f..3f221a7cde3 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -511,6 +511,27 @@ void ASTDumper::dumpAttr(const Attr *A) {
#include "clang/AST/AttrDump.inc"
}
+static Decl *getPreviousDeclImpl(...) {
+ return 0;
+}
+
+template<typename T>
+static const Decl *getPreviousDeclImpl(const Redeclarable<T> *D) {
+ return D->getPreviousDecl();
+}
+
+/// Get the previous declaration in the redeclaration chain for a declaration.
+static const Decl *getPreviousDecl(const Decl *D) {
+ switch (D->getKind()) {
+#define DECL(DERIVED, BASE) \
+ case Decl::DERIVED: \
+ return getPreviousDeclImpl(cast<DERIVED##Decl>(D));
+#define ABSTRACT_DECL(DECL)
+#include "clang/AST/DeclNodes.inc"
+ }
+ llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
+}
+
//===----------------------------------------------------------------------===//
// C++ Utilities
//===----------------------------------------------------------------------===//
@@ -639,6 +660,10 @@ void ASTDumper::dumpDecl(const Decl *D) {
OS << D->getDeclKindName() << "Decl";
}
dumpPointer(D);
+ if (D->getLexicalDeclContext() != D->getDeclContext())
+ OS << " parent " << cast<Decl>(D->getDeclContext());
+ if (const Decl *Prev = getPreviousDecl(D))
+ OS << " prev " << Prev;
dumpSourceRange(D->getSourceRange());
bool HasAttrs = D->attr_begin() != D->attr_end();
@@ -664,7 +689,7 @@ void ASTDumper::dumpDecl(const Decl *D) {
setMoreChildren(false);
if (HasDeclContext)
- dumpDeclContext(dyn_cast<DeclContext>(D));
+ dumpDeclContext(cast<DeclContext>(D));
}
void ASTDumper::VisitLabelDecl(const LabelDecl *D) {
@@ -1049,6 +1074,7 @@ void ASTDumper::VisitAccessSpecDecl(const AccessSpecDecl *D) {
}
void ASTDumper::VisitFriendDecl(const FriendDecl *D) {
+ lastChild();
if (TypeSourceInfo *T = D->getFriendType())
dumpType(T->getType());
else
OpenPOWER on IntegriCloud