3131
3232bool CppConstructor::isCopyConstructor () const
3333{
34- if (isCopyConstructor_)
35- return * isCopyConstructor_;
34+ if (isCopyConstructor_ != TriStateBool::Unknown )
35+ return isCopyConstructor_ == TriStateBool::True ;
3636
37- isCopyConstructor_ = false ;
37+ isCopyConstructor_ = TriStateBool::False ;
3838 if (!params_ || (params_->size () != 1 ))
3939 return false ;
4040 const auto & param = params_->front ();
@@ -58,16 +58,17 @@ bool CppConstructor::isCopyConstructor() const
5858 {
5959 return false ;
6060 }
61- isCopyConstructor_ = true ;
62- return *isCopyConstructor_;
61+ isCopyConstructor_ = TriStateBool::True;
62+
63+ return true ;
6364}
6465
6566bool CppConstructor::isMoveConstructor () const
6667{
67- if (isMoveConstructor_)
68- return * isMoveConstructor_;
68+ if (isMoveConstructor_ != TriStateBool::Unknown )
69+ return isMoveConstructor_ == TriStateBool::True ;
6970
70- isMoveConstructor_ = false ;
71+ isMoveConstructor_ = TriStateBool::False ;
7172 if (!params_ || (params_->size () != 1 ))
7273 return false ;
7374 const auto & param = params_->front ();
@@ -93,46 +94,50 @@ bool CppConstructor::isMoveConstructor() const
9394 {
9495 return false ;
9596 }
96- isMoveConstructor_ = true ;
97- return *isMoveConstructor_;
97+ isMoveConstructor_ = TriStateBool::True;
98+
99+ return true ;
98100}
99101
100102bool CppCompound::hasPublicVirtualMethod () const
101103{
102104 if (!isClassLike (this ))
103105 return false ;
104- if (hasVirtual_)
105- return *hasVirtual_;
106- hasVirtual_ = false ;
106+ if (hasVirtual_ != TriStateBool::Unknown)
107+ return hasVirtual_ == TriStateBool::True;
108+
109+ hasVirtual_ = TriStateBool::False;
107110 forEachMember (this , [&](const CppObj* mem) {
108111 if (isFunction (mem) && isPublic (mem))
109112 {
110113 auto func = (CppFunction*) mem;
111114 if (func->attr () & (kVirtual | kOverride ))
112115 {
113- hasVirtual_ = true ;
116+ hasVirtual_ = TriStateBool::True ;
114117 return true ;
115118 }
116119 }
117120 return false ;
118121 });
119- return *hasVirtual_;
122+
123+ return hasVirtual_ == TriStateBool::True;
120124}
121125
122126bool CppCompound::hasPureVirtual () const
123127{
124128 if (!isClassLike (this ))
125129 return false ;
126- if (hasPureVirtual_)
127- return *hasPureVirtual_;
128- hasPureVirtual_ = false ;
130+ if (hasPureVirtual_ != TriStateBool::Unknown)
131+ return hasPureVirtual_ == TriStateBool::True;
132+
133+ hasPureVirtual_ = TriStateBool::False;
129134 forEachMember (this , [&](const CppObj* mem) {
130135 if (isFunction (mem))
131136 {
132137 auto func = static_cast <const CppFunction*>(mem);
133138 if (isPureVirtual (func))
134139 {
135- hasPureVirtual_ = true ;
140+ hasPureVirtual_ = TriStateBool::True ;
136141 return true ;
137142 }
138143 }
@@ -141,14 +146,15 @@ bool CppCompound::hasPureVirtual() const
141146 auto dtor = static_cast <const CppDestructor*>(mem);
142147 if (isPureVirtual (dtor))
143148 {
144- hasPureVirtual_ = true ;
149+ hasPureVirtual_ = TriStateBool::True ;
145150 return true ;
146151 }
147152 }
148153
149154 return false ;
150155 });
151- return *hasPureVirtual_;
156+
157+ return hasPureVirtual_ == TriStateBool::True;
152158}
153159
154160bool CppCompound::triviallyConstructable () const
0 commit comments