From 8587f4c178decbf56b1ac2b858acc62ab7414dec Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sat, 9 Nov 2024 12:30:45 -0800 Subject: [PATCH] Deleted constructors should be public. --- include/Surelog/API/PythonAPI.h | 4 ++-- include/Surelog/Cache/Cache.h | 4 +--- include/Surelog/Cache/PPCache.h | 3 +-- include/Surelog/Cache/ParseCache.h | 3 +-- include/Surelog/Cache/PythonAPICache.h | 3 +-- include/Surelog/CommandLine/CommandLineParser.h | 4 ++-- include/Surelog/Common/FileSystem.h | 2 +- include/Surelog/Common/PlatformFileSystem.h | 2 +- include/Surelog/DesignCompile/CompileClass.h | 3 +-- include/Surelog/DesignCompile/CompileDesign.h | 3 +-- include/Surelog/DesignCompile/CompileFileContent.h | 3 +-- include/Surelog/DesignCompile/CompileHelper.h | 3 +-- include/Surelog/DesignCompile/CompileModule.h | 2 +- include/Surelog/ErrorReporting/ErrorContainer.h | 4 ++-- include/Surelog/ErrorReporting/LogListener.h | 2 +- include/Surelog/ErrorReporting/Report.h | 5 ++--- include/Surelog/ErrorReporting/Waiver.h | 6 +++--- include/Surelog/Expression/ExprBuilder.h | 4 ++-- include/Surelog/Library/ParseLibraryDef.h | 3 +-- include/Surelog/Package/Precompiled.h | 2 +- include/Surelog/SourceCompile/Compiler.h | 2 +- include/Surelog/SourceCompile/LoopCheck.h | 3 +-- include/Surelog/Testbench/ClassObject.h | 3 +-- include/Surelog/Testbench/Constraint.h | 3 +-- include/Surelog/Testbench/CoverGroupDefinition.h | 3 +-- include/Surelog/Testbench/Variable.h | 3 +-- 26 files changed, 33 insertions(+), 49 deletions(-) diff --git a/include/Surelog/API/PythonAPI.h b/include/Surelog/API/PythonAPI.h index 9eba899b66..843bf07b01 100644 --- a/include/Surelog/API/PythonAPI.h +++ b/include/Surelog/API/PythonAPI.h @@ -43,6 +43,8 @@ struct parser_rule_context; class PythonAPI { public: PythonAPI() = default; + PythonAPI(const PythonAPI& orig) = delete; + virtual ~PythonAPI() = default; /* Main interpreter (in main thread) */ @@ -74,8 +76,6 @@ class PythonAPI { static void setStrictMode(bool mode) { m_strictMode = mode; } private: - PythonAPI(const PythonAPI& orig) = delete; - static void initInterp_(); static void loadScriptsInInterp_(); static bool loadScript_(const std::filesystem::path& name, diff --git a/include/Surelog/Cache/Cache.h b/include/Surelog/Cache/Cache.h index abed9c4a93..b11b89ea93 100644 --- a/include/Surelog/Cache/Cache.h +++ b/include/Surelog/Cache/Cache.h @@ -48,6 +48,7 @@ class VObject; class Cache { public: + Cache(const Cache& orig) = delete; static constexpr uint64_t Capacity = 0x000000000FFFFFFF; protected: @@ -94,9 +95,6 @@ class Cache { void restoreSymbols( SymbolTable& targetSymbols, const ::capnp::List<::capnp::Text>::Reader& sourceSymbols); - - private: - Cache(const Cache& orig) = delete; }; } // namespace SURELOG diff --git a/include/Surelog/Cache/PPCache.h b/include/Surelog/Cache/PPCache.h index 2bebb5876d..44bafc9d58 100644 --- a/include/Surelog/Cache/PPCache.h +++ b/include/Surelog/Cache/PPCache.h @@ -35,14 +35,13 @@ class PreprocessFile; class PPCache : Cache { public: explicit PPCache(PreprocessFile* pp); + PPCache(const PPCache& orig) = delete; bool restore(bool errorsOnly); bool save(); bool isValid(); private: - PPCache(const PPCache& orig) = delete; - PathId getCacheFileId(PathId sourceFileId) const; bool checkCacheIsValid(PathId cacheFileId, diff --git a/include/Surelog/Cache/ParseCache.h b/include/Surelog/Cache/ParseCache.h index 5b49c9114d..1f5eb35deb 100644 --- a/include/Surelog/Cache/ParseCache.h +++ b/include/Surelog/Cache/ParseCache.h @@ -35,14 +35,13 @@ class ParseFile; class ParseCache final : Cache { public: explicit ParseCache(ParseFile* pp); + ParseCache(const ParseCache& orig) = delete; bool restore(); bool save(); bool isValid(); private: - ParseCache(const ParseCache& orig) = delete; - PathId getCacheFileId(PathId ppFileId) const; bool checkCacheIsValid(PathId cacheFileId, diff --git a/include/Surelog/Cache/PythonAPICache.h b/include/Surelog/Cache/PythonAPICache.h index 015ba10955..2bf27221a9 100644 --- a/include/Surelog/Cache/PythonAPICache.h +++ b/include/Surelog/Cache/PythonAPICache.h @@ -35,14 +35,13 @@ class PythonListen; class PythonAPICache final : Cache { public: explicit PythonAPICache(PythonListen* listener); + PythonAPICache(const PythonAPICache& orig) = delete; bool restore(); bool save(); bool isValid() const; private: - PythonAPICache(const PythonAPICache& orig) = delete; - PathId getCacheFileId(PathId sourceFileId) const; bool checkCacheIsValid(PathId cacheFileId, diff --git a/include/Surelog/CommandLine/CommandLineParser.h b/include/Surelog/CommandLine/CommandLineParser.h index e963de823f..75a8f19b24 100644 --- a/include/Surelog/CommandLine/CommandLineParser.h +++ b/include/Surelog/CommandLine/CommandLineParser.h @@ -46,6 +46,8 @@ class CommandLineParser final { public: CommandLineParser(ErrorContainer* errors, SymbolTable* symbolTable, bool diffCompMode = false, bool fileUnit = false); + CommandLineParser(const CommandLineParser& orig) = delete; + bool parseCommandLine(int32_t argc, const char** argv); /* Verilog command line content */ @@ -250,8 +252,6 @@ class CommandLineParser final { bool cleanCache(); private: - CommandLineParser(const CommandLineParser& orig) = delete; - std::pair addWorkingDirectory_( const std::filesystem::path& wd, const std::filesystem::path& rwd); bool plus_arguments_(std::string_view s, const std::filesystem::path& cd); diff --git a/include/Surelog/Common/FileSystem.h b/include/Surelog/Common/FileSystem.h index 9e2297fafb..cda9618e2a 100644 --- a/include/Surelog/Common/FileSystem.h +++ b/include/Surelog/Common/FileSystem.h @@ -368,7 +368,7 @@ class FileSystem { protected: FileSystem() = default; - private: + public: FileSystem(const FileSystem &rhs) = delete; FileSystem &operator=(const FileSystem &rhs) = delete; }; diff --git a/include/Surelog/Common/PlatformFileSystem.h b/include/Surelog/Common/PlatformFileSystem.h index b80a0f89d3..f76420ffa9 100644 --- a/include/Surelog/Common/PlatformFileSystem.h +++ b/include/Surelog/Common/PlatformFileSystem.h @@ -247,7 +247,7 @@ class PlatformFileSystem /*final*/ : public FileSystem { Mappings m_mappings; std::filesystem::path m_outputDir; - private: + public: PlatformFileSystem(const PlatformFileSystem &rhs) = delete; PlatformFileSystem &operator=(const PlatformFileSystem &rhs) = delete; }; diff --git a/include/Surelog/DesignCompile/CompileClass.h b/include/Surelog/DesignCompile/CompileClass.h index 30f9328cde..fdd72f132c 100644 --- a/include/Surelog/DesignCompile/CompileClass.h +++ b/include/Surelog/DesignCompile/CompileClass.h @@ -65,12 +65,11 @@ class CompileClass final { m_helper.seterrorReporting(errors, symbols); builtins_ = {"constraint_mode", "randomize", "rand_mode", "srandom"}; } + CompileClass(const CompileClass&) = delete; bool compile(); private: - CompileClass(const CompileClass&) = delete; - CompileDesign* const m_compileDesign; ClassDefinition* const m_class; Design* const m_design; diff --git a/include/Surelog/DesignCompile/CompileDesign.h b/include/Surelog/DesignCompile/CompileDesign.h index c112cc41f7..3038559bb7 100644 --- a/include/Surelog/DesignCompile/CompileDesign.h +++ b/include/Surelog/DesignCompile/CompileDesign.h @@ -48,6 +48,7 @@ class CompileDesign { public: // Note: takes owernship of compiler explicit CompileDesign(Compiler* compiler); + CompileDesign(const CompileDesign& orig) = delete; virtual ~CompileDesign(); // Used in MockCompileDesign bool compile(); @@ -65,8 +66,6 @@ class CompileDesign { } private: - CompileDesign(const CompileDesign& orig) = delete; - template void compileMT_(ObjectMapType& objects, int32_t maxThreadCount); diff --git a/include/Surelog/DesignCompile/CompileFileContent.h b/include/Surelog/DesignCompile/CompileFileContent.h index 56e3f4254a..035084f7be 100644 --- a/include/Surelog/DesignCompile/CompileFileContent.h +++ b/include/Surelog/DesignCompile/CompileFileContent.h @@ -84,12 +84,11 @@ class CompileFileContent final { m_declOnly(declOnly) { m_helper.seterrorReporting(errors, symbols); } + CompileFileContent(const CompileFileContent&) = delete; bool compile(); private: - CompileFileContent(const CompileFileContent&) = delete; - bool collectObjects_(); CompileDesign* const m_compileDesign; FileContent* const m_fileContent; diff --git a/include/Surelog/DesignCompile/CompileHelper.h b/include/Surelog/DesignCompile/CompileHelper.h index e95d54f744..d4ce370d0c 100644 --- a/include/Surelog/DesignCompile/CompileHelper.h +++ b/include/Surelog/DesignCompile/CompileHelper.h @@ -74,6 +74,7 @@ enum class Reduce : bool { Yes = true, No = false }; class CompileHelper final { public: CompileHelper() = default; + CompileHelper(const CompileHelper&) = delete; void seterrorReporting(ErrorContainer* errors, SymbolTable* symbols) { m_errors = errors; @@ -625,8 +626,6 @@ class CompileHelper final { void setElabMode(bool on) { m_elabMode = on; } private: - CompileHelper(const CompileHelper&) = delete; - ErrorContainer* m_errors = nullptr; SymbolTable* m_symbols = nullptr; ExprBuilder m_exprBuilder; diff --git a/include/Surelog/DesignCompile/CompileModule.h b/include/Surelog/DesignCompile/CompileModule.h index 606fcfa217..b2b3c66229 100644 --- a/include/Surelog/DesignCompile/CompileModule.h +++ b/include/Surelog/DesignCompile/CompileModule.h @@ -71,11 +71,11 @@ class CompileModule final { m_instance(instance) { m_helper.seterrorReporting(errors, symbols); } + CompileModule(const CompileModule&) = delete; bool compile(); private: - CompileModule(const CompileModule&) = delete; enum CollectType { FUNCTION, DEFINITION, GENERATE_REGIONS, OTHER }; bool collectModuleObjects_(CollectType collectType); bool checkModule_(); diff --git a/include/Surelog/ErrorReporting/ErrorContainer.h b/include/Surelog/ErrorReporting/ErrorContainer.h index fe1f563596..711481bf6c 100644 --- a/include/Surelog/ErrorReporting/ErrorContainer.h +++ b/include/Surelog/ErrorReporting/ErrorContainer.h @@ -63,6 +63,8 @@ class ErrorContainer final { explicit ErrorContainer(SymbolTable* symbolTable, LogListener* logListener = nullptr); + ErrorContainer(const ErrorContainer& orig) = delete; + virtual ~ErrorContainer(); LogListener* getLogListener() { return m_logListener; } @@ -86,8 +88,6 @@ class ErrorContainer final { void setPythonInterp(void* interpState) { m_interpState = interpState; } private: - ErrorContainer(const ErrorContainer& orig) = delete; - std::pair createReport_() const; std::pair createReport_(const Error& error) const; std::vector m_errors; diff --git a/include/Surelog/ErrorReporting/LogListener.h b/include/Surelog/ErrorReporting/LogListener.h index e910e4c576..761b553850 100644 --- a/include/Surelog/ErrorReporting/LogListener.h +++ b/include/Surelog/ErrorReporting/LogListener.h @@ -84,7 +84,7 @@ class LogListener { int32_t droppedCount = 0; uint32_t maxQueuedMessageCount = DEFAULT_MAX_QUEUED_MESSAGE_COUNT; - private: + public: LogListener(const LogListener&) = delete; LogListener& operator=(const LogListener&) = delete; }; diff --git a/include/Surelog/ErrorReporting/Report.h b/include/Surelog/ErrorReporting/Report.h index c70b909bac..6ae9f19ecd 100644 --- a/include/Surelog/ErrorReporting/Report.h +++ b/include/Surelog/ErrorReporting/Report.h @@ -35,11 +35,10 @@ class SymbolTable; class Report final { public: Report() = default; + Report(const Report& orig) = delete; + std::pair makeDiffCompUnitReport(CommandLineParser* clp, SymbolTable* st); - - private: - Report(const Report& orig) = delete; }; } // namespace SURELOG diff --git a/include/Surelog/ErrorReporting/Waiver.h b/include/Surelog/ErrorReporting/Waiver.h index b5483b6362..293a7f9ada 100644 --- a/include/Surelog/ErrorReporting/Waiver.h +++ b/include/Surelog/ErrorReporting/Waiver.h @@ -38,6 +38,9 @@ namespace SURELOG { class Waiver final { public: + Waiver() = delete; + Waiver(const Waiver& orig) = delete; + static void initWaivers(); static bool macroArgCheck(std::string_view name); @@ -64,9 +67,6 @@ class Waiver final { } private: - Waiver() = delete; - Waiver(const Waiver& orig) = delete; - static std::set> m_macroArgCheck; static std::multimap m_waivers; }; diff --git a/include/Surelog/Expression/ExprBuilder.h b/include/Surelog/Expression/ExprBuilder.h index 9aad3c90f3..db32798555 100644 --- a/include/Surelog/Expression/ExprBuilder.h +++ b/include/Surelog/Expression/ExprBuilder.h @@ -41,6 +41,8 @@ class ValuedComponentI; class ExprBuilder final { public: ExprBuilder() = default; + ExprBuilder(const ExprBuilder& orig) = delete; + Value* evalExpr(const FileContent*, NodeId id, ValuedComponentI* instance = nullptr, bool muteErrors = false); @@ -56,8 +58,6 @@ class ExprBuilder final { ValueFactory& getValueFactory() { return m_valueFactory; } private: - ExprBuilder(const ExprBuilder& orig) = delete; - ValueFactory m_valueFactory; ErrorContainer* m_errors = nullptr; SymbolTable* m_symbols = nullptr; diff --git a/include/Surelog/Library/ParseLibraryDef.h b/include/Surelog/Library/ParseLibraryDef.h index 9f72e6a51a..7574409060 100644 --- a/include/Surelog/Library/ParseLibraryDef.h +++ b/include/Surelog/Library/ParseLibraryDef.h @@ -43,6 +43,7 @@ class ParseLibraryDef final { ParseLibraryDef(CommandLineParser* commandLineParser, ErrorContainer* errors, SymbolTable* symbolTable, LibrarySet* librarySet, ConfigSet* configSet); + ParseLibraryDef(const ParseLibraryDef& orig) = delete; bool parseLibrariesDefinition(); bool parseLibraryDefinition(PathId file, Library* lib = nullptr); @@ -62,8 +63,6 @@ class ParseLibraryDef final { ConfigSet* getConfigSet() const { return m_configSet; } private: - ParseLibraryDef(const ParseLibraryDef& orig) = delete; - PathId m_fileId; CommandLineParser* const m_commandLineParser; ErrorContainer* const m_errors; diff --git a/include/Surelog/Package/Precompiled.h b/include/Surelog/Package/Precompiled.h index 5400977877..1bccde5cec 100644 --- a/include/Surelog/Package/Precompiled.h +++ b/include/Surelog/Package/Precompiled.h @@ -38,6 +38,7 @@ class SymbolTable; class Precompiled final { public: static Precompiled* getSingleton(); + Precompiled(const Precompiled&) = delete; void addPrecompiled(std::string_view package_name, std::string_view fileName); @@ -50,7 +51,6 @@ class Precompiled final { private: Precompiled(); // Only accessed via singleton. - Precompiled(const Precompiled&) = delete; std::map> m_packageMap; std::set> m_packageFileSet; diff --git a/include/Surelog/SourceCompile/Compiler.h b/include/Surelog/SourceCompile/Compiler.h index 8fe44d0f5d..ee6e4b445b 100644 --- a/include/Surelog/SourceCompile/Compiler.h +++ b/include/Surelog/SourceCompile/Compiler.h @@ -65,6 +65,7 @@ class Compiler { SymbolTable* symbolTable); Compiler(CommandLineParser* commandLineParser, ErrorContainer* errors, SymbolTable* symbolTable, std::string_view text); + Compiler(const Compiler& orig) = delete; virtual ~Compiler(); bool compile(); @@ -104,7 +105,6 @@ class Compiler { #endif private: - Compiler(const Compiler& orig) = delete; bool parseLibrariesDef_(); bool ppinit_(); diff --git a/include/Surelog/SourceCompile/LoopCheck.h b/include/Surelog/SourceCompile/LoopCheck.h index a1d052c7e2..b56669a946 100644 --- a/include/Surelog/SourceCompile/LoopCheck.h +++ b/include/Surelog/SourceCompile/LoopCheck.h @@ -36,6 +36,7 @@ namespace SURELOG { class LoopCheck { public: LoopCheck() = default; + LoopCheck(const LoopCheck& orig) = delete; ~LoopCheck(); void clear(); @@ -46,8 +47,6 @@ class LoopCheck { std::vector reportLoop() const; private: - LoopCheck(const LoopCheck& orig) = delete; - class Node { public: explicit Node(SymbolId objId) : m_objId(objId), m_visited(false) {} diff --git a/include/Surelog/Testbench/ClassObject.h b/include/Surelog/Testbench/ClassObject.h index ca6bdc17a0..c978a1e87a 100644 --- a/include/Surelog/Testbench/ClassObject.h +++ b/include/Surelog/Testbench/ClassObject.h @@ -43,6 +43,7 @@ class ClassObject final { std::map, std::less<>>; explicit ClassObject(ClassDefinition* class_def) : m_class(class_def) {} + ClassObject(const ClassObject& orig) = delete; ClassDefinition* getClass() { return m_class; } const PropertyValueMap& getProperties() const { return m_properties; } @@ -50,8 +51,6 @@ class ClassObject final { Value* getValue(std::string_view property) const; private: - ClassObject(const ClassObject& orig) = delete; - ClassDefinition* const m_class; PropertyValueMap m_properties; }; diff --git a/include/Surelog/Testbench/Constraint.h b/include/Surelog/Testbench/Constraint.h index a6a355a8d6..d2292eabb5 100644 --- a/include/Surelog/Testbench/Constraint.h +++ b/include/Surelog/Testbench/Constraint.h @@ -38,14 +38,13 @@ class Constraint final { public: Constraint(const FileContent* fC, NodeId id, std::string_view name) : m_fileContent(fC), m_nodeId(id), m_name(name) {} + Constraint(const Constraint&) = delete; std::string_view getName() const { return m_name; } const FileContent* getFileContent() const { return m_fileContent; } NodeId getNodeId() const { return m_nodeId; } private: - Constraint(const Constraint&) = delete; - const FileContent* const m_fileContent; const NodeId m_nodeId; const std::string m_name; diff --git a/include/Surelog/Testbench/CoverGroupDefinition.h b/include/Surelog/Testbench/CoverGroupDefinition.h index 7dbdfdf3a9..e2383232af 100644 --- a/include/Surelog/Testbench/CoverGroupDefinition.h +++ b/include/Surelog/Testbench/CoverGroupDefinition.h @@ -38,6 +38,7 @@ class CoverGroupDefinition final { public: CoverGroupDefinition(const FileContent* fC, NodeId id, std::string_view name) : m_fileContent(fC), m_nodeId(id), m_name(name) {} + CoverGroupDefinition(const CoverGroupDefinition&) = delete; std::string_view getName() const { return m_name; } @@ -46,8 +47,6 @@ class CoverGroupDefinition final { NodeId getNodeId() const { return m_nodeId; } private: - CoverGroupDefinition(const CoverGroupDefinition&) = delete; - // Set in constructor, never updated, no copy constructor. Can be const. const FileContent* const m_fileContent; const NodeId m_nodeId; diff --git a/include/Surelog/Testbench/Variable.h b/include/Surelog/Testbench/Variable.h index b7bb23514b..af3a83e482 100644 --- a/include/Surelog/Testbench/Variable.h +++ b/include/Surelog/Testbench/Variable.h @@ -44,6 +44,7 @@ class Variable { m_nodeId(varId), m_range(range), m_name(name) {} + Variable(const Variable&) = delete; virtual ~Variable() = default; const DataType* getDataType() const { return m_dataType; } @@ -53,8 +54,6 @@ class Variable { NodeId getRange() const { return m_range; } private: - Variable(const Variable&) = delete; - // All of these values are only set in the constructor and we never // copy. So these can be const. const DataType* const m_dataType;