Skip to content

Commit

Permalink
Use final instead of override where possible.
Browse files Browse the repository at this point in the history
This serves as documentation for humans but also provides
hints for devirtualization for comilers.
  • Loading branch information
hzeller committed Nov 9, 2024
1 parent b4fbd15 commit b863057
Show file tree
Hide file tree
Showing 30 changed files with 172 additions and 172 deletions.
116 changes: 58 additions & 58 deletions include/Surelog/Common/PlatformFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SymbolTable;
* Native platform specific file system implementation.
*
*/
class PlatformFileSystem : public FileSystem {
class PlatformFileSystem final : public FileSystem {
public:
struct Configuration final {
std::filesystem::path m_sourceDir;
Expand All @@ -55,131 +55,131 @@ class PlatformFileSystem : public FileSystem {
typedef std::vector<Mapping> Mappings;

public:
PathId toPathId(std::string_view path, SymbolTable *symbolTable) override;
std::filesystem::path toPlatformAbsPath(PathId id) override;
std::filesystem::path toPlatformRelPath(PathId id) override;
PathId toPathId(std::string_view path, SymbolTable *symbolTable) final;
std::filesystem::path toPlatformAbsPath(PathId id) final;
std::filesystem::path toPlatformRelPath(PathId id) final;

std::pair<std::filesystem::path, std::filesystem::path> toSplitPlatformPath(
PathId id) override;
PathId id) final;

std::string getWorkingDir() override;
std::set<std::string> getWorkingDirs() override;
std::string getWorkingDir() final;
std::set<std::string> getWorkingDirs() final;

using FileSystem::openInput;
std::istream &openInput(PathId fileId, std::ios_base::openmode mode) override;
bool close(std::istream &strm) override;
std::istream &openInput(PathId fileId, std::ios_base::openmode mode) final;
bool close(std::istream &strm) final;

using FileSystem::openOutput;
std::ostream &openOutput(PathId fileId,
std::ios_base::openmode mode) override;
bool close(std::ostream &strm) override;
std::ios_base::openmode mode) final;
bool close(std::ostream &strm) final;

using FileSystem::saveContent;
bool saveContent(PathId fileId, const char *content, std::streamsize length,
bool useTemp) override;
bool useTemp) final;

bool addMapping(std::string_view what, std::string_view with) override;
std::string remap(std::string_view what) override;
bool addMapping(std::string_view what, std::string_view with) final;
std::string remap(std::string_view what) final;

bool addWorkingDirectoryCacheEntry(std::string_view prefix,
std::string_view suffix) override;
std::string_view suffix) final;

