Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'final' liberally #1260

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions src/liboslcomp/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class ASTNode : public OIIO::RefCnt {



class ASTshader_declaration : public ASTNode {
class ASTshader_declaration final : public ASTNode {
public:
ASTshader_declaration(OSLCompilerImpl* comp, int stype, ustring name,
ASTNode* form, ASTNode* stmts, ASTNode* meta);
Expand All @@ -444,7 +444,7 @@ class ASTshader_declaration : public ASTNode {



class ASTfunction_declaration : public ASTNode {
class ASTfunction_declaration final : public ASTNode {
public:
ASTfunction_declaration(OSLCompilerImpl* comp, TypeSpec type, ustring name,
ASTNode* form, ASTNode* stmts, ASTNode* meta,
Expand Down Expand Up @@ -474,7 +474,7 @@ class ASTfunction_declaration : public ASTNode {



class ASTvariable_declaration : public ASTNode {
class ASTvariable_declaration final : public ASTNode {
public:
ASTvariable_declaration(OSLCompilerImpl* comp, const TypeSpec& type,
ustring name, ASTNode* init, bool isparam,
Expand Down Expand Up @@ -531,7 +531,7 @@ class ASTvariable_declaration : public ASTNode {



class ASTvariable_ref : public ASTNode {
class ASTvariable_ref final : public ASTNode {
public:
ASTvariable_ref(OSLCompilerImpl* comp, ustring name);
const char* nodetypename() const { return "variable_ref"; }
Expand All @@ -550,7 +550,7 @@ class ASTvariable_ref : public ASTNode {



class ASTpreincdec : public ASTNode {
class ASTpreincdec final : public ASTNode {
public:
ASTpreincdec(OSLCompilerImpl* comp, int op, ASTNode* expr);
const char* nodetypename() const
Expand All @@ -566,7 +566,7 @@ class ASTpreincdec : public ASTNode {



class ASTpostincdec : public ASTNode {
class ASTpostincdec final : public ASTNode {
public:
ASTpostincdec(OSLCompilerImpl* comp, int op, ASTNode* expr);
const char* nodetypename() const
Expand All @@ -582,7 +582,7 @@ class ASTpostincdec : public ASTNode {



class ASTindex : public ASTNode {
class ASTindex final : public ASTNode {
public:
// ASTindex (OSLCompilerImpl *comp, ASTNode *expr, ASTNode *index);
// ASTindex (OSLCompilerImpl *comp, ASTNode *expr, ASTNode *index, ASTNode *index2);
Expand Down Expand Up @@ -617,7 +617,7 @@ class ASTindex : public ASTNode {



class ASTstructselect : public ASTNode {
class ASTstructselect final : public ASTNode {
public:
ASTstructselect(OSLCompilerImpl* comp, ASTNode* expr, ustring field);
const char* nodetypename() const { return "structselect"; }
Expand Down Expand Up @@ -653,7 +653,7 @@ class ASTstructselect : public ASTNode {



class ASTconditional_statement : public ASTNode {
class ASTconditional_statement final : public ASTNode {
public:
ASTconditional_statement(OSLCompilerImpl* comp, ASTNode* cond,
ASTNode* truestmt, ASTNode* falsestmt = NULL)
Expand All @@ -674,7 +674,7 @@ class ASTconditional_statement : public ASTNode {



class ASTloop_statement : public ASTNode {
class ASTloop_statement final : public ASTNode {
public:
enum LoopType { LoopWhile, LoopDo, LoopFor };

Expand All @@ -695,7 +695,7 @@ class ASTloop_statement : public ASTNode {



class ASTloopmod_statement : public ASTNode {
class ASTloopmod_statement final : public ASTNode {
public:
enum LoopModType { LoopModBreak, LoopModContinue };

Expand All @@ -713,7 +713,7 @@ class ASTloopmod_statement : public ASTNode {



class ASTreturn_statement : public ASTNode {
class ASTreturn_statement final : public ASTNode {
public:
ASTreturn_statement(OSLCompilerImpl* comp, ASTNode* expr)
: ASTNode(return_statement_node, comp, 0, expr)
Expand Down Expand Up @@ -763,7 +763,8 @@ class ASTtype_constructor : public ASTNode {
};


class ASTcompound_initializer : public ASTtype_constructor {

class ASTcompound_initializer final : public ASTtype_constructor {
bool m_ctor;

TypeSpec typecheck(TypeSpec expected, unsigned mode);
Expand All @@ -787,7 +788,7 @@ class ASTcompound_initializer : public ASTtype_constructor {



class ASTassign_expression : public ASTNode {
class ASTassign_expression final : public ASTNode {
public:
ASTassign_expression(OSLCompilerImpl* comp, ASTNode* var, Operator op,
ASTNode* expr);
Expand All @@ -804,7 +805,7 @@ class ASTassign_expression : public ASTNode {



class ASTunary_expression : public ASTNode {
class ASTunary_expression final : public ASTNode {
public:
ASTunary_expression(OSLCompilerImpl* comp, int op, ASTNode* expr);

Expand All @@ -823,7 +824,7 @@ class ASTunary_expression : public ASTNode {



class ASTbinary_expression : public ASTNode {
class ASTbinary_expression final : public ASTNode {
public:
ASTbinary_expression(OSLCompilerImpl* comp, Operator op, ASTNode* left,
ASTNode* right);
Expand All @@ -847,7 +848,7 @@ class ASTbinary_expression : public ASTNode {



class ASTternary_expression : public ASTNode {
class ASTternary_expression final : public ASTNode {
public:
ASTternary_expression(OSLCompilerImpl* comp, ASTNode* cond,
ASTNode* trueexpr, ASTNode* falseexpr)
Expand All @@ -867,7 +868,7 @@ class ASTternary_expression : public ASTNode {



class ASTcomma_operator : public ASTNode {
class ASTcomma_operator final : public ASTNode {
public:
ASTcomma_operator(OSLCompilerImpl* comp, ASTNode* exprlist)
: ASTNode(comma_operator_node, comp, Nothing, exprlist)
Expand All @@ -884,7 +885,7 @@ class ASTcomma_operator : public ASTNode {



class ASTtypecast_expression : public ASTNode {
class ASTtypecast_expression final : public ASTNode {
public:
ASTtypecast_expression(OSLCompilerImpl* comp, TypeSpec typespec,
ASTNode* expr)
Expand All @@ -903,7 +904,7 @@ class ASTtypecast_expression : public ASTNode {



class ASTfunction_call : public ASTNode {
class ASTfunction_call final : public ASTNode {
public:
ASTfunction_call(OSLCompilerImpl* comp, ustring name, ASTNode* args,
FunctionSymbol* funcsym = nullptr);
Expand Down Expand Up @@ -1019,7 +1020,7 @@ class ASTfunction_call : public ASTNode {



class ASTliteral : public ASTNode {
class ASTliteral final : public ASTNode {
public:
ASTliteral(OSLCompilerImpl* comp, int i)
: ASTNode(literal_node, comp), m_i(i)
Expand Down
4 changes: 2 additions & 2 deletions src/liboslcomp/symtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef std::vector<std::shared_ptr<StructSpec>> StructList;
/// Subclass of Symbol used just for functions, which are different
/// because they can be polymorphic, and also need to carry around more
/// information than other symbols.
class FunctionSymbol : public Symbol {
class FunctionSymbol final : public Symbol {
public:
FunctionSymbol(ustring n, TypeSpec type, ASTNode* node = NULL)
: Symbol(n, type, SymTypeFunction, node)
Expand Down Expand Up @@ -112,7 +112,7 @@ class FunctionSymbol : public Symbol {
/// general case (like arrays), it allocates memory and uses the
/// parent class's fields m_data and m_data_free, which will also cause
/// the parent class to properly free it upon destruction.
class ConstantSymbol : public Symbol {
class ConstantSymbol final : public Symbol {
public:
ConstantSymbol(ustring n, ustring val)
: Symbol(n, TypeDesc::TypeString, SymTypeConst)
Expand Down
2 changes: 1 addition & 1 deletion src/liboslexec/accum_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct

// This is a fake AOV implementation. It will just keep track
// of what test cases wrote to it
class MyAov : public Aov
class MyAov final : public Aov
{
public:
MyAov(const TestPath *test, int id)
Expand Down
2 changes: 1 addition & 1 deletion src/liboslexec/backendllvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace pvt { // OSL::pvt

/// OSOProcessor that generates LLVM IR and JITs it to give machine
/// code to implement a shader group.
class BackendLLVM : public OSOProcessorBase {
class BackendLLVM final : public OSOProcessorBase {
public:
BackendLLVM (ShadingSystemImpl &shadingsys, ShaderGroup &group,
ShadingContext *context);
Expand Down
4 changes: 2 additions & 2 deletions src/liboslexec/llvm_passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace {
// Also if future LLVM version takes on the work of this optimization pass,
// then it may be removed.
template <int WidthT>
class PreventBitMasksFromBeingLiveinsToBasicBlocks
class PreventBitMasksFromBeingLiveinsToBasicBlocks final
: public llvm::FunctionPass
{
typedef llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter> IRBuilder;
Expand Down Expand Up @@ -307,7 +307,7 @@ class PreventBitMasksFromBeingLiveinsToBasicBlocks


template <int WidthT>
class PrePromoteLogicalOpsOnBitMasks
class PrePromoteLogicalOpsOnBitMasks final
: public llvm::FunctionPass
{
typedef llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter> IRBuilder;
Expand Down
4 changes: 2 additions & 2 deletions src/liboslexec/llvm_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ LLVM_Util::total_jit_memory_held ()
/// MemoryManager - Create a shell that passes on requests
/// to a real LLVMMemoryManager underneath, but can be retained after the
/// dummy is destroyed. Also, we don't pass along any deallocations.
class LLVM_Util::MemoryManager : public LLVMMemoryManager {
class LLVM_Util::MemoryManager final : public LLVMMemoryManager {
protected:
LLVMMemoryManager *mm; // the real one
public:
Expand Down Expand Up @@ -290,7 +290,7 @@ class LLVM_Util::MemoryManager : public LLVMMemoryManager {



class LLVM_Util::IRBuilder : public llvm::IRBuilder<llvm::ConstantFolder,
class LLVM_Util::IRBuilder final : public llvm::IRBuilder<llvm::ConstantFolder,
llvm::IRBuilderDefaultInserter> {
typedef llvm::IRBuilder<llvm::ConstantFolder,
llvm::IRBuilderDefaultInserter> Base;
Expand Down
2 changes: 1 addition & 1 deletion src/liboslexec/loadshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace pvt { // OSL::pvt

/// Custom subclass of OSOReader that provide callbacks that set all the
/// right fields in the ShaderMaster.
class OSOReaderToMaster : public OSOReader
class OSOReaderToMaster final : public OSOReader
{
public:
OSOReaderToMaster (ShadingSystemImpl &shadingsys)
Expand Down
12 changes: 6 additions & 6 deletions src/liboslexec/lpexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class LPexp {


/// LPexp concatenation
class Cat : public LPexp {
class Cat final : public LPexp {
public:
virtual ~Cat();
void append(LPexp *regexp);
Expand All @@ -80,7 +80,7 @@ class Cat : public LPexp {


/// Basic symbol like G or 'customlabel'
class Symbol : public LPexp {
class Symbol final : public LPexp {
public:
Symbol(ustring sym) { m_sym = sym; };
virtual ~Symbol() {};
Expand All @@ -99,7 +99,7 @@ class Symbol : public LPexp {
/// Wildcard regexp
///
/// Named like this to avoid confusion with the automata Wildcard class
class Wildexp : public LPexp {
class Wildexp final : public LPexp {
public:
Wildexp(SymbolSet &minus):m_wildcard(minus) {};
virtual ~Wildexp() {};
Expand All @@ -116,7 +116,7 @@ class Wildexp : public LPexp {


/// Ored list of expressions
class Orlist : public LPexp {
class Orlist final : public LPexp {
public:
virtual ~Orlist();
void append(LPexp *regexp);
Expand All @@ -131,7 +131,7 @@ class Orlist : public LPexp {


// Unlimited repeat: (exp)*
class Repeat : public LPexp {
class Repeat final : public LPexp {
public:
Repeat(LPexp *child):m_child(child) {};
virtual ~Repeat() { delete m_child; };
Expand All @@ -146,7 +146,7 @@ class Repeat : public LPexp {


// Bounded repeat: (exp){m,n}
class NRepeat : public LPexp {
class NRepeat final : public LPexp {
public:
NRepeat(LPexp *child, int min, int max):m_child(child),m_min(min),m_max(max) {};
virtual ~NRepeat() { delete m_child; };
Expand Down
2 changes: 1 addition & 1 deletion src/liboslexec/oslexec_pvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ inline off_t vectorbytes (const std::vector<T> &v)
/// shader that would be a .oso file on disk: symbols, instructions,
/// arguments, you name it. A master copy is shared by all the
/// individual instances of the shader.
class ShaderMaster : public RefCnt {
class ShaderMaster final : public RefCnt {
public:
typedef OIIO::intrusive_ptr<ShaderMaster> ref;
ShaderMaster (ShadingSystemImpl &shadingsys);
Expand Down
2 changes: 1 addition & 1 deletion src/liboslexec/runtimeoptimize.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef std::set<int> FastIntSet;


/// OSOProcessor that does runtime optimization on shaders.
class RuntimeOptimizer : public OSOProcessorBase {
class RuntimeOptimizer final : public OSOProcessorBase {
public:
RuntimeOptimizer (ShadingSystemImpl &shadingsys, ShaderGroup &group,
ShadingContext *context);
Expand Down
2 changes: 1 addition & 1 deletion src/liboslquery/oslquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace pvt {

// Custom subclass of OSOReader that just reads the .oso file and fills
// out the right fields in the OSLQuery.
class OSOReaderQuery : public OSOReader {
class OSOReaderQuery final : public OSOReader {
public:
OSOReaderQuery(OSLQuery& query)
: m_query(query), m_reading_param(false), m_default_values(0)
Expand Down
6 changes: 3 additions & 3 deletions src/osl.imageio/oslinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ OSL_NAMESPACE_ENTER
///


class OSLInput : public ImageInput {
class OSLInput final : public ImageInput {
public:
OSLInput();
virtual ~OSLInput();
Expand Down Expand Up @@ -137,7 +137,7 @@ OIIO_PLUGIN_EXPORTS_END
namespace pvt {


class OIIO_RendererServices : public RendererServices {
class OIIO_RendererServices final : public RendererServices {
public:
OIIO_RendererServices(TextureSystem* texsys = NULL)
: RendererServices(texsys)
Expand Down Expand Up @@ -192,7 +192,7 @@ class OIIO_RendererServices : public RendererServices {



class ErrorRecorder : public OIIO::ErrorHandler {
class ErrorRecorder final : public OIIO::ErrorHandler {
public:
ErrorRecorder() : ErrorHandler() {}
virtual void operator()(int errcode, const std::string& msg)
Expand Down
2 changes: 1 addition & 1 deletion src/oslc/oslcmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace { // anonymous
// Subclass ErrorHandler because we want our messages to appear somewhat
// differant than the default ErrorHandler base class, in order to match
// typical compiler command line messages.
class OSLC_ErrorHandler : public ErrorHandler {
class OSLC_ErrorHandler final : public ErrorHandler {
public:
virtual void operator()(int errcode, const std::string& msg)
{
Expand Down
Loading