Skip to content

Commit aa40d59

Browse files
committed
Properly set up scope prefix instead of hacking it away
1 parent 4c0915f commit aa40d59

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/cpp/cpp_instantiate_template.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,9 @@ const symbolt &cpp_typecheckt::class_template_symbol(
165165
INVARIANT_STRUCTURED(
166166
template_scope!=nullptr, nullptr_exceptiont, "template_scope is null");
167167

168-
irep_idt identifier=
169-
id2string(template_scope->prefix)+
170-
"tag-"+id2string(template_symbol.base_name)+
171-
id2string(suffix);
168+
irep_idt identifier = id2string(template_scope->get_parent().prefix) +
169+
"tag-" + id2string(template_symbol.base_name) +
170+
id2string(suffix);
172171

173172
// already there?
174173
symbol_tablet::symbolst::const_iterator s_it=
@@ -205,9 +204,8 @@ const symbolt &cpp_typecheckt::class_template_symbol(
205204

206205
id.id_class=cpp_idt::id_classt::CLASS;
207206
id.is_scope=true;
208-
id.prefix=template_scope->prefix+
209-
id2string(s_ptr->base_name)+
210-
id2string(suffix)+"::";
207+
id.prefix = template_scope->get_parent().prefix +
208+
id2string(s_ptr->base_name) + id2string(suffix) + "::";
211209
id.class_identifier=s_ptr->name;
212210
id.id_class=cpp_idt::id_classt::CLASS;
213211

src/cpp/cpp_typecheck_template.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,7 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters(
719719
std::string id_suffix="template::"+std::to_string(template_counter++);
720720

721721
// produce a new scope for the template parameters
722-
cpp_scopet &template_scope=
723-
cpp_scopes.current_scope().new_scope(
724-
cpp_scopes.current_scope().prefix+id_suffix);
725-
726-
template_scope.prefix=template_scope.get_parent().prefix+id_suffix;
722+
cpp_scopet &template_scope = cpp_scopes.current_scope().new_scope(id_suffix);
727723
template_scope.id_class=cpp_idt::id_classt::TEMPLATE_SCOPE;
728724

729725
cpp_scopes.go_to(template_scope);
@@ -826,9 +822,6 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters(
826822
#endif
827823
}
828824

829-
// continue without adding to the prefix
830-
template_scope.prefix=template_scope.get_parent().prefix;
831-
832825
return template_scope;
833826
}
834827

0 commit comments

Comments
 (0)