Skip to content

Commit 4067de6

Browse files
committed
protect typet::subtype() const
Protecting this method enables the use of type-specific accessor methods, which can exploit type invariants about the existence of the subtype.
1 parent e1fecd3 commit 4067de6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/util/type.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ class typet:public irept
4545
}
4646
#endif
4747

48+
// Deliberately protected -- use type-specific accessor methods instead.
49+
protected:
4850
const typet &subtype() const
4951
{
5052
if(get_sub().empty())
5153
return static_cast<const typet &>(get_nil_irep());
5254
return static_cast<const typet &>(get_sub().front());
5355
}
5456

57+
public:
58+
// This method will be protected eventually.
5559
typet &subtype()
5660
{
5761
subt &sub=get_sub();

0 commit comments

Comments
 (0)