summaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2019-09-04 20:30:00 +0000
committerAaron Ballman <aaron@aaronballman.com>2019-09-04 20:30:00 +0000
commit9ff46a3fe18a95a18b540a5f448bf6f8ad1e7912 (patch)
tree7258fb4396c0c62fff2885ee898358b808efd885 /lib/AST
parent11911b2d6ccf63ef73966cda90c68bf0de78358c (diff)
downloadclang-9ff46a3fe18a95a18b540a5f448bf6f8ad1e7912.tar.gz
Generate parent context id from Decl* instead of DeclContext*.
Because of multiple inheritance, a DeclContext pointer does not produce the same pointer representation as a Decl pointer that references the same AST Node. When dumping the parentDeclContextId field of a node, convert the pointer to Decl* first, so the id can be used to find the AST node it references. Patch by Bert Belder. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/JSONNodeDumper.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/AST/JSONNodeDumper.cpp b/lib/AST/JSONNodeDumper.cpp
index 68f5b29775..b7e8c88224 100644
--- a/lib/AST/JSONNodeDumper.cpp
+++ b/lib/AST/JSONNodeDumper.cpp
@@ -111,9 +111,14 @@ void JSONNodeDumper::Visit(const Decl *D) {
if (const auto *ND = dyn_cast<NamedDecl>(D))
attributeOnlyIfTrue("isHidden", ND->isHidden());
- if (D->getLexicalDeclContext() != D->getDeclContext())
- JOS.attribute("parentDeclContext",
- createPointerRepresentation(D->getDeclContext()));
+ if (D->getLexicalDeclContext() != D->getDeclContext()) {
+ // Because of multiple inheritance, a DeclContext pointer does not produce
+ // the same pointer representation as a Decl pointer that references the
+ // same AST Node.
+ const auto *ParentDeclContextDecl = dyn_cast<Decl>(D->getDeclContext());
+ JOS.attribute("parentDeclContextId",
+ createPointerRepresentation(ParentDeclContextDecl));
+ }
addPreviousDeclaration(D);
InnerDeclVisitor::Visit(D);