diff options
author | Brad King <brad.king@kitware.com> | 2014-03-06 20:07:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-24 15:37:20 (GMT) |
commit | 66e499376acbff61aece11ed8c0cef59c05aca3a (patch) | |
tree | 949a00a3ec501f15f0f4bab3822b86d6a47c3d2d | |
parent | 4c2326f24a266c2ee7b88b50c5655fb2edbd082c (diff) | |
download | CastXML-66e499376acbff61aece11ed8c0cef59c05aca3a.zip CastXML-66e499376acbff61aece11ed8c0cef59c05aca3a.tar.gz CastXML-66e499376acbff61aece11ed8c0cef59c05aca3a.tar.bz2 |
Output: Make FundamentalType names match gccxml
The gccxml FundamentalType names used different variants for integer
type names than Clang uses. Hard-code the names for these types.
Add a test case to cover these names.
-rw-r--r-- | src/Output.cxx | 15 | ||||
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/expect/gccxml.FundamentalTypes-xml.txt | 32 | ||||
-rw-r--r-- | test/input/FundamentalTypes.cxx | 15 |
4 files changed, 62 insertions, 1 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 0e4c18c..c24c451 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -1268,7 +1268,20 @@ void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t, { this->OS << " <FundamentalType"; this->PrintIdAttribute(dn); - this->PrintNameAttribute(t->getName(this->CTX.getPrintingPolicy()).str()); + + // gccxml used different name variants than Clang for some types + std::string name; + switch (t->getKind()) { + case clang::BuiltinType::Short: name = "short int"; break; + case clang::BuiltinType::UShort: name = "short unsigned int"; break; + case clang::BuiltinType::Long: name = "long int"; break; + case clang::BuiltinType::ULong: name = "long unsigned int"; break; + case clang::BuiltinType::LongLong: name = "long long int"; break; + case clang::BuiltinType::ULongLong: name = "long long unsigned int"; break; + default: name = t->getName(this->CTX.getPrintingPolicy()).str(); break; + }; + this->PrintNameAttribute(name); + this->OS << "/>\n"; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d3cb069..112d3c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -93,6 +93,7 @@ castxml_test_gccxml(Function-variadic) castxml_test_gccxml(FunctionType) castxml_test_gccxml(FunctionType-variadic) castxml_test_gccxml(FundamentalType) +castxml_test_gccxml(FundamentalTypes) castxml_test_gccxml(Method) castxml_test_gccxml(MethodType) castxml_test_gccxml(MethodType-cv) diff --git a/test/expect/gccxml.FundamentalTypes-xml.txt b/test/expect/gccxml.FundamentalTypes-xml.txt new file mode 100644 index 0000000..6bd2561 --- /dev/null +++ b/test/expect/gccxml.FundamentalTypes-xml.txt @@ -0,0 +1,32 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Namespace id="_1" name="start" context="_2" members="_3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15"/> + <Typedef id="_3" name="t_Char" type="_16" context="_1" location="f1:2" file="f1" line="2"/> + <Typedef id="_4" name="t_SChar" type="_17" context="_1" location="f1:3" file="f1" line="3"/> + <Typedef id="_5" name="t_UChar" type="_18" context="_1" location="f1:4" file="f1" line="4"/> + <Typedef id="_6" name="t_Short" type="_19" context="_1" location="f1:5" file="f1" line="5"/> + <Typedef id="_7" name="t_UShort" type="_20" context="_1" location="f1:6" file="f1" line="6"/> + <Typedef id="_8" name="t_Int" type="_21" context="_1" location="f1:7" file="f1" line="7"/> + <Typedef id="_9" name="t_UInt" type="_22" context="_1" location="f1:8" file="f1" line="8"/> + <Typedef id="_10" name="t_Long" type="_23" context="_1" location="f1:9" file="f1" line="9"/> + <Typedef id="_11" name="t_ULong" type="_24" context="_1" location="f1:10" file="f1" line="10"/> + <Typedef id="_12" name="t_LongLong" type="_25" context="_1" location="f1:11" file="f1" line="11"/> + <Typedef id="_13" name="t_ULongLong" type="_26" context="_1" location="f1:12" file="f1" line="12"/> + <Typedef id="_14" name="t_Float" type="_27" context="_1" location="f1:13" file="f1" line="13"/> + <Typedef id="_15" name="t_Double" type="_28" context="_1" location="f1:14" file="f1" line="14"/> + <FundamentalType id="_16" name="char"/> + <FundamentalType id="_17" name="signed char"/> + <FundamentalType id="_18" name="unsigned char"/> + <FundamentalType id="_19" name="short int"/> + <FundamentalType id="_20" name="short unsigned int"/> + <FundamentalType id="_21" name="int"/> + <FundamentalType id="_22" name="unsigned int"/> + <FundamentalType id="_23" name="long int"/> + <FundamentalType id="_24" name="long unsigned int"/> + <FundamentalType id="_25" name="long long int"/> + <FundamentalType id="_26" name="long long unsigned int"/> + <FundamentalType id="_27" name="float"/> + <FundamentalType id="_28" name="double"/> + <Namespace id="_2" name="::"/> + <File id="f1" name=".*/test/input/FundamentalTypes.cxx"/> +</GCC_XML>$ diff --git a/test/input/FundamentalTypes.cxx b/test/input/FundamentalTypes.cxx new file mode 100644 index 0000000..7ec7c53 --- /dev/null +++ b/test/input/FundamentalTypes.cxx @@ -0,0 +1,15 @@ +namespace start { + typedef char t_Char; + typedef signed char t_SChar; + typedef unsigned char t_UChar; + typedef short t_Short; + typedef unsigned short t_UShort; + typedef int t_Int; + typedef unsigned int t_UInt; + typedef long t_Long; + typedef unsigned long t_ULong; + typedef long long t_LongLong; + typedef unsigned long long t_ULongLong; + typedef float t_Float; + typedef double t_Double; +} |