summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-14 17:36:39 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-14 17:37:53 (GMT)
commit68009c611d9fbf5ad8391e12e4d40c5716aee43e (patch)
tree3f8e1f58046e8d3fc948d393479d4c6ea89be1ea /src
parent2bba2e9e8900666ca92a7abb848ee8e5756462d8 (diff)
downloadCastXML-68009c611d9fbf5ad8391e12e4d40c5716aee43e.zip
CastXML-68009c611d9fbf5ad8391e12e4d40c5716aee43e.tar.gz
CastXML-68009c611d9fbf5ad8391e12e4d40c5716aee43e.tar.bz2
Output: Add function calling convention attributes
Add to Function-like and FunctionType elements an attributes="" attribute for the calling convention as gccxml does.
Diffstat (limited to 'src')
-rw-r--r--src/Output.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Output.cxx b/src/Output.cxx
index 132345d..3b7065d 100644
--- a/src/Output.cxx
+++ b/src/Output.cxx
@@ -25,6 +25,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/Basic/Specifiers.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/Support/raw_ostream.h"
@@ -256,6 +257,10 @@ class ASTVisitor: public ASTVisitorBase
for later output. */
void PrintBasesAttribute(clang::CXXRecordDecl const* dx);
+ /** Print an attributes="..." attribute listing the attributes
+ of the given function type. */
+ void PrintFunctionTypeAttributes(clang::FunctionProtoType const* t);
+
/** Print a throws="..." attribute listing the XML IDREFs for
the types that the given function prototype declares in
the throw() specification. */
@@ -466,6 +471,9 @@ unsigned int ASTVisitor::AddDumpNode(DumpType dt, bool complete) {
case clang::Type::Adjusted:
return this->AddDumpNode(DumpType(
t->getAs<clang::AdjustedType>()->getAdjustedType(), c), complete);
+ case clang::Type::Attributed:
+ return this->AddDumpNode(DumpType(
+ t->getAs<clang::AttributedType>()->getEquivalentType(), c), complete);
case clang::Type::Decayed:
return this->AddDumpNode(DumpType(
t->getAs<clang::DecayedType>()->getDecayedType(), c), complete);
@@ -993,6 +1001,26 @@ void ASTVisitor::PrintBasesAttribute(clang::CXXRecordDecl const* dx)
}
//----------------------------------------------------------------------------
+void ASTVisitor::PrintFunctionTypeAttributes(clang::FunctionProtoType const* t)
+{
+ switch (t->getExtInfo().getCC()) {
+ case clang::CallingConv::CC_C:
+ break;
+ case clang::CallingConv::CC_X86StdCall:
+ this->OS << " attributes=\"__stdcall__\"";
+ break;
+ case clang::CallingConv::CC_X86FastCall:
+ this->OS << " attributes=\"__fastcall__\"";
+ break;
+ case clang::CallingConv::CC_X86ThisCall:
+ this->OS << " attributes=\"__thiscall__\"";
+ break;
+ default:
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
void ASTVisitor::PrintThrowsAttribute(clang::FunctionProtoType const* fpt,
bool complete)
{
@@ -1083,6 +1111,7 @@ void ASTVisitor::OutputFunctionHelper(clang::FunctionDecl const* d,
}
clang::QualType ft = d->getType();
+ this->PrintFunctionTypeAttributes(ft->getAs<clang::FunctionProtoType>());
this->PrintThrowsAttribute(
ft->getAs<clang::FunctionProtoType>(), dn->Complete);
@@ -1130,6 +1159,7 @@ void ASTVisitor::OutputFunctionTypeHelper(clang::FunctionProtoType const* t,
if(t->isRestrict()) {
this->OS << " restrict=\"1\"";
}
+ this->PrintFunctionTypeAttributes(t);
if(t->param_type_begin() != t->param_type_end()) {
this->OS << ">\n";
for (clang::FunctionProtoType::param_type_iterator