@@ -80,6 +80,13 @@ using FunctionDeclTy =
8080// /
8181class Function final {
8282public:
83+ enum class FunctionKind {
84+ Normal,
85+ Ctor,
86+ Dtor,
87+ LambdaStaticInvoker,
88+ LambdaCallOperator,
89+ };
8390 using ParamDescriptor = std::pair<PrimType, Descriptor *>;
8491
8592 // / Returns the size of the function's local stack.
@@ -141,43 +148,31 @@ class Function final {
141148 bool isConstexpr () const { return IsValid || isLambdaStaticInvoker (); }
142149
143150 // / Checks if the function is virtual.
144- bool isVirtual () const ;
151+ bool isVirtual () const { return Virtual; } ;
145152
146153 // / Checks if the function is a constructor.
147- bool isConstructor () const {
148- return isa_and_nonnull<CXXConstructorDecl>(
149- dyn_cast<const FunctionDecl *>(Source));
150- }
154+ bool isConstructor () const { return Kind == FunctionKind::Ctor; }
151155 // / Checks if the function is a destructor.
152- bool isDestructor () const {
153- return isa_and_nonnull<CXXDestructorDecl>(
154- dyn_cast<const FunctionDecl *>(Source));
155- }
156-
157- // / Returns the parent record decl, if any.
158- const CXXRecordDecl *getParentDecl () const {
159- if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
160- dyn_cast<const FunctionDecl *>(Source)))
161- return MD->getParent ();
162- return nullptr ;
163- }
156+ bool isDestructor () const { return Kind == FunctionKind::Dtor; }
164157
165158 // / Returns whether this function is a lambda static invoker,
166159 // / which we generate custom byte code for.
167160 bool isLambdaStaticInvoker () const {
168- if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
169- dyn_cast<const FunctionDecl *>(Source)))
170- return MD->isLambdaStaticInvoker ();
171- return false ;
161+ return Kind == FunctionKind::LambdaStaticInvoker;
172162 }
173163
174164 // / Returns whether this function is the call operator
175165 // / of a lambda record decl.
176166 bool isLambdaCallOperator () const {
167+ return Kind == FunctionKind::LambdaCallOperator;
168+ }
169+
170+ // / Returns the parent record decl, if any.
171+ const CXXRecordDecl *getParentDecl () const {
177172 if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
178173 dyn_cast<const FunctionDecl *>(Source)))
179- return clang::isLambdaCallOperator (MD );
180- return false ;
174+ return MD-> getParent ( );
175+ return nullptr ;
181176 }
182177
183178 // / Checks if the function is fully done compiling.
@@ -213,7 +208,7 @@ class Function final {
213208
214209 bool isThisPointerExplicit () const {
215210 if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
216- Source. dyn_cast <const FunctionDecl *>()))
211+ dyn_cast<const FunctionDecl *>(Source )))
217212 return MD->isExplicitObjectMemberFunction ();
218213 return false ;
219214 }
@@ -232,7 +227,7 @@ class Function final {
232227 llvm::SmallVectorImpl<PrimType> &&ParamTypes,
233228 llvm::DenseMap<unsigned , ParamDescriptor> &&Params,
234229 llvm::SmallVectorImpl<unsigned > &&ParamOffsets, bool HasThisPointer,
235- bool HasRVO, unsigned BuiltinID );
230+ bool HasRVO);
236231
237232 // / Sets the code of a function.
238233 void setCode (unsigned NewFrameSize, std::vector<std::byte> &&NewCode,
@@ -255,6 +250,8 @@ class Function final {
255250
256251 // / Program reference.
257252 Program &P;
253+ // / Function Kind.
254+ FunctionKind Kind;
258255 // / Declaration this function was compiled from.
259256 FunctionDeclTy Source;
260257 // / Local area size: storage + metadata.
@@ -289,6 +286,7 @@ class Function final {
289286 bool HasBody = false ;
290287 bool Defined = false ;
291288 bool Variadic = false ;
289+ bool Virtual = false ;
292290 unsigned BuiltinID = 0 ;
293291
294292public:
0 commit comments