diff options
author | Greg Clayton <gclayton@apple.com> | 2012-10-30 16:57:17 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-10-30 16:57:17 +0000 |
commit | 373670df5a60e2e968039ee5dab44c1845f3e4eb (patch) | |
tree | d3c2119287b8e6baa820f583c087158c86718eb0 | |
parent | 7bba3f14bff0082e08861616c1d4b97660c43f84 (diff) | |
download | bcm5719-llvm-373670df5a60e2e968039ee5dab44c1845f3e4eb.tar.gz bcm5719-llvm-373670df5a60e2e968039ee5dab44c1845f3e4eb.zip |
Added the ability to get function return and argument types to SBType():
bool
SBType::IsFunctionType ();
lldb::SBType
SBType::GetFunctionReturnType ();
lldb::SBTypeList
SBType::GetFunctionArgumentTypes ();
llvm-svn: 167023
-rw-r--r-- | lldb/include/lldb/API/SBType.h | 9 | ||||
-rw-r--r-- | lldb/scripts/Python/interface/SBType.i | 14 | ||||
-rw-r--r-- | lldb/source/API/SBType.cpp | 45 |
3 files changed, 67 insertions, 1 deletions
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 85dfcf46d70..14ee24da473 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -90,6 +90,9 @@ public: bool IsReferenceType(); + bool + IsFunctionType (); + lldb::SBType GetPointerType(); @@ -141,6 +144,12 @@ public: lldb::TemplateArgumentKind GetTemplateArgumentKind (uint32_t idx); + lldb::SBType + GetFunctionReturnType (); + + lldb::SBTypeList + GetFunctionArgumentTypes (); + const char* GetName(); diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i index 76fdfc923bd..82dff14fbd3 100644 --- a/lldb/scripts/Python/interface/SBType.i +++ b/lldb/scripts/Python/interface/SBType.i @@ -161,6 +161,9 @@ public: bool IsReferenceType(); + + bool + IsFunctionType (); lldb::SBType GetPointerType(); @@ -216,6 +219,12 @@ public: lldb::TemplateArgumentKind GetTemplateArgumentKind (uint32_t idx); + lldb::SBType + GetFunctionReturnType (); + + lldb::SBTypeList + GetFunctionArgumentTypes (); + bool IsTypeComplete (); @@ -240,7 +249,10 @@ public: __swig_getmethods__["is_reference"] = IsReferenceType if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') - + + __swig_getmethods__["is_function"] = IsFunctionType + if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') + __swig_getmethods__["num_fields"] = GetNumberOfFields if _newclass: num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 3e6d8f59c5d..7387ed3097d 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -219,6 +219,51 @@ SBType::GetDereferencedType() return SBType(ClangASTType(m_opaque_sp->GetASTContext(),qt.getNonReferenceType().getAsOpaquePtr())); } +bool +SBType::IsFunctionType () +{ + if (IsValid()) + { + QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType())); + const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); + return func != NULL; + } + return false; +} + +lldb::SBType +SBType::GetFunctionReturnType () +{ + if (IsValid()) + { + QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType())); + const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); + + if (func) + return SBType(ClangASTType(m_opaque_sp->GetASTContext(), + func->getResultType().getAsOpaquePtr())); + } + return lldb::SBType(); +} + +lldb::SBTypeList +SBType::GetFunctionArgumentTypes () +{ + SBTypeList sb_type_list; + if (IsValid()) + { + QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType())); + const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); + if (func) + { + const uint32_t num_args = func->getNumArgs(); + for (uint32_t i=0; i<num_args; ++i) + sb_type_list.Append (SBType(ClangASTType(m_opaque_sp->GetASTContext(), func->getArgType(i).getAsOpaquePtr()))); + } + } + return sb_type_list; +} + lldb::SBType SBType::GetUnqualifiedType() { |