[Lldb-commits] [lldb] r167023 - in /lldb/trunk: include/lldb/API/SBType.h scripts/Python/interface/SBType.i source/API/SBType.cpp
Greg Clayton
gclayton at apple.com
Tue Oct 30 09:57:17 PDT 2012
Author: gclayton
Date: Tue Oct 30 11:57:17 2012
New Revision: 167023
URL: http://llvm.org/viewvc/llvm-project?rev=167023&view=rev
Log:
Added the ability to get function return and argument types to SBType():
bool
SBType::IsFunctionType ();
lldb::SBType
SBType::GetFunctionReturnType ();
lldb::SBTypeList
SBType::GetFunctionArgumentTypes ();
Modified:
lldb/trunk/include/lldb/API/SBType.h
lldb/trunk/scripts/Python/interface/SBType.i
lldb/trunk/source/API/SBType.cpp
Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=167023&r1=167022&r2=167023&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Tue Oct 30 11:57:17 2012
@@ -90,6 +90,9 @@
bool
IsReferenceType();
+ bool
+ IsFunctionType ();
+
lldb::SBType
GetPointerType();
@@ -141,6 +144,12 @@
lldb::TemplateArgumentKind
GetTemplateArgumentKind (uint32_t idx);
+ lldb::SBType
+ GetFunctionReturnType ();
+
+ lldb::SBTypeList
+ GetFunctionArgumentTypes ();
+
const char*
GetName();
Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=167023&r1=167022&r2=167023&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Tue Oct 30 11:57:17 2012
@@ -161,6 +161,9 @@
bool
IsReferenceType();
+
+ bool
+ IsFunctionType ();
lldb::SBType
GetPointerType();
@@ -216,6 +219,12 @@
lldb::TemplateArgumentKind
GetTemplateArgumentKind (uint32_t idx);
+ lldb::SBType
+ GetFunctionReturnType ();
+
+ lldb::SBTypeList
+ GetFunctionArgumentTypes ();
+
bool
IsTypeComplete ();
@@ -240,7 +249,10 @@
__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.''')
Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=167023&r1=167022&r2=167023&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Tue Oct 30 11:57:17 2012
@@ -219,6 +219,51 @@
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()
{
More information about the lldb-commits
mailing list