Skip to content

Commit db44fce

Browse files
NathanJPhillipspeterschrammel
authored andcommitted
Add get_this utility function
This tries to find a this-parameter and returns false (success) if one was found.
1 parent 5150eca commit db44fce

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/util/std_types.h

+26
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,32 @@ class code_typet:public typet
810810
return !p.empty() && p.front().get_this();
811811
}
812812

813+
/*******************************************************************\
814+
Function: code_typet::get_this
815+
816+
Purpose:
817+
Get the this parameter for the current function type
818+
819+
Inputs:
820+
thisParameter: An output parameter to receive the parametert for
821+
the this parameter for the current function
822+
823+
Outputs:
824+
true if the current function type does not have a this parameter
825+
826+
\*******************************************************************/
827+
bool get_this(const parametert *&thisParameter) const
828+
{
829+
const parameterst &params=parameters();
830+
if(params.empty())
831+
return true; // No parameters to function
832+
const parametert &possible_fn_this=params.front();
833+
if(!possible_fn_this.get_this())
834+
return true; // No this parameter to function
835+
thisParameter=&possible_fn_this;
836+
return false;
837+
}
838+
813839
bool is_KnR() const
814840
{
815841
return get_bool(ID_C_KnR);

0 commit comments

Comments
 (0)