diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2019-09-04 20:30:00 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2019-09-04 20:30:00 +0000 |
commit | 40e3760472eae18919f4be8906869701db8f8f03 (patch) | |
tree | b1baa20526f6e91d6cd1221f969f2a2ceb37df6c /clang/lib/AST/JSONNodeDumper.cpp | |
parent | 41adc374086d69082a1cef48ebea771833564afa (diff) | |
download | llvm-40e3760472eae18919f4be8906869701db8f8f03.zip llvm-40e3760472eae18919f4be8906869701db8f8f03.tar.gz llvm-40e3760472eae18919f4be8906869701db8f8f03.tar.bz2 |
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.
llvm-svn: 370970
Diffstat (limited to 'clang/lib/AST/JSONNodeDumper.cpp')
-rw-r--r-- | clang/lib/AST/JSONNodeDumper.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index 68f5b29..b7e8c88 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/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); |