Skip to content

Commit b936032

Browse files
author
Daniel Kroening
committed
C++: introduce template_parameter_symbol_type
The C++ front-end uses symbol_typet to represent template parameter types. It also uses the same irep to represent typedefs and struct/union tags. This commit disambiguates the meaning of this irep by introducing a separate type, called template_parameter_symbol_type.
1 parent b01bb42 commit b936032

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/cpp/cpp_template_parameter.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ struct template_parametert:public exprt
6262
};
6363

6464
/// a template parameter symbol that is a type
65-
struct template_parameter_symbol_typet:public typet
65+
struct template_parameter_symbol_typet : public typet
6666
{
6767
public:
68-
explicit template_parameter_symbol_typet(
69-
const irep_idt &identifier):typet(ID_template_parameter_symbol_type)
68+
explicit template_parameter_symbol_typet(const irep_idt &identifier)
69+
: typet(ID_template_parameter_symbol_type)
7070
{
7171
set_identifier(identifier);
7272
}
@@ -90,16 +90,18 @@ struct template_parameter_symbol_typet:public typet
9090
///
9191
/// \param type: Source type.
9292
/// \return Object of type \ref template_parameter_symbol_typet.
93-
inline const template_parameter_symbol_typet &to_template_parameter_symbol_type(const typet &type)
93+
inline const template_parameter_symbol_typet &
94+
to_template_parameter_symbol_type(const typet &type)
9495
{
95-
PRECONDITION(type.id()==ID_template_parameter_symbol_type);
96+
PRECONDITION(type.id() == ID_template_parameter_symbol_type);
9697
return static_cast<const template_parameter_symbol_typet &>(type);
9798
}
9899

99100
/// \copydoc to_template_parameter_symbol_type(const typet &)
100-
inline template_parameter_symbol_typet &to_template_parameter_symbol_type(typet &type)
101+
inline template_parameter_symbol_typet &
102+
to_template_parameter_symbol_type(typet &type)
101103
{
102-
PRECONDITION(type.id()==ID_template_parameter_symbol_type);
104+
PRECONDITION(type.id() == ID_template_parameter_symbol_type);
103105
return static_cast<template_parameter_symbol_typet &>(type);
104106
}
105107

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,9 +2271,9 @@ void cpp_typecheck_resolvet::filter_for_named_scopes(
22712271
if(e.id()!=ID_type)
22722272
continue; // expressions are definitively not a scope
22732273

2274-
if(e.type().id() == ID_symbol_type)
2274+
if(e.type().id() == ID_template_parameter_symbol_type)
22752275
{
2276-
symbol_typet type=to_symbol_type(e.type());
2276+
auto type = to_template_parameter_symbol_type(e.type());
22772277

22782278
while(true)
22792279
{
@@ -2282,8 +2282,8 @@ void cpp_typecheck_resolvet::filter_for_named_scopes(
22822282
const symbolt &symbol=cpp_typecheck.lookup(identifier);
22832283
assert(symbol.is_type);
22842284

2285-
if(symbol.type.id() == ID_symbol_type)
2286-
type=to_symbol_type(symbol.type);
2285+
if(symbol.type.id() == ID_template_parameter_symbol_type)
2286+
type = to_template_parameter_symbol_type(symbol.type);
22872287
else if(symbol.type.id()==ID_struct ||
22882288
symbol.type.id()==ID_union ||
22892289
symbol.type.id()==ID_c_enum)

0 commit comments

Comments
 (0)