summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-03-18 15:40:57 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-24 15:37:20 (GMT)
commit95c7a3dea54a7c23bf5fd3a9a7fd5adfe1f45414 (patch)
tree6712ab58b1ff81fea60c51a9df2e9ea2fca7db5e /src
parentfbc3aa539f7db36f949daeb37472b807d48e03c9 (diff)
downloadCastXML-95c7a3dea54a7c23bf5fd3a9a7fd5adfe1f45414.zip
CastXML-95c7a3dea54a7c23bf5fd3a9a7fd5adfe1f45414.tar.gz
CastXML-95c7a3dea54a7c23bf5fd3a9a7fd5adfe1f45414.tar.bz2
Output: Fix output of forward-declared classes
When adding a dump node for a class, use the class definition, if available, instead of the canonical declaration. They may not be the same when a class is forward-declared before it is defined. We need to use the definition to get all members.
Diffstat (limited to 'src')
-rw-r--r--src/Output.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index c24c451..856a79b 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -380,6 +380,14 @@ public:
//----------------------------------------------------------------------------
unsigned int ASTVisitor::AddDumpNode(clang::Decl const* d, bool complete) {
+ // Select the definition or canonical declaration.
+ d = d->getCanonicalDecl();
+ if(clang::RecordDecl const* rd = clang::dyn_cast<clang::RecordDecl>(d)) {
+ if(clang::RecordDecl const* rdd = rd->getDefinition()) {
+ d = rdd;
+ }
+ }
+
// Replace some decls with those they reference.
switch (d->getKind()) {
case clang::Decl::UsingShadow:
@@ -390,8 +398,7 @@ unsigned int ASTVisitor::AddDumpNode(clang::Decl const* d, bool complete) {
break;
}
- // Add the node for the canonical declaration instance.
- return this->AddDumpNodeImpl(d->getCanonicalDecl(), complete);
+ return this->AddDumpNodeImpl(d, complete);
}
//----------------------------------------------------------------------------