PathId getProgramFile(std::string_view hint,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathId getWorkingDir(std::string_view dir, SymbolTable *symbolTable) override;
PathId getOutputDir(std::string_view dir, SymbolTable *symbolTable) override;
PathId getPrecompiledDir(PathId programId, SymbolTable *symbolTable) override;
PathId getWorkingDir(std::string_view dir, SymbolTable *symbolTable) final;
PathId getOutputDir(std::string_view dir, SymbolTable *symbolTable) final;
PathId getPrecompiledDir(PathId programId, SymbolTable *symbolTable) final;

using FileSystem::getLogFile;
PathId getLogFile(bool isUnitCompilation, std::string_view filename,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathId getCacheDir(bool isUnitCompilation, std::string_view dirname,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathId getCompileDir(bool isUnitCompilation,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

using FileSystem::getPpOutputFile;
PathId getPpOutputFile(bool isUnitCompilation, PathId sourceFileId,
std::string_view libraryName,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

using FileSystem::getPpCacheFile;
PathId getPpCacheFile(bool isUnitCompilation, PathId sourceFileId,
std::string_view libraryName, bool isPrecompiled,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

using FileSystem::getParseCacheFile;
PathId getParseCacheFile(bool isUnitCompilation, PathId ppFileId,
std::string_view libraryName, bool isPrecompiled,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

using FileSystem::getPythonCacheFile;
PathId getPythonCacheFile(bool isUnitCompilation, PathId sourceFileId,
std::string_view libraryName,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathId getPpMultiprocessingDir(bool isUnitCompilation,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;
PathId getParserMultiprocessingDir(bool isUnitCompilation,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathId getChunkFile(PathId ppFileId, int32_t chunkIndex,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathId getCheckerDir(bool isUnitCompilation,
SymbolTable *symbolTable) override;
PathId getCheckerFile(PathId uhdmFileId, SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;
PathId getCheckerFile(PathId uhdmFileId, SymbolTable *symbolTable) final;
PathId getCheckerHtmlFile(PathId uhdmFileId,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;
PathId getCheckerHtmlFile(PathId uhdmFileId, int32_t index,
SymbolTable *symbolTable) override;

bool rename(PathId whatId, PathId toId) override;
bool remove(PathId fileId) override;
bool mkdir(PathId dirId) override;
bool rmdir(PathId dirId) override;
bool mkdirs(PathId dirId) override;
bool rmtree(PathId dirId) override;
bool exists(PathId id) override;
bool exists(PathId dirId, std::string_view descendant) override;
bool isDirectory(PathId id) override;
bool isRegularFile(PathId id) override;
bool filesize(PathId fileId, std::streamsize *result) override;
SymbolTable *symbolTable) final;

bool rename(PathId whatId, PathId toId) final;
bool remove(PathId fileId) final;
bool mkdir(PathId dirId) final;
bool rmdir(PathId dirId) final;
bool mkdirs(PathId dirId) final;
bool rmtree(PathId dirId) final;
bool exists(PathId id) final;
bool exists(PathId dirId, std::string_view descendant) final;
bool isDirectory(PathId id) final;
bool isRegularFile(PathId id) final;
bool filesize(PathId fileId, std::streamsize *result) final;
std::filesystem::file_time_type modtime(
PathId fileId, std::filesystem::file_time_type defaultOnFail) override;
PathId fileId, std::filesystem::file_time_type defaultOnFail) final;

PathId locate(std::string_view name, const PathIdVector &directories,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;

PathIdVector &collect(PathId dirId, SymbolTable *symbolTable,
PathIdVector &container) override;
PathIdVector &container) final;
PathIdVector &collect(PathId dirId, std::string_view extension,
SymbolTable *symbolTable,
PathIdVector &container) override;
PathIdVector &container) final;
PathIdVector &matching(PathId dirId, std::string_view pattern,
SymbolTable *symbolTable,
PathIdVector &container) override;
PathIdVector &container) final;
PathIdVector &matching(PathId dirId, const std::regex &pattern,
SymbolTable *symbolTable,
PathIdVector &container) override;
PathIdVector &container) final;

PathId getChild(PathId id, std::string_view name,
SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;
PathId getSibling(PathId id, std::string_view name,
SymbolTable *symbolTable) override;
PathId getParent(PathId id, SymbolTable *symbolTable) override;
SymbolTable *symbolTable) final;
PathId getParent(PathId id, SymbolTable *symbolTable) final;
std::pair<SymbolId, std::string_view> getLeaf(
PathId id, SymbolTable *symbolTable) override;
PathId id, SymbolTable *symbolTable) final;
std::pair<SymbolId, std::string_view> getType(
PathId id, SymbolTable *symbolTable) override;
PathId id, SymbolTable *symbolTable) final;

void printConfiguration(std::ostream &out) override;
void printConfiguration(std::ostream &out) final;

explicit PlatformFileSystem(const std::filesystem::path &workingDir);
~PlatformFileSystem() override;
~PlatformFileSystem() final;

protected:
// Internal helpers
Expand Down
4 changes: 2 additions & 2 deletions include/Surelog/Design/DummyType.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace SURELOG {

class FileContent;

class DummyType : public DataType {
class DummyType final : public DataType {
SURELOG_IMPLEMENT_RTTI(DummyType, DataType)
public:
DummyType(const FileContent* fC, NodeId nameId, NodeId structId);
~DummyType() override;
~DummyType() final;

NodeId getNameId() const { return m_nameId; }

Expand Down
4 changes: 2 additions & 2 deletions include/Surelog/Design/Enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ namespace SURELOG {
class FileContent;
class Value;

class Enum : public DataType {
class Enum final : public DataType {
SURELOG_IMPLEMENT_RTTI(Enum, DataType)
public:
Enum(const FileContent* fC, NodeId nameId, NodeId baseTypeId);
~Enum() override = default;
~Enum() final = default;

typedef std::map<std::string, std::pair<uint32_t, Value*>, std::less<>>
NameValueMap;
Expand Down
12 changes: 6 additions & 6 deletions include/Surelog/Design/FileContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class ModuleDefinition;
class Package;
class Program;

class FileContent : public DesignComponent {
class FileContent final : public DesignComponent {
SURELOG_IMPLEMENT_RTTI(FileContent, DesignComponent)
public:
FileContent(PathId fileId, Library* library, SymbolTable* symbolTable,
ErrorContainer* errors, FileContent* parent, PathId fileChunkId);
~FileContent() override;
~FileContent() final;

void setLibrary(Library* lib) { m_library = lib; }

Expand Down Expand Up @@ -94,12 +94,12 @@ class FileContent : public DesignComponent {
bool first = false) const;
// Recursively search for all items of types
// and stops at types stopPoints
uint32_t getSize() const override {
uint32_t getSize() const final {
return static_cast<uint32_t>(m_objects.size());
}
VObjectType getType() const override { return VObjectType::slNoType; }
bool isInstance() const override { return false; }
std::string_view getName() const override;
VObjectType getType() const final { return VObjectType::slNoType; }
bool isInstance() const final { return false; }
std::string_view getName() const final;
NodeId getRootNode() const;
std::string printObjects() const; // The whole file content
std::string printSubTree(
Expand Down
12 changes: 6 additions & 6 deletions include/Surelog/Design/ModuleDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ namespace SURELOG {
class CompileModule;
class FileContent;

class ModuleDefinition : public DesignComponent, public ClockingBlockHolder {
class ModuleDefinition final : public DesignComponent, public ClockingBlockHolder {
SURELOG_IMPLEMENT_RTTI(ModuleDefinition, DesignComponent)
friend CompileModule;

public:
ModuleDefinition(const FileContent* fileContent, NodeId nodeId,
std::string_view name);

~ModuleDefinition() override = default;
~ModuleDefinition() final = default;

std::string_view getName() const override { return m_name; }
VObjectType getType() const override;
bool isInstance() const override;
uint32_t getSize() const override;
std::string_view getName() const final { return m_name; }
VObjectType getType() const final;
bool isInstance() const final;
uint32_t getSize() const final;

typedef std::map<std::string, ClockingBlock> ClockingBlockMap;
typedef std::map<std::string, ModPort, std::less<>> ModPortSignalMap;
Expand Down
8 changes: 4 additions & 4 deletions include/Surelog/Design/ModuleInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class Parameter;
class PathId;
class SymbolTable;

class ModuleInstance : public ValuedComponentI {
class ModuleInstance final : public ValuedComponentI {
SURELOG_IMPLEMENT_RTTI(ModuleInstance, ValuedComponentI)
public:
ModuleInstance(DesignComponent* definition, const FileContent* fileContent,
NodeId nodeId, ModuleInstance* parent,
std::string_view instName, std::string_view moduleName);
~ModuleInstance() override;
~ModuleInstance() final;

typedef std::map<UHDM::module_array*, std::vector<ModuleInstance*>>
ModuleArrayModuleInstancesMap;
Expand Down Expand Up @@ -101,8 +101,8 @@ class ModuleInstance : public ValuedComponentI {
std::vector<Parameter*>& getTypeParams() { return m_typeParams; }

Value* getValue(std::string_view name,
ExprBuilder& exprBuilder) const override;
UHDM::expr* getComplexValue(std::string_view name) const override;
ExprBuilder& exprBuilder) const final;
UHDM::expr* getComplexValue(std::string_view name) const final;

ModuleInstance* getInstanceBinding() { return m_boundInstance; }
bool isElaborated() const { return m_elaborated; }
Expand Down
6 changes: 3 additions & 3 deletions include/Surelog/Design/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ namespace SURELOG {

class FileContent;

class Parameter : public DataType {
class Parameter final : public DataType {
SURELOG_IMPLEMENT_RTTI(Parameter, DataType)
public:
Parameter(const FileContent* fC, NodeId nodeId, std::string_view name,
NodeId node_type, bool port_param);

~Parameter() override;
~Parameter() final;

VObjectType getType() const override;
VObjectType getType() const final;
NodeId getNodeType() const { return m_ntype; }

void setUhdmParam(UHDM::any* param) { m_param = param; }
Expand Down
4 changes: 2 additions & 2 deletions include/Surelog/Design/SimpleType.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace SURELOG {

class FileContent;

class SimpleType : public DataType {
class SimpleType final : public DataType {
SURELOG_IMPLEMENT_RTTI(SimpleType, DataType)
public:
SimpleType(const FileContent* fC, NodeId nameId, NodeId structId);
~SimpleType() override = default;
~SimpleType() final = default;

NodeId getNameId() const { return m_nameId; }

Expand Down
4 changes: 2 additions & 2 deletions include/Surelog/Design/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class SubRoutineCallStmt : public Statement {
std::string_view getFunc() const { return m_func; }
bool isStatic() const { return m_static; }
bool isSystemCall() const { return m_system; }
Function* getFunction() override { return m_function; }
void setFunction(Function* function) override { m_function = function; }
Function* getFunction() final { return m_function; }
void setFunction(Function* function) final { m_function = function; }

private:
std::vector<NodeId> m_var_chain;
Expand Down
6 changes: 3 additions & 3 deletions include/Surelog/Design/Struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ namespace SURELOG {

class FileContent;

class Struct : public DataType {
class Struct final : public DataType {
SURELOG_IMPLEMENT_RTTI(Struct, DataType)
public:
Struct(const FileContent* fC, NodeId nameId, NodeId structId);
~Struct() override = default;
~Struct() final = default;

NodeId getNameId() const { return m_nameId; }

bool isNet() const override;
bool isNet() const final;

private:
const NodeId m_nameId;
Expand Down
4 changes: 2 additions & 2 deletions include/Surelog/Design/TfPortItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace SURELOG {
class Procedure;
class Value;

class TfPortItem : public Variable {
class TfPortItem final : public Variable {
public:
TfPortItem(Procedure* parent, const FileContent* fc, NodeId id, NodeId range,
std::string_view name, DataType* type, Value* default_value,
Expand All @@ -42,7 +42,7 @@ class TfPortItem : public Variable {
m_parent(parent),
m_default(default_value),
m_direction(direction) {}
~TfPortItem() override = default;
~TfPortItem() final = default;

Procedure* getParent() const { return m_parent; }
Value* getDefault() const { return m_default; }
Expand Down
Loading

0 comments on commit b863057

Please sign in to comment.