diff options
-rw-r--r-- | src/Output.cxx | 79 | ||||
-rw-r--r-- | test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/expect/gccxml.MethodType-cv-xml.txt | 13 | ||||
-rw-r--r-- | test/expect/gccxml.MethodType-xml.txt | 12 | ||||
-rw-r--r-- | test/expect/gccxml.OffsetType-cv-xml.txt | 11 | ||||
-rw-r--r-- | test/expect/gccxml.OffsetType-xml.txt | 9 | ||||
-rw-r--r-- | test/input/MethodType-cv.cxx | 2 | ||||
-rw-r--r-- | test/input/MethodType.cxx | 2 | ||||
-rw-r--r-- | test/input/OffsetType-cv.cxx | 2 | ||||
-rw-r--r-- | test/input/OffsetType.cxx | 2 |
10 files changed, 132 insertions, 4 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 5d97270..82cef66 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -218,6 +218,10 @@ class ASTVisitor: public ASTVisitorBase void PrintNameAttribute(std::string const& name); void PrintNameAttribute(clang::NamedDecl 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); + /** Print a type="..." attribute with the XML IDREF for the given (possibly cv-qualified) type. Also queues the given type for later output. */ @@ -265,7 +269,8 @@ class ASTVisitor: public ASTVisitorBase This encompasses functionality common to all the function type output methods. */ void OutputFunctionTypeHelper(clang::FunctionProtoType const* t, - DumpNode const* dn, const char* tag); + DumpNode const* dn, const char* tag, + clang::Type const* c); /** Output an <Argument/> element inside a function element. */ void OutputFunctionArgument(clang::ParmVarDecl const* a, bool complete); @@ -307,6 +312,12 @@ class ASTVisitor: public ASTVisitorBase DumpNode const* dn); void OutputLValueReferenceType(clang::LValueReferenceType const* t, DumpNode const* dn); + void OutputMemberPointerType(clang::MemberPointerType const* t, + DumpNode const* dn); + void OutputMethodType(clang::FunctionProtoType const* t, + clang::Type const* c, DumpNode const* dn); + void OutputOffsetType(clang::QualType t, clang::Type const* c, + DumpNode const* dn); void OutputPointerType(clang::PointerType const* t, DumpNode const* dn); /** Queue declarations matching given qualified name in given context. */ @@ -559,7 +570,12 @@ void ASTVisitor::OutputDecl(clang::Decl const* d, DumpNode const* dn) void ASTVisitor::OutputType(DumpType dt, DumpNode const* dn) { clang::QualType t = dt.Type; - if(t.hasLocalQualifiers()) { + clang::Type const* c = dt.Class; + + if(c) { + // Output the method type. + this->OutputMethodType(t->getAs<clang::FunctionProtoType>(), c, dn); + } else if(t.hasLocalQualifiers()) { // Output the qualified type. This will queue // the unqualified type if necessary. this->OutputCvQualifiedType(t, dn); @@ -685,6 +701,14 @@ void ASTVisitor::PrintNameAttribute(clang::NamedDecl const* d) } //---------------------------------------------------------------------------- +void ASTVisitor::PrintBaseTypeAttribute(clang::Type const* c, bool complete) +{ + this->OS << " basetype=\""; + this->PrintTypeIdRef(clang::QualType(c, 0), complete); + this->OS << "\""; +} + +//---------------------------------------------------------------------------- void ASTVisitor::PrintTypeAttribute(clang::QualType t, bool complete) { this->OS << " type=\""; @@ -866,11 +890,24 @@ void ASTVisitor::OutputFunctionHelper(clang::FunctionDecl const* d, //---------------------------------------------------------------------------- void ASTVisitor::OutputFunctionTypeHelper(clang::FunctionProtoType const* t, - DumpNode const* dn, const char* tag) + DumpNode const* dn, const char* tag, + clang::Type const* c) { this->OS << " <" << tag; this->PrintIdAttribute(dn); + if(c) { + this->PrintBaseTypeAttribute(c, dn->Complete); + } this->PrintReturnsAttribute(t->getReturnType(), dn->Complete); + if(t->isConst()) { + this->OS << " const=\"1\""; + } + if(t->isVolatile()) { + this->OS << " volatile=\"1\""; + } + if(t->isRestrict()) { + this->OS << " restrict=\"1\""; + } if(t->param_type_begin() != t->param_type_end()) { this->OS << ">\n"; for (clang::FunctionProtoType::param_type_iterator @@ -1139,7 +1176,7 @@ void ASTVisitor::OutputIncompleteArrayType(clang::IncompleteArrayType const* t, void ASTVisitor::OutputFunctionProtoType(clang::FunctionProtoType const* t, DumpNode const* dn) { - this->OutputFunctionTypeHelper(t, dn, "FunctionType"); + this->OutputFunctionTypeHelper(t, dn, "FunctionType", 0); } //---------------------------------------------------------------------------- @@ -1153,6 +1190,40 @@ void ASTVisitor::OutputLValueReferenceType(clang::LValueReferenceType const* t, } //---------------------------------------------------------------------------- +void ASTVisitor::OutputMemberPointerType(clang::MemberPointerType const* t, + DumpNode const* dn) +{ + if(t->isMemberDataPointerType()) { + this->OutputOffsetType(t->getPointeeType(), t->getClass(), dn); + } else { + this->OS << " <PointerType"; + this->PrintIdAttribute(dn); + unsigned int id = this->AddDumpNode( + DumpType(t->getPointeeType(), t->getClass()), false); + this->OS << " type=\"_" << id << "\""; + this->OS << "/>\n"; + } +} + +//---------------------------------------------------------------------------- +void ASTVisitor::OutputMethodType(clang::FunctionProtoType const* t, + clang::Type const* c, DumpNode const* dn) +{ + this->OutputFunctionTypeHelper(t, dn, "MethodType", c); +} + +//---------------------------------------------------------------------------- +void ASTVisitor::OutputOffsetType(clang::QualType t, clang::Type const* c, + DumpNode const* dn) +{ + this->OS << " <OffsetType"; + this->PrintIdAttribute(dn); + this->PrintBaseTypeAttribute(c, dn->Complete); + this->PrintTypeAttribute(t, dn->Complete); + this->OS << "/>\n"; +} + +//---------------------------------------------------------------------------- void ASTVisitor::OutputPointerType(clang::PointerType const* t, DumpNode const* dn) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 66ec112..51f1fb7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -80,7 +80,11 @@ castxml_test_gccxml(FunctionType) castxml_test_gccxml(FunctionType-variadic) castxml_test_gccxml(FundamentalType) castxml_test_gccxml(Method) +castxml_test_gccxml(MethodType) +castxml_test_gccxml(MethodType-cv) castxml_test_gccxml(Namespace) +castxml_test_gccxml(OffsetType) +castxml_test_gccxml(OffsetType-cv) castxml_test_gccxml(OperatorFunction) castxml_test_gccxml(OperatorMethod) castxml_test_gccxml(PointerType) diff --git a/test/expect/gccxml.MethodType-cv-xml.txt b/test/expect/gccxml.MethodType-cv-xml.txt new file mode 100644 index 0000000..eaa84ca --- /dev/null +++ b/test/expect/gccxml.MethodType-cv-xml.txt @@ -0,0 +1,13 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Typedef id="_1" name="start" type="_3cv" context="_4" location="f1:2" file="f1" line="2"/> + <CvQualifiedType id="_3cv" type="_3" const="1" volatile="1"/> + <PointerType id="_3" type="_5"/> + <Namespace id="_4" name="::"/> + <MethodType id="_5" basetype="_6" returns="_7" const="1" volatile="1"> + <Argument type="_7"/> + </MethodType> + <Class id="_6" name="A" context="_4" location="f1:1" file="f1" line="1" incomplete="1"/> + <FundamentalType id="_7" name="int"/> + <File id="f1" name=".*/test/input/MethodType-cv.cxx"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.MethodType-xml.txt b/test/expect/gccxml.MethodType-xml.txt new file mode 100644 index 0000000..dae67b0 --- /dev/null +++ b/test/expect/gccxml.MethodType-xml.txt @@ -0,0 +1,12 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Typedef id="_1" name="start" type="_2" context="_3" location="f1:2" file="f1" line="2"/> + <PointerType id="_2" type="_4"/> + <Namespace id="_3" name="::"/> + <MethodType id="_4" basetype="_5" returns="_6"> + <Argument type="_6"/> + </MethodType> + <Class id="_5" name="A" context="_3" location="f1:1" file="f1" line="1" incomplete="1"/> + <FundamentalType id="_6" name="int"/> + <File id="f1" name=".*/test/input/MethodType.cxx"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.OffsetType-cv-xml.txt b/test/expect/gccxml.OffsetType-cv-xml.txt new file mode 100644 index 0000000..7b849dc --- /dev/null +++ b/test/expect/gccxml.OffsetType-cv-xml.txt @@ -0,0 +1,11 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Typedef id="_1" name="start" type="_3cv" context="_4" location="f1:2" file="f1" line="2"/> + <CvQualifiedType id="_3cv" type="_3" const="1" volatile="1"/> + <OffsetType id="_3" basetype="_5" type="_7cv"/> + <Class id="_5" name="A" context="_4" location="f1:1" file="f1" line="1" incomplete="1"/> + <CvQualifiedType id="_7cv" type="_7" const="1" volatile="1"/> + <FundamentalType id="_7" name="int"/> + <Namespace id="_4" name="::"/> + <File id="f1" name=".*/test/input/OffsetType-cv.cxx"/> +</GCC_XML>$ diff --git a/test/expect/gccxml.OffsetType-xml.txt b/test/expect/gccxml.OffsetType-xml.txt new file mode 100644 index 0000000..5a4c63e --- /dev/null +++ b/test/expect/gccxml.OffsetType-xml.txt @@ -0,0 +1,9 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Typedef id="_1" name="start" type="_2" context="_3" location="f1:2" file="f1" line="2"/> + <OffsetType id="_2" basetype="_4" type="_5"/> + <Class id="_4" name="A" context="_3" location="f1:1" file="f1" line="1" incomplete="1"/> + <FundamentalType id="_5" name="int"/> + <Namespace id="_3" name="::"/> + <File id="f1" name=".*/test/input/OffsetType.cxx"/> +</GCC_XML>$ diff --git a/test/input/MethodType-cv.cxx b/test/input/MethodType-cv.cxx new file mode 100644 index 0000000..1ab435d --- /dev/null +++ b/test/input/MethodType-cv.cxx @@ -0,0 +1,2 @@ +class A; +typedef int (A::* const volatile start)(int) const volatile; diff --git a/test/input/MethodType.cxx b/test/input/MethodType.cxx new file mode 100644 index 0000000..2f9e67c --- /dev/null +++ b/test/input/MethodType.cxx @@ -0,0 +1,2 @@ +class A; +typedef int (A::* start)(int); diff --git a/test/input/OffsetType-cv.cxx b/test/input/OffsetType-cv.cxx new file mode 100644 index 0000000..efbc605 --- /dev/null +++ b/test/input/OffsetType-cv.cxx @@ -0,0 +1,2 @@ +class A; +typedef int const volatile A::* const volatile start; diff --git a/test/input/OffsetType.cxx b/test/input/OffsetType.cxx new file mode 100644 index 0000000..5a030d5 --- /dev/null +++ b/test/input/OffsetType.cxx @@ -0,0 +1,2 @@ +class A; +typedef int A::* start; |