CPP code-gen: Mark child classes final, remove final from function defs

This commit is contained in:
Tim Wojtulewicz 2023-07-14 16:42:37 -07:00 committed by Tim Wojtulewicz
parent 0e40f7e6af
commit 73adf2bf01
2 changed files with 6 additions and 6 deletions

View file

@ -117,7 +117,7 @@ void CPPCompile::DeclareSubclass(const FuncTypePtr& ft, const ProfileFunc* pf, c
NL(); NL();
Emit("static %s %s(%s);", yt_decl, fname, ParamDecl(ft, lambda_ids, pf)); Emit("static %s %s(%s);", yt_decl, fname, ParamDecl(ft, lambda_ids, pf));
Emit("class %s_cl : public CPPStmt", fname); Emit("class %s_cl final : public CPPStmt", fname);
StartBlock(); StartBlock();
Emit("public:"); Emit("public:");
@ -151,7 +151,7 @@ void CPPCompile::DeclareSubclass(const FuncTypePtr& ft, const ProfileFunc* pf, c
if ( lambda_ids && lambda_ids->length() > 0 ) if ( lambda_ids && lambda_ids->length() > 0 )
Emit("%s_cl(const char* name) : CPPStmt(name, %s) { }", fname, loc_info); Emit("%s_cl(const char* name) : CPPStmt(name, %s) { }", fname, loc_info);
Emit("ValPtr Exec(Frame* f, StmtFlowType& flow) override final"); Emit("ValPtr Exec(Frame* f, StmtFlowType& flow) override");
StartBlock(); StartBlock();
Emit("flow = FLOW_RETURN;"); Emit("flow = FLOW_RETURN;");
@ -182,13 +182,13 @@ void CPPCompile::DeclareDynCPPStmt()
Emit("// dispatch. All of this is ugly, and only needed because clang"); Emit("// dispatch. All of this is ugly, and only needed because clang");
Emit("// goes nuts (super slow) in the face of thousands of templates"); Emit("// goes nuts (super slow) in the face of thousands of templates");
Emit("// in a given context (initializers, or a function body)."); Emit("// in a given context (initializers, or a function body).");
Emit("class CPPDynStmt : public CPPStmt"); Emit("class CPPDynStmt final : public CPPStmt");
Emit("\t{"); Emit("\t{");
Emit("public:"); Emit("public:");
Emit("\tCPPDynStmt(const char* _name, void* _func, int _type_signature, const char* filename, " Emit("\tCPPDynStmt(const char* _name, void* _func, int _type_signature, const char* filename, "
"int line_num) : CPPStmt(_name, filename, line_num), " "int line_num) : CPPStmt(_name, filename, line_num), "
"func(_func), type_signature(_type_signature) { }"); "func(_func), type_signature(_type_signature) { }");
Emit("\tValPtr Exec(Frame* f, StmtFlowType& flow) override final;"); Emit("\tValPtr Exec(Frame* f, StmtFlowType& flow) override;");
Emit("private:"); Emit("private:");
Emit("\t// The function to call in Exec()."); Emit("\t// The function to call in Exec().");
Emit("\tvoid* func;"); Emit("\tvoid* func;");

View file

@ -44,7 +44,7 @@ void CPPCompile::GenInitExpr(std::shared_ptr<CallExprInitInfo> ce_init)
// Create the Func subclass that can be used in a CallExpr to // Create the Func subclass that can be used in a CallExpr to
// evaluate 'e'. // evaluate 'e'.
Emit("class %s : public CPPFunc", wc); Emit("class %s final : public CPPFunc", wc);
StartBlock(); StartBlock();
Emit("public:"); Emit("public:");
@ -57,7 +57,7 @@ void CPPCompile::GenInitExpr(std::shared_ptr<CallExprInitInfo> ce_init)
EndBlock(); EndBlock();
Emit("ValPtr Invoke(zeek::Args* args, Frame* parent) const override final"); Emit("ValPtr Invoke(zeek::Args* args, Frame* parent) const override");
StartBlock(); StartBlock();
if ( IsNativeType(t) ) if ( IsNativeType(t) )