diff options
-rw-r--r-- | src/Output.cxx | 36 | ||||
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/expect/gccxml.FunctionType-xml.txt | 11 | ||||
-rw-r--r-- | test/input/FunctionType.cxx | 1 |
4 files changed, 49 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index ad91f55..c93acfc 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -248,6 +248,12 @@ class ASTVisitor: public ASTVisitorBase const char* tag, std::string const& name, unsigned int flags); + /** Output a function type element using the tag given by the caller. + This encompasses functionality common to all the function type + output methods. */ + void OutputFunctionTypeHelper(clang::FunctionProtoType const* t, + DumpNode const* dn, const char* tag); + /** Output an <Argument/> element inside a function element. */ void OutputFunctionArgument(clang::ParmVarDecl const* a, bool complete); @@ -284,6 +290,8 @@ class ASTVisitor: public ASTVisitorBase DumpNode const* dn); void OutputIncompleteArrayType(clang::IncompleteArrayType const* t, DumpNode const* dn); + void OutputFunctionProtoType(clang::FunctionProtoType const* t, + DumpNode const* dn); void OutputLValueReferenceType(clang::LValueReferenceType const* t, DumpNode const* dn); void OutputPointerType(clang::PointerType const* t, DumpNode const* dn); @@ -837,6 +845,27 @@ void ASTVisitor::OutputFunctionHelper(clang::FunctionDecl const* d, } //---------------------------------------------------------------------------- +void ASTVisitor::OutputFunctionTypeHelper(clang::FunctionProtoType const* t, + DumpNode const* dn, const char* tag) +{ + this->OS << " <" << tag; + this->PrintIdAttribute(dn); + this->PrintReturnsAttribute(t->getReturnType(), dn->Complete); + if(t->param_type_begin() != t->param_type_end()) { + this->OS << ">\n"; + for (clang::FunctionProtoType::param_type_iterator + i = t->param_type_begin(), e = t->param_type_end(); i != e; ++i) { + this->OS << " <Argument"; + this->PrintTypeAttribute(*i, dn->Complete); + this->OS << "/>\n"; + } + this->OS << " </" << tag << ">\n"; + } else { + this->OS << "/>\n"; + } +} + +//---------------------------------------------------------------------------- void ASTVisitor::OutputFunctionArgument(clang::ParmVarDecl const* a, bool complete) { @@ -1084,6 +1113,13 @@ void ASTVisitor::OutputIncompleteArrayType(clang::IncompleteArrayType const* t, } //---------------------------------------------------------------------------- +void ASTVisitor::OutputFunctionProtoType(clang::FunctionProtoType const* t, + DumpNode const* dn) +{ + this->OutputFunctionTypeHelper(t, dn, "FunctionType"); +} + +//---------------------------------------------------------------------------- void ASTVisitor::OutputLValueReferenceType(clang::LValueReferenceType const* t, DumpNode const* dn) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a8762ab..e6a69f1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -75,6 +75,7 @@ castxml_test_gccxml(Field) castxml_test_gccxml(Function) castxml_test_gccxml(Function-template) castxml_test_gccxml(Function-throw) +castxml_test_gccxml(FunctionType) castxml_test_gccxml(FundamentalType) castxml_test_gccxml(Method) castxml_test_gccxml(Namespace) diff --git a/test/expect/gccxml.FunctionType-xml.txt b/test/expect/gccxml.FunctionType-xml.txt new file mode 100644 index 0000000..9e05ce6 --- /dev/null +++ b/test/expect/gccxml.FunctionType-xml.txt @@ -0,0 +1,11 @@ +^<\?xml version="1.0"\?> +<GCC_XML[^>]*> + <Typedef id="_1" name="start" type="_2" context="_3" location="f1:1" file="f1" line="1"/> + <FunctionType id="_2" returns="_4"> + <Argument type="_5"/> + </FunctionType> + <FundamentalType id="_4" name="void"/> + <FundamentalType id="_5" name="int"/> + <Namespace id="_3" name="::"/> + <File id="f1" name=".*/test/input/FunctionType.cxx"/> +</GCC_XML>$ diff --git a/test/input/FunctionType.cxx b/test/input/FunctionType.cxx new file mode 100644 index 0000000..9b238a3 --- /dev/null +++ b/test/input/FunctionType.cxx @@ -0,0 +1 @@ +typedef void start(int); |