Skip to content

Commit b18138c

Browse files
committed
Use parametert::get_this()
Use the method provided by the parametert API rather than the low-level approach of a fixed base name.
1 parent f278f3d commit b18138c

7 files changed

+11
-14
lines changed

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,13 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member(
576576
code_typet code1=to_code_type(expr.type().subtype());
577577
assert(!code1.parameters().empty());
578578
code_typet::parametert this1=code1.parameters()[0];
579-
INVARIANT(
580-
this1.get_base_name() == ID_this, "first parameter should be `this'");
579+
INVARIANT(this1.get_this(), "first parameter should be `this'");
581580
code1.parameters().erase(code1.parameters().begin());
582581

583582
code_typet code2=to_code_type(type.subtype());
584583
assert(!code2.parameters().empty());
585584
code_typet::parametert this2=code2.parameters()[0];
586-
INVARIANT(
587-
this2.get_base_name() == ID_this, "first parameter should be `this'");
585+
INVARIANT(this2.get_this(), "first parameter should be `this'");
588586
code2.parameters().erase(code2.parameters().begin());
589587

590588
if(this2.type().subtype().get_bool(ID_C_constant) &&

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
698698
code_typet &code_type=to_code_type(op.type().subtype());
699699

700700
code_typet::parameterst &args=code_type.parameters();
701-
if(!args.empty() && args[0].get_base_name() == ID_this)
701+
if(!args.empty() && args.front().get_this())
702702
{
703703
// it's a pointer to member function
704704
const struct_tag_typet symbol(code_type.get(ID_C_member_name));
@@ -2192,7 +2192,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
21922192
to_code_type(expr.function().type()).parameters();
21932193

21942194
if(
2195-
!parameters.empty() && parameters.front().get_base_name() == ID_this &&
2195+
!parameters.empty() && parameters.front().get_this() &&
21962196
!expr.arguments().empty())
21972197
{
21982198
const code_typet::parametert &parameter = parameters.front();

src/cpp/cpp_typecheck_fargs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bool cpp_typecheck_fargst::match(
9797

9898
// "this" is a special case -- we turn the pointer type
9999
// into a reference type to do the type matching
100-
if(it == ops.begin() && parameter.get_base_name() == ID_this)
100+
if(it == ops.begin() && parameter.get_this())
101101
{
102102
type.set(ID_C_reference, true);
103103
type.set(ID_C_this, true);

src/cpp/cpp_typecheck_function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ irep_idt cpp_typecheckt::function_identifier(const typet &type)
174174
code_typet::parameterst::const_iterator it=
175175
parameters.begin();
176176

177-
if(it != parameters.end() && it->get_base_name() == ID_this)
177+
if(it != parameters.end() && it->get_this())
178178
{
179179
const typet &pointer=it->type();
180180
const typet &symbol =pointer.subtype();

src/cpp/cpp_typecheck_initializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol)
9494
exprt new_object(ID_new_object, parameter.type());
9595
new_object.set(ID_C_lvalue, true);
9696

97-
if(parameter.get_base_name() == ID_this)
97+
if(parameter.get_this())
9898
{
9999
fargs.has_object = true;
100100
new_object.type() = parameter.type().subtype();

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ void cpp_typecheck_resolvet::apply_template_args(
20752075

20762076
if(
20772077
!code_type.parameters().empty() &&
2078-
code_type.parameters()[0].get_base_name() == ID_this)
2078+
code_type.parameters().front().get_this())
20792079
{
20802080
// do we have an object?
20812081
if(fargs.has_object)
@@ -2129,9 +2129,7 @@ bool cpp_typecheck_resolvet::disambiguate_functions(
21292129
const code_typet::parameterst &parameters=type.parameters();
21302130
const code_typet::parametert &parameter=parameters.front();
21312131

2132-
INVARIANT(
2133-
parameter.get_base_name() == ID_this,
2134-
"first parameter should be `this'");
2132+
INVARIANT(parameter.get_this(), "first parameter should be `this'");
21352133

21362134
if(type.return_type().id() == ID_constructor)
21372135
{

src/cpp/cpp_typecheck_type.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ void cpp_typecheckt::typecheck_type(typet &type)
106106
code_typet::parameterst &parameters =
107107
to_code_type(type.subtype()).parameters();
108108

109-
if(parameters.empty() || parameters.front().get_base_name() != ID_this)
109+
if(parameters.empty() || !parameters.front().get_this())
110110
{
111111
// Add 'this' to the parameters
112112
code_typet::parametert a0(pointer_type(class_object));
113113
a0.set_base_name(ID_this);
114+
a0.set_this();
114115
parameters.insert(parameters.begin(), a0);
115116
}
116117
}

0 commit comments

Comments
 (0)