diff options
author | Brad King <brad.king@kitware.com> | 2015-06-23 19:21:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-06-23 19:27:03 (GMT) |
commit | b40df94b22507ddb0d5bb2997f29caa47d56a96b (patch) | |
tree | 4b990944a83a9ecb7d3be4a9deabe5c60590941a | |
parent | 73b947ec075e536535e9cc5bec84d1bed4d43d5b (diff) | |
download | CastXML-b40df94b22507ddb0d5bb2997f29caa47d56a96b.zip CastXML-b40df94b22507ddb0d5bb2997f29caa47d56a96b.tar.gz CastXML-b40df94b22507ddb0d5bb2997f29caa47d56a96b.tar.bz2 |
Output: Generate a FundamentalType for our __float128 typedef
GNU compilers have a builtin __float128 type but Clang does not. Since
commit fe1bb977ee (Detect: Provide __float128 when simulating GNU
compilers, 2015-02-24) we define __float128 as a typedef in the preamble
referencing a struct with the proper size and alignment. Avoid exposing
this implementation detail to clients by generating a FundamentalType
element as a special case when our typedef is encountered. This matches
gccxml behavior when __float128 is encountered.
GitHub-Issue: 18
-rw-r--r-- | src/Output.cxx | 16 | ||||
-rw-r--r-- | test/expect/gccxml.any.GNU-float128.xml.txt | 18 | ||||
-rw-r--r-- | test/expect/gccxml.c89.GNU-float128.xml.txt | 6 |
3 files changed, 18 insertions, 22 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 60a8359..7d2bb05 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -1492,6 +1492,22 @@ void ASTVisitor::OutputClassTemplateSpecializationDecl( void ASTVisitor::OutputTypedefDecl(clang::TypedefDecl const* d, DumpNode const* dn) { + // As a special case, replace our compatibility Typedef for __float128 + // with a FundamentalType so we generate the same thing gccxml did. + if (d->getName() == "__float128" && + clang::isa<clang::TranslationUnitDecl>(d->getDeclContext())) { + clang::SourceLocation sl = d->getLocation(); + if (sl.isValid()) { + clang::FullSourceLoc fsl = this->CTX.getFullLoc(sl).getExpansionLoc(); + if (!this->CI.getSourceManager().getFileEntryForID(fsl.getFileID())) { + this->OS << " <FundamentalType"; + this->PrintIdAttribute(dn); + this->OS << " name=\"__float128\" size=\"128\" align=\"128\"/>\n"; + return; + } + } + } + this->OS << " <Typedef"; this->PrintIdAttribute(dn); this->PrintNameAttribute(d->getName().str()); diff --git a/test/expect/gccxml.any.GNU-float128.xml.txt b/test/expect/gccxml.any.GNU-float128.xml.txt index 9300f76..2797894 100644 --- a/test/expect/gccxml.any.GNU-float128.xml.txt +++ b/test/expect/gccxml.any.GNU-float128.xml.txt @@ -3,23 +3,7 @@ <Function id="_1" name="start" returns="_2" context="_3" location="f1:1" file="f1" line="1" mangled="[^"]+"> <Argument type="_2" location="f1:1" file="f1" line="1"/> </Function> - <Typedef id="_2" name="__float128" type="_4" context="_3"/> - <Struct id="_4" name="" context="_3" members="_5 _6 _7 _8 _9" size="128" align="128"/> - <Field id="_5" name="x" type="_10" context="_4" access="public" offset="0"/> - <Constructor id="_6" context="_4" access="public" location="f0:0" file="f0" line="0" inline="1" artificial="1"( throw="")?/> - <Constructor id="_7" context="_4" access="public" location="f0:0" file="f0" line="0" inline="1" artificial="1"( throw="")?> - <Argument type="_11"/> - </Constructor> - <OperatorMethod id="_8" name="=" returns="_12" context="_4" access="public" location="f0:0" file="f0" line="0" inline="1" artificial="1"( throw="")? mangled="[^"]+"> - <Argument type="_11"/> - </OperatorMethod> - <Destructor id="_9" context="_4" access="public" location="f0:0" file="f0" line="0" inline="1" artificial="1"( throw="")?/> - <ArrayType id="_10" min="0" max="15" type="_13"/> - <ReferenceType id="_11" type="_4c"/> - <CvQualifiedType id="_4c" type="_4" const="1"/> - <ReferenceType id="_12" type="_4"/> - <FundamentalType id="_13" name="char" size="[0-9]+" align="[0-9]+"/> + <FundamentalType id="_2" name="__float128" size="128" align="128"/> <Namespace id="_3" name="::"/> - <File id="f0" name="<builtin>"/> <File id="f1" name=".*/test/input/GNU-float128.cxx"/> </GCC_XML>$ diff --git a/test/expect/gccxml.c89.GNU-float128.xml.txt b/test/expect/gccxml.c89.GNU-float128.xml.txt index 66dfde7..9263155 100644 --- a/test/expect/gccxml.c89.GNU-float128.xml.txt +++ b/test/expect/gccxml.c89.GNU-float128.xml.txt @@ -3,11 +3,7 @@ <Function id="_1" name="start" returns="_2" context="_3" location="f1:1" file="f1" line="1" mangled="[^"]+"> <Argument type="_2" location="f1:1" file="f1" line="1"/> </Function> - <Typedef id="_2" name="__float128" type="_4" context="_3"/> - <Struct id="_4" name="" context="_3" members="_5" size="128" align="128"/> - <Field id="_5" name="x" type="_6" context="_4" access="public" offset="0"/> - <ArrayType id="_6" min="0" max="15" type="_7"/> - <FundamentalType id="_7" name="char" size="[0-9]+" align="[0-9]+"/> + <FundamentalType id="_2" name="__float128" size="128" align="128"/> <Namespace id="_3" name="::"/> <File id="f1" name=".*/test/input/GNU-float128.c"/> </GCC_XML>$ |