diff options
author | Michka Popoff <michkapopoff@gmail.com> | 2015-04-05 12:33:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-04-08 14:50:35 (GMT) |
commit | 45d5a24874afa9343df9048bb240b655e9b49965 (patch) | |
tree | 81f1903f5d4cde8c45ceb2023414aef06e800683 /src | |
parent | 57c93dfba8395299cd939c40dd894f40cfd4ec28 (diff) | |
download | CastXML-45d5a24874afa9343df9048bb240b655e9b49965.zip CastXML-45d5a24874afa9343df9048bb240b655e9b49965.tar.gz CastXML-45d5a24874afa9343df9048bb240b655e9b49965.tar.bz2 |
Output: Add "size" and "align" attributes on builtin types and structs
This information is produced by gccxml, so add it to our output too.
Since we don't know the architecture that will be targeted during
testing, match any size and align values with "[0-9]+".
Diffstat (limited to 'src')
-rw-r--r-- | src/Output.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index e1a5e05..31f91be 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -233,6 +233,10 @@ class ASTVisitor: public ASTVisitorBase /** Print an offset="..." attribute. */ void PrintOffsetAttribute(unsigned int const& offset); + /** Print size="..." and align="..." attributes. */ + void PrintABIAttributes(clang::TypeInfo const& t); + void PrintABIAttributes(clang::TypeDecl const* d); + /** Print a basetype="..." attribute with the XML IDREF for the given type. Also queues the given type for later output. */ void PrintBaseTypeAttribute(clang::Type const* c, bool complete); @@ -916,6 +920,24 @@ void ASTVisitor::PrintOffsetAttribute(unsigned int const& offset) } //---------------------------------------------------------------------------- +void ASTVisitor::PrintABIAttributes(clang::TypeDecl const* d) +{ + if(clang::TypeDecl const* td = clang::dyn_cast<clang::TypeDecl>(d)) { + clang::Type const* ty = td->getTypeForDecl(); + if(!ty->isIncompleteType()) { + this->PrintABIAttributes(this->CTX.getTypeInfo(ty)); + } + } +} + +//---------------------------------------------------------------------------- +void ASTVisitor::PrintABIAttributes(clang::TypeInfo const& t) +{ + this->OS << " size=\"" << t.Width << "\""; + this->OS << " align=\"" << t.Align << "\""; +} + +//---------------------------------------------------------------------------- void ASTVisitor::PrintBaseTypeAttribute(clang::Type const* c, bool complete) { this->OS << " basetype=\""; @@ -1296,6 +1318,7 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d, } else { this->OS << " incomplete=\"1\""; } + this->PrintABIAttributes(d); if(doBases) { this->OS << ">\n"; for(clang::CXXRecordDecl::base_class_const_iterator i = dx->bases_begin(), @@ -1559,6 +1582,7 @@ void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t, default: name = t->getName(this->CTX.getPrintingPolicy()).str(); break; }; this->PrintNameAttribute(name); + this->PrintABIAttributes(this->CTX.getTypeInfo(t)); this->OS << "/>\n"; } |