Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9927057

Browse files
author
Greg Clayton
committedOct 30, 2012
Added the ability to get function return and argument types to SBType():
bool SBType::IsFunctionType (); lldb::SBType SBType::GetFunctionReturnType (); lldb::SBTypeList SBType::GetFunctionArgumentTypes (); git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@167023 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent aaf0088 commit 9927057

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed
 

‎include/lldb/API/SBType.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class SBType
9090
bool
9191
IsReferenceType();
9292

93+
bool
94+
IsFunctionType ();
95+
9396
lldb::SBType
9497
GetPointerType();
9598

@@ -141,6 +144,12 @@ class SBType
141144
lldb::TemplateArgumentKind
142145
GetTemplateArgumentKind (uint32_t idx);
143146

147+
lldb::SBType
148+
GetFunctionReturnType ();
149+
150+
lldb::SBTypeList
151+
GetFunctionArgumentTypes ();
152+
144153
const char*
145154
GetName();
146155

‎scripts/Python/interface/SBType.i

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ public:
161161

162162
bool
163163
IsReferenceType();
164+
165+
bool
166+
IsFunctionType ();
164167

165168
lldb::SBType
166169
GetPointerType();
@@ -216,6 +219,12 @@ public:
216219
lldb::TemplateArgumentKind
217220
GetTemplateArgumentKind (uint32_t idx);
218221

222+
lldb::SBType
223+
GetFunctionReturnType ();
224+
225+
lldb::SBTypeList
226+
GetFunctionArgumentTypes ();
227+
219228
bool
220229
IsTypeComplete ();
221230

@@ -240,7 +249,10 @@ public:
240249

241250
__swig_getmethods__["is_reference"] = IsReferenceType
242251
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.''')
243-
252+
253+
__swig_getmethods__["is_function"] = IsFunctionType
254+
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.''')
255+
244256
__swig_getmethods__["num_fields"] = GetNumberOfFields
245257
if _newclass: num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''')
246258

‎source/API/SBType.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,51 @@ SBType::GetDereferencedType()
219219
return SBType(ClangASTType(m_opaque_sp->GetASTContext(),qt.getNonReferenceType().getAsOpaquePtr()));
220220
}
221221

222+
bool
223+
SBType::IsFunctionType ()
224+
{
225+
if (IsValid())
226+
{
227+
QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
228+
const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
229+
return func != NULL;
230+
}
231+
return false;
232+
}
233+
234+
lldb::SBType
235+
SBType::GetFunctionReturnType ()
236+
{
237+
if (IsValid())
238+
{
239+
QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
240+
const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
241+
242+
if (func)
243+
return SBType(ClangASTType(m_opaque_sp->GetASTContext(),
244+
func->getResultType().getAsOpaquePtr()));
245+
}
246+
return lldb::SBType();
247+
}
248+
249+
lldb::SBTypeList
250+
SBType::GetFunctionArgumentTypes ()
251+
{
252+
SBTypeList sb_type_list;
253+
if (IsValid())
254+
{
255+
QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
256+
const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
257+
if (func)
258+
{
259+
const uint32_t num_args = func->getNumArgs();
260+
for (uint32_t i=0; i<num_args; ++i)
261+
sb_type_list.Append (SBType(ClangASTType(m_opaque_sp->GetASTContext(), func->getArgType(i).getAsOpaquePtr())));
262+
}
263+
}
264+
return sb_type_list;
265+
}
266+
222267
lldb::SBType
223268
SBType::GetUnqualifiedType()
224269
{

0 commit comments

Comments
 (0)
This repository has been archived.