diff --git a/.clang-tidy b/.clang-tidy index 61436dcb64..782b6c63c2 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,8 +12,8 @@ Checks: > bugprone-*, -bugprone-branch-clone, - -bugprone-narrowing-conversions, -bugprone-easily-swappable-parameters, + -bugprone-narrowing-conversions, clang-diagnostic-*, clang-analyzer-*, -clang-analyzer-core.CallAndMessage, @@ -32,10 +32,13 @@ Checks: > -misc-unused-parameters, -misc-use-anonymous-namespace, modernize-*, - -modernize-use-trailing-return-type, + -modernize-type-traits, -modernize-use-auto, + -modernize-use-nodiscard, + -modernize-use-trailing-return-type, performance-*, -performance-avoid-endl, + -performance-enum-size, readability-*, -readability-braces-around-statements, -readability-convert-member-functions-to-static, diff --git a/.github/bin/run-clang-tidy-cached.cc b/.github/bin/run-clang-tidy-cached.cc index 4150456515..f33c6d5642 100755 --- a/.github/bin/run-clang-tidy-cached.cc +++ b/.github/bin/run-clang-tidy-cached.cc @@ -15,7 +15,7 @@ B=${0%%.cc}; [ "$B" -nt "$0" ] || c++ -std=c++17 -o"$B" "$0" && exec "$B" "$@"; // See the License for the specific language governing permissions and // limitations under the License. -// Location: https://github.com/hzeller/dev-tools (2024-10-18) +// Location: https://github.com/hzeller/dev-tools (2024-11-09) // Script to run clang-tidy on files in a bazel project while caching the // results as clang-tidy can be pretty slow. The clang-tidy output messages @@ -28,8 +28,9 @@ B=${0%%.cc}; [ "$B" -nt "$0" ] || c++ -std=c++17 -o"$B" "$0" && exec "$B" "$@"; // run-clang-tidy-cached.cc --checks="-*,modernize-use-override" --fix // // Note: useful environment variables to configure are -// CLANG_TIDY = binary to run; default would just be clang-tidy. -// CACHE_DIR = where to put the cached content; default ~/.cache +// CLANG_TIDY = binary to run; default would just be clang-tidy. +// CLANG_TIDY_CONFIG = override configuration file in kConfig.clang_tidy_file +// CACHE_DIR = where to put the cached content; default ~/.cache // This file shall be c++17 self-contained; not using any re2 or absl niceties. #include @@ -109,7 +110,8 @@ struct ConfigValues { // that is included by a lot of other files results in lots of reprocessing. bool revisit_if_any_include_changes = true; - // Clang tidy configuration: clang tidy files with checks. + // Clang tidy configuration: clang tidy files with checks. This can be + // overriden with environment variable CLANG_TIDY_CONFIG std::string_view clang_tidy_file = ".clang-tidy"; }; @@ -117,7 +119,7 @@ struct ConfigValues { static constexpr ConfigValues kConfig = { .start_dir = ".", .file_include_re = "^(src|include)", - .file_exclude_re = "\\.template\\.", + .file_exclude_re = "\\.template\\.|hellouhdm.cpp", // Not clean yet, don't revisit yet. .revisit_brokenfiles_if_build_config_newer = false, }; @@ -176,11 +178,15 @@ std::string GetContent(const fs::path &f) { return GetContent(file_to_read); } -const char *EnvWithFallback(const char *varname, const char *fallback) { - const char *value = getenv(varname); +std::string_view EnvWithFallback(const char *var, std::string_view fallback) { + const char *value = getenv(var); return value ? value : fallback; } +std::string_view GetClangTidyConfig() { + return EnvWithFallback("CLANG_TIDY_CONFIG", kConfig.clang_tidy_file); +} + std::string GetCommandOutput(const std::string &prog) { return GetContent(popen(prog.c_str(), "r")); // NOLINT } @@ -323,7 +329,7 @@ class ClangTidyRunner { static std::string AssembleArgs(int argc, char **argv) { std::string result = " --quiet"; result.append(" '--config-file=") - .append(kConfig.clang_tidy_file) + .append(GetClangTidyConfig()) .append("'"); for (const std::string_view arg : kExtraArgs) { result.append(" --extra-arg='").append(arg).append("'"); @@ -352,7 +358,7 @@ class ClangTidyRunner { // Make sure directory filename depends on .clang-tidy content. hash_t cache_unique_id = hashContent(version + clang_tidy_args_); - cache_unique_id ^= hashContent(GetContent(kConfig.clang_tidy_file)); + cache_unique_id ^= hashContent(GetContent(GetClangTidyConfig())); return cache_dir / fs::path(cache_prefix + "v" + major_version + "_" + ToHex(cache_unique_id, 8)); } @@ -527,8 +533,8 @@ class FileGatherer { int main(int argc, char *argv[]) { // Test that key files exist and remember their last change. - if (!fs::exists(kConfig.clang_tidy_file)) { - std::cerr << "Need a " << kConfig.clang_tidy_file << " config file.\n"; + if (!fs::exists(GetClangTidyConfig())) { + std::cerr << "Need a " << GetClangTidyConfig() << " config file.\n"; return EXIT_FAILURE; } diff --git a/.github/bin/run-clang-tidy.sh b/.github/bin/run-clang-tidy.sh index ba529fc40d..74290fd8b9 100755 --- a/.github/bin/run-clang-tidy.sh +++ b/.github/bin/run-clang-tidy.sh @@ -13,32 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -# TODO(hzeller): switch to .github/bin/run-clang-tidy-cached.cc -# entirely once we have all the issues addressed. -# It caches the results, so is much faster, but doesn't have the -# concept of the 'limited' clang-tidy. - -# Exact binary can be set with environment variable if needed. -CLANG_TIDY="${CLANG_TIDY:-clang-tidy}" - LOCAL_TMP=${TMPDIR:-/tmp} TIDY_OUT=${LOCAL_TMP}/clang-tidy-surelog.out -hash ${CLANG_TIDY} || exit 2 # make sure it is installed. - if [ "$1" == "limited" ]; then + export CLANG_TIDY_CONFIG="${LOCAL_TMP}/clang-tidy" # For now, since there are a lot things to fix, don't enable everything # that is mentioned in .clang-tidy, but add rules as we fix them. # The more strict .clang-tidy rules will still show up as reminders in the # IDE, so are hopefully fixed on the way. - cat > ${LOCAL_TMP}/clang-tidy < "${CLANG_TIDY_CONFIG}" < -*, bugprone-copy-constructor-init, bugprone-macro-parentheses, bugprone-redundant-branch-condition, bugprone-string-integer-assignment, + bugprone-suspicious-include, bugprone-suspicious-missing-comma, bugprone-suspicious-string-compare, bugprone-too-small-loop-variable, @@ -49,19 +41,29 @@ Checks: > clang-diagnostic-unused-private-field, google-build-using-namespace, google-explicit-constructor, + modernize-concat-nested-namespaces, modernize-loop-convert, + modernize-make-unique, modernize-raw-string-literal, + modernize-redundant-void-arg, + modernize-use-bool-literals, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-nullptr, modernize-use-override, + modernize-use-using, performance-faster-string-find, performance-for-range-copy, performance-inefficient-string-concatenation, performance-inefficient-vector-operation, performance-unnecessary-copy-initialization, performance-unnecessary-value-param, + readability-avoid-const-params-in-decls, readability-const-return-type, readability-container-size-empty, readability-delete-null-pointer, readability-non-const-parameter, + readability-redundant-casting, readability-redundant-member-init, readability-redundant-smartptr-get, readability-redundant-string-cstr, @@ -79,31 +81,13 @@ CheckOptions: - key: performance-unnecessary-copy-initialization.AllowedTypes value: ::SURELOG::SymbolId;SURELOG::SymbolId;SymbolId;::SURELOG::NodeId;SURELOG::NodeId;NodeId;::SURELOG::PathId;SURELOG::PathId;PathId EOF - CLANG_TIDY_OPTS="--config-file=${LOCAL_TMP}/clang-tidy" fi -CLANG_TIDY_OPTS="${CLANG_TIDY_OPTS} --quiet" - if [ ! -r compile_commands.json ]; then echo "To get compile_commands.json, run in root of project and " echo " make run-cmake-release" exit 1 fi -find src/ include/ -name "*.cpp" -or -name "*.h" \ - | grep -v Python | grep -v Constraint.h | grep -v "hello.*\.cpp" \ - | xargs -P$(nproc) -n 5 -- ${CLANG_TIDY} ${CLANG_TIDY_OPTS} 2>/dev/null \ - > ${TIDY_OUT} - -cat ${TIDY_OUT} - -sed 's|\(.*\)\(\[[a-zA-Z.-]*\]$\)|\2|p;d' < ${TIDY_OUT} \ - | sort | uniq -c | sort -rn - -if [ -s ${TIDY_OUT} ]; then - echo "There were clang-tidy warnings (see ${TIDY_OUT}). Please fix." - exit 1 -fi - -echo "No clang-tidy complaints.😎" -exit 0 +# Invoke run-clang-tidy-cached, possibly with the 'limited' clang-tidy config. +sh $(dirname $0)/run-clang-tidy-cached.cc diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a84fe35e08..fb09f7e208 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1075,7 +1075,7 @@ jobs: - name: Install Dependencies run: | sudo apt-get update -qq - sudo apt -qq -y install clang-tidy-18 \ + sudo apt -qq -y install clang-tidy-18 ccache \ g++-9 default-jre cmake \ uuid-dev build-essential @@ -1096,10 +1096,20 @@ jobs: submodules: recursive fetch-depth: 0 - - name: Use ccache - uses: hendrikmuhs/ccache-action@v1.2 + - name: Create Cache Timestamp + id: cache_timestamp + uses: nanzm/get-time-action@v2.0 + with: + format: 'YYYY-MM-DD-HH-mm-ss' + + - name: Retrieve cached results + uses: actions/cache@v3 with: - key: clang-tidy-codegen + path: | + /home/runner/.cache/clang-tidy + /home/runner/.cache/ccache + key: clang-tidy-${{ steps.cache_timestamp.outputs.time }} + restore-keys: clang-tidy- - name: Configure shell run: | @@ -1107,14 +1117,13 @@ jobs: - name: Prepare source run: | - make run-cmake-release - make -j2 -C build GenerateParser - make -j2 -C build GenerateParserListeners - make -j2 -C build GenerateCacheSerializers + make run-cmake-release-with-python + make -j2 -C build surelog # creates all relevant artifacts ln -sf build/compile_commands.json . - name: Run clang tidy run: | export CLANG_TIDY=clang-tidy-18 "${CLANG_TIDY}" --version - ./.github/bin/run-clang-tidy.sh limited + ./.github/bin/run-clang-tidy.sh limited \ + || ( cat Surelog_clang-tidy.out ; exit 1) diff --git a/include/Surelog/API/PythonAPI.h b/include/Surelog/API/PythonAPI.h index 37e89193e3..5302d560d6 100644 --- a/include/Surelog/API/PythonAPI.h +++ b/include/Surelog/API/PythonAPI.h @@ -30,7 +30,7 @@ #include struct _ts; -typedef struct _ts PyThreadState; +using PyThreadState = struct _ts; namespace SURELOG { @@ -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) */ @@ -59,7 +61,8 @@ class PythonAPI { const std::string& function, const std::vector& args, PyThreadState* interp); - static void evalScript(std::string function, SV3_1aPythonListener* listener, + static void evalScript(const std::string& function, + SV3_1aPythonListener* listener, parser_rule_context* ctx); static std::string getInvalidScriptString() { return m_invalidScriptResult; } static bool isListenerLoaded() { return m_listenerLoaded; } @@ -74,8 +77,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/API/SLAPI.h b/include/Surelog/API/SLAPI.h index 6a3f6864b5..720ae5cfd4 100644 --- a/include/Surelog/API/SLAPI.h +++ b/include/Surelog/API/SLAPI.h @@ -49,11 +49,11 @@ class ModuleInstance; class DesignComponent; class ErrorContainer; -typedef std::vector UIntVector; +using UIntVector = std::vector; /* Error DB API */ -void SLsetWaiver(const char* messageId, const char* fileName = 0, - uint32_t line = 0, const char* objectName = 0); +void SLsetWaiver(const char* messageId, const char* fileName = nullptr, + uint32_t line = 0, const char* objectName = nullptr); void SLoverrideSeverity(const char* messageId, const char* severity); @@ -67,13 +67,13 @@ void SLaddError(ErrorContainer* container, const char* messageId, void SLaddErrorContext(SV3_1aPythonListener* prog, antlr4::ParserRuleContext* context, const char* messageId, const char* objectName, - bool printColumn = 0); + bool printColumn = false); void SLaddMLErrorContext(SV3_1aPythonListener* prog, antlr4::ParserRuleContext* context1, antlr4::ParserRuleContext* context2, const char* messageId, const char* objectName1, - const char* objectName2, bool printColumn = 0); + const char* objectName2, bool printColumn = false); void SLaddMLError(ErrorContainer* container, const char* messageId, const char* fileName1, uint32_t line1, uint32_t col1, 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/ClockingBlockHolder.h b/include/Surelog/Common/ClockingBlockHolder.h index 4a8dfb27fd..a88b33d6bc 100644 --- a/include/Surelog/Common/ClockingBlockHolder.h +++ b/include/Surelog/Common/ClockingBlockHolder.h @@ -34,10 +34,10 @@ namespace SURELOG { class ClockingBlockHolder { public: - typedef std::multimap - ClockingBlockMap; + using ClockingBlockMap = + std::multimap; - virtual ~ClockingBlockHolder() {} // virtual as used as interface + virtual ~ClockingBlockHolder() = default; // virtual as used as interface ClockingBlockMap& getClockingBlockMap() { return m_clockingBlockMap; } void addClockingBlock(SymbolId blockId, ClockingBlock& block); diff --git a/include/Surelog/Common/Containers.h b/include/Surelog/Common/Containers.h index 6baa098613..03d9898a27 100644 --- a/include/Surelog/Common/Containers.h +++ b/include/Surelog/Common/Containers.h @@ -24,23 +24,23 @@ class Package; class Program; class MacroInfo; -typedef std::map - ModuleNameModuleDefinitionMap; -typedef std::multimap - PackageNamePackageDefinitionMultiMap; -typedef std::vector PackageDefinitionVec; -typedef std::map - ProgramNameProgramDefinitionMap; - -typedef std::multimap - ClassNameClassDefinitionMultiMap; -typedef std::map - ClassNameClassDefinitionMap; - -typedef std::map, StringViewCompare> - MacroStorage; -typedef std::map, StringViewCompare> - MacroStorageRef; +using ModuleNameModuleDefinitionMap = + std::map; +using PackageNamePackageDefinitionMultiMap = + std::multimap; +using PackageDefinitionVec = std::vector; +using ProgramNameProgramDefinitionMap = + std::map; + +using ClassNameClassDefinitionMultiMap = + std::multimap; +using ClassNameClassDefinitionMap = + std::map; + +using MacroStorage = + std::map, StringViewCompare>; +using MacroStorageRef = + std::map, StringViewCompare>; } // namespace SURELOG diff --git a/include/Surelog/Common/FileSystem.h b/include/Surelog/Common/FileSystem.h index e0bb7cd343..cda9618e2a 100644 --- a/include/Surelog/Common/FileSystem.h +++ b/include/Surelog/Common/FileSystem.h @@ -106,8 +106,8 @@ class FileSystem { static constexpr std::string_view kParserCacheDirName = kCacheDirName; static constexpr std::string_view kPythonCacheDirName = kCacheDirName; - typedef std::map> - filepath_to_working_directories_cache_t; + using filepath_to_working_directories_cache_t = + std::map>; public: static FileSystem *getInstance(); @@ -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/NodeId.h b/include/Surelog/Common/NodeId.h index 365950f2ee..401d657d35 100644 --- a/include/Surelog/Common/NodeId.h +++ b/include/Surelog/Common/NodeId.h @@ -32,14 +32,14 @@ namespace SURELOG { * currently owned by FileContent. * */ -typedef uint32_t RawNodeId; +using RawNodeId = uint32_t; inline static constexpr RawNodeId InvalidRawNodeId = 0; // Max of 28 bits as per cache! class NodeId final { public: constexpr NodeId() : NodeId(InvalidRawNodeId) {} constexpr explicit NodeId(RawNodeId id) : id(id) {} - constexpr NodeId(const NodeId &rhs) : id(rhs.id) {} + constexpr NodeId(const NodeId &rhs) = default; operator RawNodeId() const { return id; } // NOLINT @@ -154,9 +154,9 @@ struct NodeIdLessThanComparer final { } }; -typedef std::set NodeIdSet; -typedef std::unordered_set - NodeIdUnorderedSet; +using NodeIdSet = std::set; +using NodeIdUnorderedSet = + std::unordered_set; } // namespace SURELOG diff --git a/include/Surelog/Common/PathId.h b/include/Surelog/Common/PathId.h index 8b3ce94166..c578351457 100644 --- a/include/Surelog/Common/PathId.h +++ b/include/Surelog/Common/PathId.h @@ -43,7 +43,7 @@ namespace SURELOG { * of it outside of the SURELOG::FileSystem context. * */ -typedef uint32_t RawPathId; +using RawPathId = uint32_t; inline static constexpr RawPathId BadRawPathId = 0; inline static constexpr std::string_view BadRawPath = BadRawSymbol; @@ -141,10 +141,10 @@ struct PathIdLessThanComparer final { } }; -typedef std::set PathIdSet; -typedef std::unordered_set - PathIdUnorderedSet; -typedef std::vector PathIdVector; +using PathIdSet = std::set; +using PathIdUnorderedSet = + std::unordered_set; +using PathIdVector = std::vector; } // namespace SURELOG diff --git a/include/Surelog/Common/PlatformFileSystem.h b/include/Surelog/Common/PlatformFileSystem.h index fc1cc46334..f76420ffa9 100644 --- a/include/Surelog/Common/PlatformFileSystem.h +++ b/include/Surelog/Common/PlatformFileSystem.h @@ -54,13 +54,13 @@ class PlatformFileSystem /*final*/ : public FileSystem { std::filesystem::path m_sourceDir; std::filesystem::path m_cacheDir; }; - typedef std::vector Configurations; + using Configurations = std::vector; struct Mapping final { std::string m_what; std::string m_with; }; - typedef std::vector Mappings; + using Mappings = std::vector; public: PathId toPathId(std::string_view path, SymbolTable *symbolTable) override; @@ -202,7 +202,7 @@ class PlatformFileSystem /*final*/ : public FileSystem { // ref: https://stackoverflow.com/a/18940595 template struct Comparer final { - typedef std::true_type is_transparent; + using is_transparent = std::true_type; // helper does some magic in order to reduce the number of // pairs of types we need to know how to compare: it turns // everything into a pointer, and then uses `std::less` @@ -231,10 +231,10 @@ class PlatformFileSystem /*final*/ : public FileSystem { } }; - typedef std::set, Comparer> - InputStreams; - typedef std::set, Comparer> - OutputStreams; + using InputStreams = + std::set, Comparer>; + using OutputStreams = + std::set, Comparer>; const std::filesystem::path m_workingDir; @@ -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/Common/PortNetHolder.h b/include/Surelog/Common/PortNetHolder.h index 0c2e51ecc7..c587d493b9 100644 --- a/include/Surelog/Common/PortNetHolder.h +++ b/include/Surelog/Common/PortNetHolder.h @@ -36,7 +36,7 @@ class Signal; class PortNetHolder { public: - virtual ~PortNetHolder() {} // virtual as used as interface + virtual ~PortNetHolder() = default; // virtual as used as interface std::vector& getPorts() { return m_ports; } std::vector& getSignals() { return m_signals; } diff --git a/include/Surelog/Design/Design.h b/include/Surelog/Design/Design.h index 647c5c986f..8bb8cfff86 100644 --- a/include/Surelog/Design/Design.h +++ b/include/Surelog/Design/Design.h @@ -83,7 +83,7 @@ class Design final { ~Design(); - typedef std::vector> FileIdDesignContentMap; + using FileIdDesignContentMap = std::vector>; // TODO: Unfortunately, all these need to be non-const, as there is code // on the receiving end is not using const stringently enough. @@ -158,7 +158,7 @@ class Design final { ErrorContainer* getErrorContainer() { return m_errors; } - typedef std::multimap> BindMap; + using BindMap = std::multimap>; BindMap& getBindMap() { return m_bindMap; } diff --git a/include/Surelog/Design/DesignComponent.h b/include/Surelog/Design/DesignComponent.h index ae416d26ef..4c22f949fc 100644 --- a/include/Surelog/Design/DesignComponent.h +++ b/include/Surelog/Design/DesignComponent.h @@ -78,7 +78,7 @@ class DesignComponent : public ValuedComponentI, public PortNetHolder { public: DesignComponent(const DesignComponent* parent, DesignComponent* definition) : ValuedComponentI(parent, definition), m_instance(nullptr) {} - ~DesignComponent() override {} + ~DesignComponent() override = default; virtual uint32_t getSize() const = 0; virtual VObjectType getType() const = 0; @@ -86,22 +86,22 @@ class DesignComponent : public ValuedComponentI, public PortNetHolder { virtual std::string_view getName() const = 0; void append(DesignComponent*); - typedef std::map DataTypeMap; - typedef std::map TypeDefMap; - typedef std::vector DataTypeVec; - typedef std::vector TypeDefVec; - typedef std::map FunctionMap; - typedef std::map TaskMap; - typedef std::map VariableMap; - typedef std::map ParameterMap; - typedef std::vector ParameterVec; - typedef std::vector ParamAssignVec; - typedef std::map LetStmtMap; - typedef std::map, - StringViewCompare> - NamedObjectMap; - typedef std::vector> - FuncNameTypespecVec; + using DataTypeMap = std::map; + using TypeDefMap = std::map; + using DataTypeVec = std::vector; + using TypeDefVec = std::vector; + using FunctionMap = std::map; + using TaskMap = std::map; + using VariableMap = std::map; + using ParameterMap = std::map; + using ParameterVec = std::vector; + using ParamAssignVec = std::vector; + using LetStmtMap = std::map; + using NamedObjectMap = + std::map, + StringViewCompare>; + using FuncNameTypespecVec = + std::vector>; void addFileContent(const FileContent* fileContent, NodeId nodeId); const std::vector& getFileContents() const { diff --git a/include/Surelog/Design/Enum.h b/include/Surelog/Design/Enum.h index c84c93c904..28775b7b32 100644 --- a/include/Surelog/Design/Enum.h +++ b/include/Surelog/Design/Enum.h @@ -49,8 +49,8 @@ class Enum final : public DataType { Enum(const FileContent* fC, NodeId nameId, NodeId baseTypeId); ~Enum() final = default; - typedef std::map, std::less<>> - NameValueMap; + using NameValueMap = + std::map, std::less<>>; void addValue(std::string_view name, uint32_t lineNb, Value* value) { m_values.emplace(name, std::make_pair(lineNb, value)); diff --git a/include/Surelog/Design/FileContent.h b/include/Surelog/Design/FileContent.h index 5eece2f2ed..1491fa1e4d 100644 --- a/include/Surelog/Design/FileContent.h +++ b/include/Surelog/Design/FileContent.h @@ -58,7 +58,7 @@ class FileContent final : public DesignComponent { void setLibrary(Library* lib) { m_library = lib; } - typedef std::map> NameIdMap; + using NameIdMap = std::map>; NodeId sl_get(NodeId parent, VObjectType type) const; // Get first child item of type diff --git a/include/Surelog/Design/Function.h b/include/Surelog/Design/Function.h index edbd8134a7..49bc7db834 100644 --- a/include/Surelog/Design/Function.h +++ b/include/Surelog/Design/Function.h @@ -40,7 +40,7 @@ class CompileHelper; class DesignComponent; class FileContent; class TfPortItem; -typedef std::vector TfPortList; +using TfPortList = std::vector; class Procedure : public Scope, public Statement { SURELOG_IMPLEMENT_RTTI_2_BASES(Procedure, Scope, Statement) diff --git a/include/Surelog/Design/Instance.h b/include/Surelog/Design/Instance.h index 34e554b156..178b47a00f 100644 --- a/include/Surelog/Design/Instance.h +++ b/include/Surelog/Design/Instance.h @@ -29,7 +29,7 @@ namespace SURELOG { class Instance final { public: - Instance() {} + Instance() = default; Instance(const Instance& orig) = delete; }; diff --git a/include/Surelog/Design/ModuleDefinition.h b/include/Surelog/Design/ModuleDefinition.h index 41f07b782a..558decd145 100644 --- a/include/Surelog/Design/ModuleDefinition.h +++ b/include/Surelog/Design/ModuleDefinition.h @@ -62,10 +62,10 @@ class ModuleDefinition final : public DesignComponent, bool isInstance() const final; uint32_t getSize() const final; - typedef std::map ClockingBlockMap; - typedef std::map> ModPortSignalMap; - typedef std::map, std::less<>> - ModPortClockingBlockMap; + using ClockingBlockMap = std::map; + using ModPortSignalMap = std::map>; + using ModPortClockingBlockMap = + std::map, std::less<>>; ModPortSignalMap& getModPortSignalMap() { return m_modportSignalMap; } ModPortClockingBlockMap& getModPortClockingBlockMap() { diff --git a/include/Surelog/Design/ModuleInstance.h b/include/Surelog/Design/ModuleInstance.h index 3d5008b0a4..ee6dfbb6ac 100644 --- a/include/Surelog/Design/ModuleInstance.h +++ b/include/Surelog/Design/ModuleInstance.h @@ -56,8 +56,8 @@ class ModuleInstance final : public ValuedComponentI { std::string_view instName, std::string_view moduleName); ~ModuleInstance() final; - typedef std::map> - ModuleArrayModuleInstancesMap; + using ModuleArrayModuleInstancesMap = + std::map>; void addSubInstance(ModuleInstance* subInstance); std::vector& getAllSubInstances() { diff --git a/include/Surelog/Design/Netlist.h b/include/Surelog/Design/Netlist.h index 6b6266b8c8..bec2dd5c83 100644 --- a/include/Surelog/Design/Netlist.h +++ b/include/Surelog/Design/Netlist.h @@ -44,13 +44,12 @@ class Netlist { explicit Netlist(ModuleInstance* parent) : m_parent(parent) {} ~Netlist(); - typedef std::map, - std::less<>> - ModPortMap; - typedef std::map, - std::less<>> - InstanceMap; - typedef std::map> SymbolTable; + using ModPortMap = + std::map, std::less<>>; + using InstanceMap = + std::map, + std::less<>>; + using SymbolTable = std::map>; std::vector* interfaces() { return m_interfaces; } std::vector* interface_arrays() { diff --git a/include/Surelog/Design/Scope.h b/include/Surelog/Design/Scope.h index 182dc32f64..6e737e7715 100644 --- a/include/Surelog/Design/Scope.h +++ b/include/Surelog/Design/Scope.h @@ -42,14 +42,14 @@ class Variable; class Scope : public RTTI { SURELOG_IMPLEMENT_RTTI(Scope, RTTI) public: - typedef std::map> VariableMap; - typedef std::map> DataTypeMap; - typedef std::vector StmtVector; - typedef std::vector ScopeVector; + using VariableMap = std::map>; + using DataTypeMap = std::map>; + using StmtVector = std::vector; + using ScopeVector = std::vector; Scope(std::string_view name, Scope* parent) : m_name(name), m_parentScope(parent) {} - ~Scope() override {} + ~Scope() override = default; std::string_view getName() const { return m_name; } Scope* getParentScope() { return m_parentScope; } diff --git a/include/Surelog/Design/Statement.h b/include/Surelog/Design/Statement.h index 3d71e95390..87c52f6855 100644 --- a/include/Surelog/Design/Statement.h +++ b/include/Surelog/Design/Statement.h @@ -45,7 +45,7 @@ class Value; class Statement : public RTTI { SURELOG_IMPLEMENT_RTTI(Statement, RTTI) public: - typedef std::vector StatementVector; + using StatementVector = std::vector; Statement(Scope* scope, Statement* parentStmt, const FileContent* fileContent, NodeId node, VObjectType type) : m_scope(scope), 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 b94f15e663..d4ce370d0c 100644 --- a/include/Surelog/DesignCompile/CompileHelper.h +++ b/include/Surelog/DesignCompile/CompileHelper.h @@ -56,7 +56,7 @@ class Statement; class SymbolTable; class Task; class TfPortItem; -typedef std::vector TfPortList; +using TfPortList = std::vector; class FScope : public ValuedComponentI { SURELOG_IMPLEMENT_RTTI(FScope, ValuedComponentI) @@ -68,12 +68,13 @@ class FScope : public ValuedComponentI { private: }; -typedef std::vector Scopes; +using Scopes = std::vector; enum class Reduce : bool { Yes = true, No = false }; class CompileHelper final { public: - CompileHelper() {} + 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/DesignCompile/NetlistElaboration.h b/include/Surelog/DesignCompile/NetlistElaboration.h index ad534d9a85..5fd78c7e2d 100644 --- a/include/Surelog/DesignCompile/NetlistElaboration.h +++ b/include/Surelog/DesignCompile/NetlistElaboration.h @@ -50,7 +50,7 @@ class NetlistElaboration final : public TestbenchElaboration { ~NetlistElaboration() final; - typedef std::map TypespecCache; + using TypespecCache = std::map; bool elabSignal(Signal* sig, ModuleInstance* instance, ModuleInstance* child, Netlist* parentNetlist, Netlist* netlist, DesignComponent* comp, std::string_view prefix, diff --git a/include/Surelog/DesignCompile/UhdmChecker.h b/include/Surelog/DesignCompile/UhdmChecker.h index e87c3b59dd..7ba160661d 100644 --- a/include/Surelog/DesignCompile/UhdmChecker.h +++ b/include/Surelog/DesignCompile/UhdmChecker.h @@ -57,7 +57,7 @@ class UhdmChecker final { CompileDesign* const m_compileDesign; Design* const m_design; - typedef uint32_t LineNb; + using LineNb = uint32_t; enum Status { EXIST, COVERED, UNSUPPORTED }; class ColRange { public: @@ -65,9 +65,9 @@ class UhdmChecker final { uint16_t to; Status covered; }; - typedef std::vector Ranges; - typedef std::map RangesMap; - typedef std::map FileNodeCoverMap; + using Ranges = std::vector; + using RangesMap = std::map; + using FileNodeCoverMap = std::map; FileNodeCoverMap fileNodeCoverMap; std::map fileMap; std::multimap> coverageMap; diff --git a/include/Surelog/DesignCompile/UhdmWriter.h b/include/Surelog/DesignCompile/UhdmWriter.h index b160298ef9..27d2b2945e 100644 --- a/include/Surelog/DesignCompile/UhdmWriter.h +++ b/include/Surelog/DesignCompile/UhdmWriter.h @@ -52,13 +52,13 @@ class Signal; class UhdmWriter final { public: - typedef std::map ModPortMap; - typedef std::map ComponentMap; - typedef std::map ModuleMap; - typedef std::map SignalBaseClassMap; - typedef std::map> SignalMap; - typedef std::map InstanceMap; - typedef std::map VpiSignalMap; + using ModPortMap = std::map; + using ComponentMap = std::map; + using ModuleMap = std::map; + using SignalBaseClassMap = std::map; + using SignalMap = std::map>; + using InstanceMap = std::map; + using VpiSignalMap = std::map; UhdmWriter(CompileDesign* compiler, Design* design); 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 6191c6ae8b..db32798555 100644 --- a/include/Surelog/Expression/ExprBuilder.h +++ b/include/Surelog/Expression/ExprBuilder.h @@ -40,7 +40,9 @@ class ValuedComponentI; class ExprBuilder final { public: - ExprBuilder() {} + 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/Expression/Value.h b/include/Surelog/Expression/Value.h index 1a608151b9..f302087b0e 100644 --- a/include/Surelog/Expression/Value.h +++ b/include/Surelog/Expression/Value.h @@ -57,7 +57,7 @@ class Value : public RTTI { Scalar }; - ~Value() override {} + ~Value() override = default; virtual int32_t getSize() const = 0; // size in bits virtual int32_t getSize( diff --git a/include/Surelog/Library/AntlrLibParserErrorListener.h b/include/Surelog/Library/AntlrLibParserErrorListener.h index 13ee04735e..98cb38f653 100644 --- a/include/Surelog/Library/AntlrLibParserErrorListener.h +++ b/include/Surelog/Library/AntlrLibParserErrorListener.h @@ -40,7 +40,7 @@ class AntlrLibParserErrorListener final : public antlr4::ANTLRErrorListener { explicit AntlrLibParserErrorListener(ParseLibraryDef *parser) : m_parser(parser) {} - ~AntlrLibParserErrorListener() final{}; + ~AntlrLibParserErrorListener() final = default; void syntaxError(antlr4::Recognizer *recognizer, antlr4::Token *offendingSymbol, size_t line, diff --git a/include/Surelog/Library/Library.h b/include/Surelog/Library/Library.h index 6017ca741e..15a62c0096 100644 --- a/include/Surelog/Library/Library.h +++ b/include/Surelog/Library/Library.h @@ -40,8 +40,8 @@ class SymbolTable; class Library final { public: - typedef std::map - ModuleDefinitionByNameMap; + using ModuleDefinitionByNameMap = + std::map; public: Library(std::string_view name, SymbolTable* symbols); 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/AntlrParserErrorListener.h b/include/Surelog/SourceCompile/AntlrParserErrorListener.h index 0def579382..121707d41c 100644 --- a/include/Surelog/SourceCompile/AntlrParserErrorListener.h +++ b/include/Surelog/SourceCompile/AntlrParserErrorListener.h @@ -48,7 +48,7 @@ class AntlrParserErrorListener final : public antlr4::ANTLRErrorListener { m_fileId(fileId), m_printExtraPpLineInfo(printExtraPpLineInfo) {} - ~AntlrParserErrorListener() final{}; + ~AntlrParserErrorListener() final = default; void syntaxError(antlr4::Recognizer *recognizer, antlr4::Token *offendingSymbol, size_t line, diff --git a/include/Surelog/SourceCompile/CommonListenerHelper.h b/include/Surelog/SourceCompile/CommonListenerHelper.h index 8e47df46f1..2d343c9ec8 100644 --- a/include/Surelog/SourceCompile/CommonListenerHelper.h +++ b/include/Surelog/SourceCompile/CommonListenerHelper.h @@ -103,7 +103,7 @@ class CommonListenerHelper { FileContent* m_fileContent; antlr4::CommonTokenStream* const m_tokens; - typedef std::map ContextToObjectMap; + using ContextToObjectMap = std::map; ContextToObjectMap m_contextToObjectMap; }; diff --git a/include/Surelog/SourceCompile/CompileSourceFile.h b/include/Surelog/SourceCompile/CompileSourceFile.h index 17eaca18d2..2c1bcd14e1 100644 --- a/include/Surelog/SourceCompile/CompileSourceFile.h +++ b/include/Surelog/SourceCompile/CompileSourceFile.h @@ -35,7 +35,7 @@ #ifdef SURELOG_WITH_PYTHON struct _ts; -typedef struct _ts PyThreadState; +using PyThreadState = struct _ts; #endif namespace SURELOG { diff --git a/include/Surelog/SourceCompile/Compiler.h b/include/Surelog/SourceCompile/Compiler.h index 91bf613163..ee6e4b445b 100644 --- a/include/Surelog/SourceCompile/Compiler.h +++ b/include/Surelog/SourceCompile/Compiler.h @@ -59,12 +59,13 @@ class SymbolTable; class Compiler { public: - typedef std::map, PathIdLessThanComparer> - PPFileMap; + using PPFileMap = + std::map, PathIdLessThanComparer>; Compiler(CommandLineParser* commandLineParser, ErrorContainer* errors, 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/IncludeFileInfo.h b/include/Surelog/SourceCompile/IncludeFileInfo.h index 8209e752a7..b4e0b622b1 100644 --- a/include/Surelog/SourceCompile/IncludeFileInfo.h +++ b/include/Surelog/SourceCompile/IncludeFileInfo.h @@ -44,17 +44,8 @@ class IncludeFileInfo { sectionFileId, originalStartLine, originalStartColumn, originalEndLine, originalEndColumn, action, -1, -1) {} IncludeFileInfo(const IncludeFileInfo& i) - : m_context(i.m_context), - m_sectionStartLine(i.m_sectionStartLine), - m_sectionSymbolId(i.m_sectionSymbolId), - m_sectionFileId(i.m_sectionFileId), - m_originalStartLine(i.m_originalStartLine), - m_originalStartColumn(i.m_originalStartColumn), - m_originalEndLine(i.m_originalEndLine), - m_originalEndColumn(i.m_originalEndColumn), - m_action(i.m_action), - m_indexOpening(i.m_indexOpening), - m_indexClosing(i.m_indexClosing) {} + + = default; IncludeFileInfo(Context context, uint32_t sectionStartLine, SymbolId sectionSymbolId, PathId sectionFileId, uint32_t originalStartLine, uint32_t originalStartColumn, 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/SourceCompile/PreprocessFile.h b/include/Surelog/SourceCompile/PreprocessFile.h index b34d336be2..d490ccb931 100644 --- a/include/Surelog/SourceCompile/PreprocessFile.h +++ b/include/Surelog/SourceCompile/PreprocessFile.h @@ -200,13 +200,8 @@ class PreprocessFile final { m_evaluate(Evaluate), m_persist(DontPersist) {} SpecialInstructions(SpecialInstructions& rhs) - : m_mute(rhs.m_mute), - m_mark_empty_macro(rhs.m_mark_empty_macro), - m_filterFileLine(rhs.m_filterFileLine), - m_check_macro_loop(rhs.m_check_macro_loop), - m_as_is_undefined_macro(rhs.m_as_is_undefined_macro), - m_evaluate(rhs.m_evaluate), - m_persist(rhs.m_persist) {} + + = default; SpecialInstructions(TraceInstr mute, EmptyMacroInstr mark_empty_macro, FileLineInfoInstr filterFileLine, CheckLoopInstr check_macro_loop, @@ -255,7 +250,7 @@ class PreprocessFile final { Type m_type = Type::IFDEF; bool m_previousActiveState = false; }; - typedef std::vector IfElseStack; + using IfElseStack = std::vector; IfElseStack m_ifStack; IfElseStack& getStack(); diff --git a/include/Surelog/SourceCompile/PythonListen.h b/include/Surelog/SourceCompile/PythonListen.h index 7ed4ad6289..5d5069be99 100644 --- a/include/Surelog/SourceCompile/PythonListen.h +++ b/include/Surelog/SourceCompile/PythonListen.h @@ -37,6 +37,8 @@ class SV3_1aPythonListener; class PythonListen { public: PythonListen(ParseFile* parse, CompileSourceFile* m_compileSourceFile); + PythonListen(const PythonListen& orig) = delete; + bool listen(); virtual ~PythonListen(); @@ -47,8 +49,6 @@ class PythonListen { void addError(Error& error); private: - PythonListen(const PythonListen& orig) = delete; - ParseFile* const m_parse; CompileSourceFile* const m_compileSourceFile; std::vector m_pythonListeners; diff --git a/include/Surelog/SourceCompile/SymbolTable.h b/include/Surelog/SourceCompile/SymbolTable.h index 486eb3e7a1..d58583b923 100644 --- a/include/Surelog/SourceCompile/SymbolTable.h +++ b/include/Surelog/SourceCompile/SymbolTable.h @@ -46,7 +46,7 @@ class SymbolTable final : public UHDM::SymbolFactory { private: // Create a snapshot of the current symbol table. Private, as this // functionality should be explicitly accessed through CreateSnapshot(). - SymbolTable(const SymbolTable& parent) : SymbolFactory(parent) {} + SymbolTable(const SymbolTable& parent) = default; }; } // namespace SURELOG diff --git a/include/Surelog/Testbench/ClassDefinition.h b/include/Surelog/Testbench/ClassDefinition.h index 3bc7b8681e..594ebffe33 100644 --- a/include/Surelog/Testbench/ClassDefinition.h +++ b/include/Surelog/Testbench/ClassDefinition.h @@ -70,14 +70,14 @@ class ClassDefinition final : public DesignComponent, public DataType { UHDM::class_defn* getUhdmDefinition() const { return m_uhdm_definition; } // Parameter definitions are stored DesignComponent maps - typedef std::map PropertyMap; - typedef std::map TaskMap; - typedef std::map ConstraintMap; - typedef std::map - BaseClassMap; - typedef std::map ClassMap; - typedef std::map - CoverGroupMap; + using PropertyMap = std::map; + using TaskMap = std::map; + using ConstraintMap = std::map; + using BaseClassMap = + std::map; + using ClassMap = std::map; + using CoverGroupMap = + std::map; const PropertyMap& getPropertyMap() const { return m_properties; } Property* getProperty(std::string_view name) const; diff --git a/include/Surelog/Testbench/ClassObject.h b/include/Surelog/Testbench/ClassObject.h index aed84f0fd2..c978a1e87a 100644 --- a/include/Surelog/Testbench/ClassObject.h +++ b/include/Surelog/Testbench/ClassObject.h @@ -39,10 +39,11 @@ class Value; class ClassObject final { public: - typedef std::map, std::less<>> - PropertyValueMap; + using PropertyValueMap = + 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; diff --git a/include/Surelog/Utils/NumUtils.h b/include/Surelog/Utils/NumUtils.h index eeb4a6d526..49c60c5122 100644 --- a/include/Surelog/Utils/NumUtils.h +++ b/include/Surelog/Utils/NumUtils.h @@ -31,8 +31,7 @@ #include #include -namespace SURELOG { -namespace NumUtils { +namespace SURELOG::NumUtils { namespace internal { // These functions parse a number from a std::string_view into "result". // Returns the end of the number on success, nullptr otherwise. @@ -176,7 +175,6 @@ template // failure. [[nodiscard]] const char* parseLongDouble(std::string_view s, long double* result); -} // namespace NumUtils -} // namespace SURELOG +} // namespace SURELOG::NumUtils #endif /* SURELOG_NUMUTILS_H */ diff --git a/include/Surelog/Utils/ParseUtils.h b/include/Surelog/Utils/ParseUtils.h index caf06fe1f8..e18c319c0d 100644 --- a/include/Surelog/Utils/ParseUtils.h +++ b/include/Surelog/Utils/ParseUtils.h @@ -31,8 +31,7 @@ #include #include -namespace SURELOG { -namespace ParseUtils { +namespace SURELOG::ParseUtils { using ParseTree = antlr4::tree::ParseTree; using LineColumn = std::pair; @@ -54,8 +53,6 @@ void tokenizeAtComma(std::vector& actualArgs, std::vector getFlatTokenList(ParseTree* tree); void inOrderTraversal(std::vector& tokens, ParseTree* parent); -} // namespace ParseUtils - -} // namespace SURELOG +} // namespace SURELOG::ParseUtils #endif /* SURELOG_PARSEUTILS_H */ diff --git a/include/Surelog/Utils/StringUtils.h b/include/Surelog/Utils/StringUtils.h index 8da16759e0..b26a0a7bee 100644 --- a/include/Surelog/Utils/StringUtils.h +++ b/include/Surelog/Utils/StringUtils.h @@ -130,7 +130,7 @@ std::string replaceAll(std::string_view str, std::string_view from, std::vector splitLines(std::string_view text); // Convert double number with given amount of precision. -std::string to_string(double a_value, const int32_t n = 3); +std::string to_string(double a_value, int32_t n = 3); // Remove '//' and '#'-style end-of-line comments [[nodiscard]] std::string removeComments(std::string_view text); diff --git a/include/Surelog/Utils/Timer.h b/include/Surelog/Utils/Timer.h index a2d78b11d1..178932d8f1 100644 --- a/include/Surelog/Utils/Timer.h +++ b/include/Surelog/Utils/Timer.h @@ -53,8 +53,8 @@ class Timer final { } private: - typedef std::chrono::high_resolution_clock clock_; - typedef std::chrono::duration > second_; + using clock_ = std::chrono::high_resolution_clock; + using second_ = std::chrono::duration>; std::chrono::time_point beg_; }; diff --git a/scripts/generate_python_listener.py b/scripts/generate_python_listener.py index 2cb61fab01..be1feab322 100644 --- a/scripts/generate_python_listener.py +++ b/scripts/generate_python_listener.py @@ -89,7 +89,7 @@ def _main(): ' PythonListen* getPythonListen() { return m_pl; }', ' antlr4::CommonTokenStream* getTokenStream() { return m_tokens; }', '', - ' void logError(ErrorDefinition::ErrorType error, antlr4::ParserRuleContext* ctx, std::string object, bool printColumn = false);', + ' void logError(ErrorDefinition::ErrorType error, antlr4::ParserRuleContext* ctx, const std::string& object, bool printColumn = false);', ' void logError(ErrorDefinition::ErrorType, Location& loc, bool showDuplicates = false);', ' void logError(ErrorDefinition::ErrorType, Location& loc, Location& extraLoc, bool showDuplicates = false);', '', diff --git a/src/API/PythonAPI.cpp b/src/API/PythonAPI.cpp index 768c154fdf..3941b97abd 100644 --- a/src/API/PythonAPI.cpp +++ b/src/API/PythonAPI.cpp @@ -42,8 +42,8 @@ #include "Surelog/API/VObjectTypes_py.h" #include "Surelog/API/slapi_scripts.h" -typedef SURELOG::NodeId NodeId; -#include +using NodeId = SURELOG::NodeId; +#include // NOLINT(bugprone-suspicious-include) #endif #include @@ -76,7 +76,7 @@ static struct PyModuleDef SLAPI_module = {PyModuleDef_HEAD_INIT, nullptr, nullptr}; -static PyObject* PyInit_slapi(void) { return PyModule_Create(&SLAPI_module); } +static PyObject* PyInit_slapi() { return PyModule_Create(&SLAPI_module); } #endif void PythonAPI::shutdown() { @@ -275,7 +275,8 @@ void PythonAPI::init(int32_t argc, const char** argv) { #endif } -void PythonAPI::evalScript(std::string function, SV3_1aPythonListener* listener, +void PythonAPI::evalScript(const std::string& function, + SV3_1aPythonListener* listener, parser_rule_context* ctx1) { #ifdef SURELOG_WITH_PYTHON antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)ctx1; diff --git a/src/API/SLAPI.cpp b/src/API/SLAPI.cpp index 7c013ddefd..f950025395 100644 --- a/src/API/SLAPI.cpp +++ b/src/API/SLAPI.cpp @@ -51,11 +51,11 @@ namespace SURELOG { void SLsetWaiver(const char* messageId, const char* fileName, uint32_t line, const char* objectName) { - if (fileName == 0 && line == 0 && objectName == 0) { + if (fileName == nullptr && line == 0 && objectName == nullptr) { Waiver::setWaiver(messageId, "", 0, ""); - } else if (line == 0 && objectName == 0) { + } else if (line == 0 && objectName == nullptr) { Waiver::setWaiver(messageId, "", 0, fileName); - } else if (objectName == 0) { + } else if (objectName == nullptr) { Waiver::setWaiver(messageId, fileName, line, ""); } else { Waiver::setWaiver(messageId, fileName, line, objectName); @@ -135,8 +135,8 @@ void SLaddErrorContext(SV3_1aPythonListener* prog, const char* messageId, const char* objectName, bool printColumn) { #ifdef SURELOG_WITH_PYTHON - SV3_1aPythonListener* listener = (SV3_1aPythonListener*)prog; - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + SV3_1aPythonListener* listener = prog; + antlr4::ParserRuleContext* ctx = context; ErrorContainer* errors = listener->getPythonListen()->getCompileSourceFile()->getErrorContainer(); ParseUtils::LineColumn lineCol = @@ -164,9 +164,9 @@ void SLaddMLErrorContext(SV3_1aPythonListener* prog, const char* messageId, const char* objectName1, const char* objectName2, bool printColumn) { #ifdef SURELOG_WITH_PYTHON - SV3_1aPythonListener* listener = (SV3_1aPythonListener*)prog; - antlr4::ParserRuleContext* ctx1 = (antlr4::ParserRuleContext*)context1; - antlr4::ParserRuleContext* ctx2 = (antlr4::ParserRuleContext*)context2; + SV3_1aPythonListener* listener = prog; + antlr4::ParserRuleContext* ctx1 = context1; + antlr4::ParserRuleContext* ctx2 = context2; ErrorContainer* errors = listener->getPythonListen()->getCompileSourceFile()->getErrorContainer(); ParseUtils::LineColumn lineCol1 = @@ -203,7 +203,7 @@ std::string SLgetFile(SV3_1aPythonListener* prog, antlr4::ParserRuleContext* context) { #ifdef SURELOG_WITH_PYTHON FileSystem* const fileSystem = FileSystem::getInstance(); - SV3_1aPythonListener* listener = (SV3_1aPythonListener*)prog; + SV3_1aPythonListener* listener = prog; ParseFile* parseFile = listener->getPythonListen()->getParseFile(); return std::string(fileSystem->toPath(parseFile->getFileId(0))); #else @@ -215,8 +215,8 @@ std::string SLgetFile(SV3_1aPythonListener* prog, int32_t SLgetLine(SV3_1aPythonListener* prog, antlr4::ParserRuleContext* context) { #ifdef SURELOG_WITH_PYTHON - SV3_1aPythonListener* listener = (SV3_1aPythonListener*)prog; - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + SV3_1aPythonListener* listener = prog; + antlr4::ParserRuleContext* ctx = context; ParseUtils::LineColumn lineCol = ParseUtils::getLineColumn(listener->getTokenStream(), ctx); return lineCol.first; @@ -229,8 +229,8 @@ int32_t SLgetLine(SV3_1aPythonListener* prog, int32_t SLgetColumn(SV3_1aPythonListener* prog, antlr4::ParserRuleContext* context) { #ifdef SURELOG_WITH_PYTHON - SV3_1aPythonListener* listener = (SV3_1aPythonListener*)prog; - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + SV3_1aPythonListener* listener = prog; + antlr4::ParserRuleContext* ctx = context; ParseUtils::LineColumn lineCol = ParseUtils::getLineColumn(listener->getTokenStream(), ctx); return lineCol.second; @@ -242,7 +242,7 @@ int32_t SLgetColumn(SV3_1aPythonListener* prog, std::string SLgetText(SV3_1aPythonListener* /*prog*/, antlr4::ParserRuleContext* context) { - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + antlr4::ParserRuleContext* ctx = context; std::vector tokens = ParseUtils::getFlatTokenList(ctx); std::string text; for (auto token : tokens) { @@ -253,7 +253,7 @@ std::string SLgetText(SV3_1aPythonListener* /*prog*/, std::vector SLgetTokens(SV3_1aPythonListener* /*prog*/, antlr4::ParserRuleContext* context) { - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + antlr4::ParserRuleContext* ctx = context; std::vector tokens = ParseUtils::getFlatTokenList(ctx); std::vector body_tokens; body_tokens.reserve(tokens.size()); @@ -265,13 +265,13 @@ std::vector SLgetTokens(SV3_1aPythonListener* /*prog*/, antlr4::ParserRuleContext* SLgetParentContext( SV3_1aPythonListener* /*prog*/, antlr4::ParserRuleContext* context) { - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + antlr4::ParserRuleContext* ctx = context; return (antlr4::ParserRuleContext*)ctx->parent; } std::vector SLgetChildrenContext( SV3_1aPythonListener* /*prog*/, antlr4::ParserRuleContext* context) { - antlr4::ParserRuleContext* ctx = (antlr4::ParserRuleContext*)context; + antlr4::ParserRuleContext* ctx = context; std::vector children; for (antlr4::tree::ParseTree* child : ctx->children) { @@ -426,7 +426,7 @@ uint32_t SLgetnTopModuleInstance(Design* design) { } ModuleDefinition* SLgetModuleDefinition(Design* design, uint32_t index) { - if (!design) return 0; + if (!design) return nullptr; ModuleNameModuleDefinitionMap::iterator itr = design->getModuleDefinitions().begin(); for (uint32_t i = 0; i < index; i++) itr++; @@ -434,7 +434,7 @@ ModuleDefinition* SLgetModuleDefinition(Design* design, uint32_t index) { } Program* SLgetProgramDefinition(Design* design, uint32_t index) { - if (!design) return 0; + if (!design) return nullptr; ProgramNameProgramDefinitionMap::iterator itr = design->getProgramDefinitions().begin(); for (uint32_t i = 0; i < index; i++) itr++; @@ -442,7 +442,7 @@ Program* SLgetProgramDefinition(Design* design, uint32_t index) { } Package* SLgetPackageDefinition(Design* design, uint32_t index) { - if (!design) return 0; + if (!design) return nullptr; PackageNamePackageDefinitionMultiMap::iterator itr = design->getPackageDefinitions().begin(); for (uint32_t i = 0; i < index; i++) itr++; @@ -450,7 +450,7 @@ Package* SLgetPackageDefinition(Design* design, uint32_t index) { } ClassDefinition* SLgetClassDefinition(Design* design, uint32_t index) { - if (!design) return 0; + if (!design) return nullptr; ClassNameClassDefinitionMap::iterator itr = design->getUniqueClassDefinitions().begin(); for (uint32_t i = 0; i < index; i++) itr++; @@ -458,7 +458,7 @@ ClassDefinition* SLgetClassDefinition(Design* design, uint32_t index) { } ModuleInstance* SLgetTopModuleInstance(Design* design, uint32_t index) { - if (!design) return 0; + if (!design) return nullptr; return design->getTopLevelModuleInstances()[index]; } diff --git a/src/API/SV3_1aPythonListener.cpp b/src/API/SV3_1aPythonListener.cpp index 2697e5b06e..452a77f4ec 100644 --- a/src/API/SV3_1aPythonListener.cpp +++ b/src/API/SV3_1aPythonListener.cpp @@ -38,13 +38,15 @@ SV3_1aPythonListener::SV3_1aPythonListener(PythonListen* pl, m_tokens(tokens), m_lineOffset(lineOffset) {} -SV3_1aPythonListener::SV3_1aPythonListener(const SV3_1aPythonListener& orig) {} +SV3_1aPythonListener::SV3_1aPythonListener(const SV3_1aPythonListener& orig) = + default; -SV3_1aPythonListener::~SV3_1aPythonListener() {} +SV3_1aPythonListener::~SV3_1aPythonListener() = default; void SV3_1aPythonListener::logError(ErrorDefinition::ErrorType error, antlr4::ParserRuleContext* ctx, - std::string object, bool printColumn) { + const std::string& object, + bool printColumn) { ParseUtils::LineColumn lineCol = ParseUtils::getLineColumn(getTokenStream(), ctx); diff --git a/src/API/Surelog.cpp b/src/API/Surelog.cpp index 6c000b480c..c1e5582ebc 100644 --- a/src/API/Surelog.cpp +++ b/src/API/Surelog.cpp @@ -53,7 +53,7 @@ void shutdown_compiler(scompiler* the_compiler) { } vpiHandle get_uhdm_design(scompiler* compiler) { - vpiHandle design_handle = 0; + vpiHandle design_handle = nullptr; Compiler* the_compiler = (Compiler*)compiler; if (the_compiler) { design_handle = the_compiler->getUhdmDesign(); diff --git a/src/CommandLine/CommandLineParser.cpp b/src/CommandLine/CommandLineParser.cpp index 0d8cf400c4..78cf950580 100644 --- a/src/CommandLine/CommandLineParser.cpp +++ b/src/CommandLine/CommandLineParser.cpp @@ -307,7 +307,7 @@ void CommandLineParser::withPython() { } std::string CommandLineParser::currentDateTime() { - time_t now = time(0); + time_t now = time(nullptr); struct tm tstruct = *localtime(&now); // Visit http://en.cppreference.com/w/cpp/chrono/c/strftime // for more information about date/time format diff --git a/src/Common/PlatformFileSystem_test.cpp b/src/Common/PlatformFileSystem_test.cpp index 57704c41b1..7cef6c2aeb 100644 --- a/src/Common/PlatformFileSystem_test.cpp +++ b/src/Common/PlatformFileSystem_test.cpp @@ -544,9 +544,9 @@ TEST(PlatformFileSystemTest, WorkingDirs_Ideal) { // but is a prototype to showcase the potential of FileSystem abstraction. class InMemoryFileSystem : public TestFileSystem { public: - typedef std::map Files; - typedef std::set Directories; - typedef std::map OpenOutputFiles; + using Files = std::map; + using Directories = std::set; + using OpenOutputFiles = std::map; explicit InMemoryFileSystem(const fs::path &cwd) : TestFileSystem(cwd) { FileSystem::setInstance(this); diff --git a/src/Design/DummyType.cpp b/src/Design/DummyType.cpp index fe1bf82991..1474af3830 100644 --- a/src/Design/DummyType.cpp +++ b/src/Design/DummyType.cpp @@ -35,5 +35,5 @@ DummyType::DummyType(const FileContent* fC, NodeId nameId, NodeId structId) m_category = DataType::Category::DUMMY; } -DummyType::~DummyType() {} +DummyType::~DummyType() = default; } // namespace SURELOG diff --git a/src/Design/Netlist.cpp b/src/Design/Netlist.cpp index dfe4698733..8673c75d16 100644 --- a/src/Design/Netlist.cpp +++ b/src/Design/Netlist.cpp @@ -25,7 +25,8 @@ namespace SURELOG { -Netlist::~Netlist() { +Netlist::~Netlist() { // NOLINT(modernize-use-equals-default) + // Why are these not deleted ? /* delete m_interfaces; delete m_interface_arrays; diff --git a/src/Design/Parameter.cpp b/src/Design/Parameter.cpp index 6a77121170..e04e655a9a 100644 --- a/src/Design/Parameter.cpp +++ b/src/Design/Parameter.cpp @@ -39,7 +39,7 @@ Parameter::Parameter(const FileContent* fC, NodeId nodeId, m_category = DataType::Category::PARAMETER; } -Parameter::~Parameter() {} +Parameter::~Parameter() = default; VObjectType Parameter::getType() const { return getFileContent()->Type(m_ntype); diff --git a/src/DesignCompile/CompileClass.cpp b/src/DesignCompile/CompileClass.cpp index 4742ca65c2..7087bc3379 100644 --- a/src/DesignCompile/CompileClass.cpp +++ b/src/DesignCompile/CompileClass.cpp @@ -77,7 +77,7 @@ bool CompileClass::compile() { } if (!names.empty()) { uint32_t index = names.size() - 1; - while (1) { + while (true) { fullName += names[index]; if (index > 0) fullName += "::"; if (index == 0) break; diff --git a/src/DesignCompile/CompileExpression.cpp b/src/DesignCompile/CompileExpression.cpp index 4362489dec..27ba8e13d3 100644 --- a/src/DesignCompile/CompileExpression.cpp +++ b/src/DesignCompile/CompileExpression.cpp @@ -207,7 +207,7 @@ any *CompileHelper::getObject(std::string_view name, DesignComponent *component, const std::string_view pname = p->Lhs()->VpiName(); if (pname == name) { if (substituteAssignedValue(p->Rhs(), compileDesign)) { - result = (any *)p->Rhs(); + result = p->Rhs(); break; } } @@ -253,7 +253,7 @@ any *CompileHelper::getObject(std::string_view name, DesignComponent *component, const std::string_view pname = p->Lhs()->VpiName(); if (pname == name) { if (substituteAssignedValue(p->Rhs(), compileDesign)) { - result = (any *)p->Rhs(); + result = p->Rhs(); break; } } @@ -276,7 +276,7 @@ any *CompileHelper::getObject(std::string_view name, DesignComponent *component, result = getObject(refname, component, compileDesign, instance, pexpr); if (result) { if (UHDM::param_assign *passign = any_cast(result)) { - result = (any *)passign->Rhs(); + result = passign->Rhs(); } } } @@ -932,8 +932,7 @@ any *CompileHelper::getValue(std::string_view name, DesignComponent *component, } ElaboratorContext elaboratorContext(&s, false, true); - result = - UHDM::clone_tree((any *)param->Rhs(), &elaboratorContext); + result = UHDM::clone_tree(param->Rhs(), &elaboratorContext); break; } } @@ -1035,8 +1034,7 @@ any *CompileHelper::getValue(std::string_view name, DesignComponent *component, } ElaboratorContext elaboratorContext(&s, false, true); - result = - UHDM::clone_tree((any *)param->Rhs(), &elaboratorContext); + result = UHDM::clone_tree(param->Rhs(), &elaboratorContext); if (result != nullptr) result->VpiParent(param); break; } @@ -2432,7 +2430,7 @@ UHDM::any *CompileHelper::compileExpression( if (substituteAssignedValue(param->Rhs(), compileDesign)) { ElaboratorContext elaboratorContext(&s, false, true); - result = UHDM::clone_tree((any *)param->Rhs(), + result = UHDM::clone_tree(param->Rhs(), &elaboratorContext); result->VpiParent(pexpr); fC->populateCoreMembers(child, child, result); @@ -2480,7 +2478,7 @@ UHDM::any *CompileHelper::compileExpression( if (substituteAssignedValue(param->Rhs(), compileDesign)) { ElaboratorContext elaboratorContext(&s, false, true); - result = UHDM::clone_tree((any *)param->Rhs(), + result = UHDM::clone_tree(param->Rhs(), &elaboratorContext); fC->populateCoreMembers(child, child, result); } @@ -2590,10 +2588,9 @@ UHDM::any *CompileHelper::compileExpression( compileDesign)) { ElaboratorContext elaboratorContext(&s, false, true); - result = UHDM::clone_tree((any *)param_ass->Rhs(), + result = UHDM::clone_tree(param_ass->Rhs(), &elaboratorContext); - result->VpiParent( - const_cast(param_ass)); + result->VpiParent(param_ass); fC->populateCoreMembers(child, child, result); typespec *tps = nullptr; const any *lhs = param_ass->Lhs(); @@ -2659,10 +2656,9 @@ UHDM::any *CompileHelper::compileExpression( } else { ElaboratorContext elaboratorContext(&s, false, true); - result = UHDM::clone_tree((any *)param_ass->Rhs(), + result = UHDM::clone_tree(param_ass->Rhs(), &elaboratorContext); - result->VpiParent( - const_cast(param_ass)); + result->VpiParent(param_ass); fC->populateCoreMembers(child, child, result); } typespec *tps = nullptr; @@ -3622,7 +3618,7 @@ bool CompileHelper::errorOnNegativeConstant(DesignComponent *component, for (auto ps : *inst->getNetlist()->param_assigns()) { std::cout << ps->Lhs()->VpiName() << " = " << "\n"; - decompile((any *)ps->Rhs()); + decompile(ps->Rhs()); } } inst = inst->getParent(); @@ -5146,7 +5142,7 @@ UHDM::any *CompileHelper::compileComplexFuncCall( path->Root_value(expval->Low_conn()); } else if (UHDM::param_assign *passign = any_cast(rootValue)) { - path->Root_value((any *)passign->Rhs()); + path->Root_value(passign->Rhs()); const any *param = passign->Lhs(); typespec *tps = nullptr; if (param->UhdmType() == uhdmparameter) { @@ -5607,8 +5603,8 @@ void CompileHelper::reorderAssignmentPattern( if (ranges) { if (level < ranges->size()) { range *r = ranges->at(level); - expr *lr = (expr *)r->Left_expr(); - expr *rr = (expr *)r->Right_expr(); + expr *lr = r->Left_expr(); + expr *rr = r->Right_expr(); bool invalidValue = false; UHDM::ExprEval eval; lr = reduceExpr(lr, invalidValue, mod, compileDesign, instance, diff --git a/src/DesignCompile/CompileHelper.cpp b/src/DesignCompile/CompileHelper.cpp index e7a4042454..6759d4b787 100644 --- a/src/DesignCompile/CompileHelper.cpp +++ b/src/DesignCompile/CompileHelper.cpp @@ -3324,15 +3324,15 @@ UHDM::any* CompileHelper::defaultPatternAssignment(const UHDM::typespec* tps, bool invalidValue = false; UHDM::ExprEval eval; expr* lexp = reduceExpr( - (expr*)r->Left_expr(), invalidValue, component, compileDesign, + r->Left_expr(), invalidValue, component, compileDesign, instance, fileSystem->toPathId( r->VpiFile(), compileDesign->getCompiler()->getSymbolTable()), r->VpiLineNo(), nullptr); expr* rexp = reduceExpr( - (expr*)r->Right_expr(), invalidValue, component, - compileDesign, instance, + r->Right_expr(), invalidValue, component, compileDesign, + instance, fileSystem->toPathId( r->VpiFile(), compileDesign->getCompiler()->getSymbolTable()), @@ -3982,7 +3982,7 @@ UHDM::constant* CompileHelper::adjustSize(const UHDM::typespec* ts, if (signedLhs) { const std::string res = twosComplement(v); // Convert to int32_t - val = std::strtoll(res.c_str(), 0, 2); + val = std::strtoll(res.c_str(), nullptr, 2); val = -val; } else { if (size > orig_size) { @@ -3991,7 +3991,7 @@ UHDM::constant* CompileHelper::adjustSize(const UHDM::typespec* ts, } orig_size = size; } - val = std::strtoll(v.c_str(), 0, 2); + val = std::strtoll(v.c_str(), nullptr, 2); } if (uniquify) { UHDM::ElaboratorContext elaboratorContext(&s, false, true); @@ -4983,7 +4983,7 @@ UHDM::expr* CompileHelper::expandPatternAssignment(const typespec* tps, uint64_t patternSize = 0; UHDM::ExprEval eval(true); - rhs = eval.flattenPatternAssignments(s, tps, (UHDM::expr*)rhs); + rhs = eval.flattenPatternAssignments(s, tps, rhs); std::vector values(size, 0); if (rhs->UhdmType() == uhdmoperation) { @@ -5014,8 +5014,8 @@ UHDM::expr* CompileHelper::expandPatternAssignment(const typespec* tps, defaultval = eval.get_value( invalidValue, reduceExpr( - (any*)tp->Pattern(), invalidValue, component, - compileDesign, instance, + tp->Pattern(), invalidValue, component, compileDesign, + instance, fileSystem->toPathId( tp->Pattern()->VpiFile(), compileDesign->getCompiler()->getSymbolTable()), @@ -5089,8 +5089,8 @@ UHDM::expr* CompileHelper::expandPatternAssignment(const typespec* tps, UHDM::ExprEval eval; val = eval.get_value( invalidValue, - reduceExpr((any*)tp->Pattern(), invalidValue, - component, compileDesign, instance, + reduceExpr(tp->Pattern(), invalidValue, component, + compileDesign, instance, fileSystem->toPathId( tp->Pattern()->VpiFile(), compileDesign->getCompiler() diff --git a/src/DesignCompile/CompileStmt.cpp b/src/DesignCompile/CompileStmt.cpp index 318cd10c06..7caf277791 100644 --- a/src/DesignCompile/CompileStmt.cpp +++ b/src/DesignCompile/CompileStmt.cpp @@ -2077,8 +2077,7 @@ bool CompileHelper::compileTask(DesignComponent* component, } if (stmt_type == uhdmassignment) { assignment* stmt = (assignment*)st; - if (stmt->Rhs() == nullptr || - any_cast((expr*)stmt->Lhs())) { + if (stmt->Rhs() == nullptr || any_cast(stmt->Lhs())) { // Declaration VectorOfvariables* vars = task->Variables(); if (vars == nullptr) { @@ -2089,7 +2088,7 @@ bool CompileHelper::compileTask(DesignComponent* component, if (stmt->Rhs() != nullptr) { stmts->push_back(st); } else { - if (variables* var = any_cast((expr*)stmt->Lhs())) + if (variables* var = any_cast(stmt->Lhs())) var->VpiParent(begin); // s.Erase(stmt); } @@ -2124,8 +2123,7 @@ bool CompileHelper::compileTask(DesignComponent* component, param_assigns->push_back(pst); } else if (stmt_type == uhdmassignment) { assignment* stmt = (assignment*)st; - if (stmt->Rhs() == nullptr || - any_cast((expr*)stmt->Lhs())) { + if (stmt->Rhs() == nullptr || any_cast(stmt->Lhs())) { // Declaration VectorOfvariables* vars = task->Variables(); if (vars == nullptr) { @@ -2136,7 +2134,7 @@ bool CompileHelper::compileTask(DesignComponent* component, if (stmt->Rhs() != nullptr) { task->Stmt(st); } else { - if (variables* var = any_cast((expr*)stmt->Lhs())) + if (variables* var = any_cast(stmt->Lhs())) var->VpiParent(task); // s.Erase(stmt); } @@ -2496,8 +2494,7 @@ bool CompileHelper::compileFunction(DesignComponent* component, param_assigns->push_back(pst); } else if (stmt_type == uhdmassignment) { assignment* stmt = (assignment*)st; - if (stmt->Rhs() == nullptr || - any_cast((expr*)stmt->Lhs())) { + if (stmt->Rhs() == nullptr || any_cast(stmt->Lhs())) { // Declaration VectorOfvariables* vars = func->Variables(); if (vars == nullptr) { @@ -2508,7 +2505,7 @@ bool CompileHelper::compileFunction(DesignComponent* component, if (stmt->Rhs() != nullptr) { stmts->push_back(st); } else { - if (variables* var = any_cast((expr*)stmt->Lhs())) + if (variables* var = any_cast(stmt->Lhs())) var->VpiParent(begin); // s.Erase(stmt); } @@ -2543,8 +2540,7 @@ bool CompileHelper::compileFunction(DesignComponent* component, param_assigns->push_back(pst); } else if (stmt_type == uhdmassignment) { assignment* stmt = (assignment*)st; - if (stmt->Rhs() == nullptr || - any_cast((expr*)stmt->Lhs())) { + if (stmt->Rhs() == nullptr || any_cast(stmt->Lhs())) { // Declaration VectorOfvariables* vars = func->Variables(); if (vars == nullptr) { @@ -2555,7 +2551,7 @@ bool CompileHelper::compileFunction(DesignComponent* component, if (stmt->Rhs() != nullptr) { func->Stmt(st); } else { - if (variables* var = any_cast((expr*)stmt->Lhs())) + if (variables* var = any_cast(stmt->Lhs())) var->VpiParent(func); // s.Erase(stmt); } @@ -3038,7 +3034,7 @@ UHDM::any* CompileHelper::bindParameter(DesignComponent* component, if (netlist->param_assigns()) { for (param_assign* pass : *netlist->param_assigns()) { if (pass->Lhs()->VpiName() == name) { - return (any*)pass->Lhs(); + return pass->Lhs(); } } } diff --git a/src/DesignCompile/DesignElaboration.cpp b/src/DesignCompile/DesignElaboration.cpp index 1e73f198a0..0ac390c4eb 100644 --- a/src/DesignCompile/DesignElaboration.cpp +++ b/src/DesignCompile/DesignElaboration.cpp @@ -71,7 +71,7 @@ DesignElaboration::DesignElaboration(CompileDesign* compileDesign) m_exprBuilder.setDesign(m_compileDesign->getCompiler()->getDesign()); } -DesignElaboration::~DesignElaboration() {} +DesignElaboration::~DesignElaboration() = default; bool DesignElaboration::elaborate() { createBuiltinPrimitives_(); @@ -349,7 +349,7 @@ bool DesignElaboration::identifyTopModules_() { std::vector locations; - while (1) { + while (true) { const FileContent* fC2 = prevFileContent; NodeId nodeId2 = prevModuleDefinition->m_node; PathId fileId2 = fileSystem->copy(fC2->getFileId(nodeId2), st); @@ -1289,7 +1289,7 @@ void DesignElaboration::elaborateInstance_( } else { // Else branch if (!tmp) continue; bool activeBranch = false; - while (1) { + while (true) { if (tmp) { tmp = fC->Sibling(tmp); // Else if (!tmp) break; diff --git a/src/DesignCompile/ElaborationStep.cpp b/src/DesignCompile/ElaborationStep.cpp index 123491c5f0..89c6ec836e 100644 --- a/src/DesignCompile/ElaborationStep.cpp +++ b/src/DesignCompile/ElaborationStep.cpp @@ -82,7 +82,7 @@ ElaborationStep::ElaborationStep(CompileDesign* compileDesign) m_errors = m_compileDesign->getCompiler()->getErrorContainer(); } -ElaborationStep::~ElaborationStep() {} +ElaborationStep::~ElaborationStep() = default; bool ElaborationStep::bindTypedefs_() { FileSystem* const fileSystem = FileSystem::getInstance(); @@ -2239,8 +2239,8 @@ any* ElaborationStep::makeVar_(DesignComponent* component, Signal* sig, obj->VpiParent(array_var); if ((array_var->Typespec() == nullptr) || associative) { VectorOfvariables* array_vars = array_var->Variables(); - array_vars->push_back((variables*)obj); - ((variables*)obj)->VpiName(""); + array_vars->push_back(obj); + (obj)->VpiName(""); } if (array_var->Typespec() == nullptr) { ref_typespec* tsRef = s.MakeRef_typespec(); @@ -2263,7 +2263,7 @@ any* ElaborationStep::makeVar_(DesignComponent* component, Signal* sig, } else if (obj->UhdmType() == uhdmlogic_var) { ((logic_var*)obj)->VpiName(signame); } - vars->push_back((variables*)obj); + vars->push_back(obj); } if (assignExp) { diff --git a/src/DesignCompile/NetlistElaboration.cpp b/src/DesignCompile/NetlistElaboration.cpp index cab04719ba..ab43ccef51 100644 --- a/src/DesignCompile/NetlistElaboration.cpp +++ b/src/DesignCompile/NetlistElaboration.cpp @@ -76,7 +76,7 @@ NetlistElaboration::NetlistElaboration(CompileDesign* compileDesign) m_errors = m_compileDesign->getCompiler()->getErrorContainer(); } -NetlistElaboration::~NetlistElaboration() {} +NetlistElaboration::~NetlistElaboration() = default; bool NetlistElaboration::elaboratePackages() { Design* design = m_compileDesign->getCompiler()->getDesign(); @@ -222,7 +222,7 @@ bool NetlistElaboration::elab_parameters_(ModuleInstance* instance, pclone->VpiParent((any*)mod_assign->VpiParent()); pclone->VpiOverriden(instance->isOverridenParam(paramName)); const any* lhs = pclone->Lhs(); - any* rhs = (any*)pclone->Rhs(); + any* rhs = pclone->Rhs(); if (complexVal) { rhs = UHDM::clone_tree(complexVal, &elaboratorContext); rhs->VpiParent(pclone); @@ -287,7 +287,7 @@ bool NetlistElaboration::elab_parameters_(ModuleInstance* instance, inst_assign->VpiColumnNo(mod_assign->VpiColumnNo()); inst_assign->VpiEndLineNo(mod_assign->VpiEndLineNo()); inst_assign->VpiEndColumnNo(mod_assign->VpiEndColumnNo()); - inst_assign->Lhs((any*)mod_assign->Lhs()); + inst_assign->Lhs(mod_assign->Lhs()); bool overriden = false; for (Parameter* tpm : @@ -2926,7 +2926,7 @@ any* NetlistElaboration::bind_net_(ModuleInstance* instance, if (ios) { for (io_decl* decl : *ios) { if (decl->VpiName() == subname) { - return (any*)decl->Expr(); + return decl->Expr(); } } } diff --git a/src/DesignCompile/TestbenchElaboration.cpp b/src/DesignCompile/TestbenchElaboration.cpp index e032b9a191..0b6362186f 100644 --- a/src/DesignCompile/TestbenchElaboration.cpp +++ b/src/DesignCompile/TestbenchElaboration.cpp @@ -181,7 +181,7 @@ bool TestbenchElaboration::checkForMultipleDefinition_() { std::vector locations; - while (1) { + while (true) { const FileContent* fC2 = prevClassDefinition->getFileContents()[0]; NodeId nodeId2 = prevClassDefinition->getNodeIds()[0]; PathId fileId2 = fileSystem->copy(fC2->getFileId(nodeId2), symbols); diff --git a/src/DesignCompile/UhdmWriter.cpp b/src/DesignCompile/UhdmWriter.cpp index 056ffe04e8..966519a463 100644 --- a/src/DesignCompile/UhdmWriter.cpp +++ b/src/DesignCompile/UhdmWriter.cpp @@ -1029,11 +1029,11 @@ class ReInstanceTypespec : public VpiListener { any* object = (any*)cobject; const instance* inst = nullptr; if (typespec* tps = any_cast(object)) { - inst = (instance*)tps->Instance(); + inst = tps->Instance(); } else if (function* tps = any_cast(object)) { - inst = (instance*)tps->Instance(); + inst = tps->Instance(); } else if (task* tps = any_cast(object)) { - inst = (instance*)tps->Instance(); + inst = tps->Instance(); } if (inst) { const std::string_view name = inst->VpiName(); @@ -1973,7 +1973,7 @@ bool UhdmWriter::writeElabProgram(Serializer& s, ModuleInstance* instance, class DetectUnsizedConstant final : public VpiListener { public: - DetectUnsizedConstant() {} + DetectUnsizedConstant() = default; bool unsizedDetected() { return unsized_; } private: @@ -3698,8 +3698,7 @@ void UhdmWriter::lateBinding(Serializer& s, DesignComponent* mod, scope* m) { if (lhs->VpiName() == name) { // Do not bind blindly here, let the uhdmelab do this correctly // Unless we are in a package - if (m && m->UhdmType() == uhdmpackage) - ref->Actual_group((any*)p->Rhs()); + if (m && m->UhdmType() == uhdmpackage) ref->Actual_group(p->Rhs()); isParam = true; break; } @@ -4704,7 +4703,7 @@ vpiHandle UhdmWriter::write(PathId uhdmFileId) { } } - vpiHandle designHandle = 0; + vpiHandle designHandle = nullptr; std::vector designs; design* d = nullptr; if (m_design) { diff --git a/src/Expression/ExprBuilder.cpp b/src/Expression/ExprBuilder.cpp index 7605561fd4..908de03b37 100644 --- a/src/Expression/ExprBuilder.cpp +++ b/src/Expression/ExprBuilder.cpp @@ -60,7 +60,7 @@ Value* ExprBuilder::clone(Value* val) { // Often, there are assignments to muteErrors here, that are never read. // It seems like there is a (future?) intention here. So for now, disable // warnings from clang-tidy. -// TODO(Alain): remove NOLINTBEGIN, run .github/bin/run-clang-tidy.sh +// TODO(Alain): remove N0LINTBEGIN, run .github/bin/run-clang-tidy.sh // and fix the intended places. // // NOLINTBEGIN(*.DeadStores) diff --git a/src/Expression/Value.cpp b/src/Expression/Value.cpp index c844f3eb88..4445815d63 100644 --- a/src/Expression/Value.cpp +++ b/src/Expression/Value.cpp @@ -40,11 +40,11 @@ uint32_t Value::nbWords_(uint32_t size) { return nb; } -SValue::~SValue() {} +SValue::~SValue() = default; LValue::~LValue() { delete[] m_valueArray; } -StValue::~StValue() {} +StValue::~StValue() = default; bool LValue::operator<(const Value& rhs) const { if (!isValid() || !rhs.isValid()) return false; diff --git a/src/SourceCompile/Compiler.cpp b/src/SourceCompile/Compiler.cpp index 2f03ffba06..cf369763ae 100644 --- a/src/SourceCompile/Compiler.cpp +++ b/src/SourceCompile/Compiler.cpp @@ -74,7 +74,7 @@ Compiler::Compiler(CommandLineParser* commandLineParser, ErrorContainer* errors, m_librarySet(new LibrarySet()), m_configSet(new ConfigSet()), m_design(new Design(getErrorContainer(), m_librarySet, m_configSet)), - m_uhdmDesign(0), + m_uhdmDesign(nullptr), m_compileDesign(nullptr) { #ifdef USETBB if (getCommandLineParser()->useTbb() && @@ -92,7 +92,7 @@ Compiler::Compiler(CommandLineParser* commandLineParser, ErrorContainer* errors, m_librarySet(new LibrarySet()), m_configSet(new ConfigSet()), m_design(new Design(getErrorContainer(), m_librarySet, m_configSet)), - m_uhdmDesign(0), + m_uhdmDesign(nullptr), m_text(text), m_compileDesign(nullptr) {} diff --git a/src/SourceCompile/ParseFile.cpp b/src/SourceCompile/ParseFile.cpp index 2c041c6cc8..f6e097b188 100644 --- a/src/SourceCompile/ParseFile.cpp +++ b/src/SourceCompile/ParseFile.cpp @@ -171,7 +171,7 @@ void ParseFile::buildLineInfoCache_() { bool inRange = false; uint32_t indexOpeningRange = 0; uint32_t index = infos.size() - 1; - while (1) { + while (true) { if ((lineItr >= infos[index].m_originalStartLine) && (infos[index].m_action == IncludeFileInfo::Action::POP)) { fileInfoCache[lineItr] = infos[index].m_sectionFileId; diff --git a/src/SourceCompile/ParserHarness.cpp b/src/SourceCompile/ParserHarness.cpp index b606545400..823b1bdab4 100644 --- a/src/SourceCompile/ParserHarness.cpp +++ b/src/SourceCompile/ParserHarness.cpp @@ -63,8 +63,8 @@ std::unique_ptr ParserHarness::parse(std::string_view content) { m_h->csf = std::make_unique( BadPathId, m_h->clp.get(), m_h->errors.get(), m_h->compiler.get(), m_h->symbols.get(), m_h->unit.get(), m_h->lib.get()); - m_h->pf.reset( - new ParseFile(content, m_h->csf.get(), m_h->unit.get(), m_h->lib.get())); + m_h->pf = std::make_unique(content, m_h->csf.get(), + m_h->unit.get(), m_h->lib.get()); std::unique_ptr file_content_result( new FileContent(BadPathId, m_h->lib.get(), m_h->symbols.get(), m_h->errors.get(), nullptr, BadPathId)); diff --git a/src/SourceCompile/PreprocessFile.cpp b/src/SourceCompile/PreprocessFile.cpp index 4066918bfd..c70b80a39e 100644 --- a/src/SourceCompile/PreprocessFile.cpp +++ b/src/SourceCompile/PreprocessFile.cpp @@ -1195,7 +1195,7 @@ PathId PreprocessFile::getFileId(uint32_t line) const { } } else { uint32_t index = size - 1; - while (1) { + while (true) { if (line >= m_lineTranslationVec[index].m_originalLine) { return (m_lineTranslationVec[index].m_pretendFileId); } @@ -1215,7 +1215,7 @@ uint32_t PreprocessFile::getLineNb(uint32_t line) { return (m_macroInfo->m_startLine + line - 1); } else if (!m_lineTranslationVec.empty()) { uint32_t index = m_lineTranslationVec.size() - 1; - while (1) { + while (true) { if (line >= m_lineTranslationVec[index].m_originalLine) { return (m_lineTranslationVec[index].m_pretendLine + (line - m_lineTranslationVec[index].m_originalLine)); diff --git a/src/SourceCompile/PythonListen.cpp b/src/SourceCompile/PythonListen.cpp index 64b25c31fa..a3ef408081 100644 --- a/src/SourceCompile/PythonListen.cpp +++ b/src/SourceCompile/PythonListen.cpp @@ -37,7 +37,7 @@ PythonListen::PythonListen(ParseFile* parse, m_compileSourceFile(compileSourceFile), m_usingCachedVersion(false) {} -PythonListen::~PythonListen() {} +PythonListen::~PythonListen() = default; void PythonListen::addError(Error& error) { getCompileSourceFile()->getErrorContainer()->addError(error); @@ -51,8 +51,8 @@ bool PythonListen::listen() { } // This is either a parent Parser object of this Parser object has no parent - if ((m_parse->m_children.size() != 0) || (m_parse->m_parent == nullptr)) { - if ((m_parse->m_parent == nullptr) && (m_parse->m_children.size() == 0)) { + if ((!m_parse->m_children.empty()) || (m_parse->m_parent == nullptr)) { + if ((m_parse->m_parent == nullptr) && (m_parse->m_children.empty())) { SV3_1aPythonListener* pythonListener = new SV3_1aPythonListener(this, m_compileSourceFile->getPythonInterp(), m_parse->m_antlrParserHandler->m_tokens, 0); @@ -61,20 +61,18 @@ bool PythonListen::listen() { pythonListener, m_parse->m_antlrParserHandler->m_tree); } - if (m_parse->m_children.size() != 0) { - for (uint32_t i = 0; i < m_parse->m_children.size(); i++) { - if (m_parse->m_children[i]->m_antlrParserHandler) { + if (!m_parse->m_children.empty()) { + for (const ParseFile* child : m_parse->m_children) { + if (child->m_antlrParserHandler) { // Only visit the chunks that got re-parsed // TODO: Incrementally regenerate the FileContent SV3_1aPythonListener* pythonListener = new SV3_1aPythonListener( this, m_compileSourceFile->getPythonInterp(), - m_parse->m_children[i]->m_antlrParserHandler->m_tokens, - m_parse->m_children[i]->m_offsetLine); + child->m_antlrParserHandler->m_tokens, child->m_offsetLine); m_pythonListeners.push_back(pythonListener); antlr4::tree::ParseTreeWalker::DEFAULT.walk( - pythonListener, - m_parse->m_children[i]->m_antlrParserHandler->m_tree); + pythonListener, child->m_antlrParserHandler->m_tree); } } } diff --git a/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp b/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp index d2b0b699c9..4b55bfcf0e 100644 --- a/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp +++ b/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp @@ -406,7 +406,7 @@ void SV3_1aPpTreeShapeListener::enterSimple_no_args_macro_definition( } if (m_reservedMacroNamesSet.find(macroName) != m_reservedMacroNamesSet.end()) { - logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, 0); + logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, false); } m_inMacroDefinitionParsing = true; SV3_1aPpParser::Simple_macro_definition_bodyContext *cBody = @@ -849,7 +849,7 @@ void SV3_1aPpTreeShapeListener::enterDefine_directive( } if (m_reservedMacroNamesSet.find(macroName) != m_reservedMacroNamesSet.end()) { - logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, 0); + logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, false); } } } @@ -1053,7 +1053,7 @@ void SV3_1aPpTreeShapeListener::enterUndef_directive( } if (m_reservedMacroNamesSet.find(macroName) != m_reservedMacroNamesSet.end()) { - logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, 0); + logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, false); } if (m_pp->m_debugMacro) std::cout << "Undefining macro: " << macroName << std::endl; @@ -1454,7 +1454,7 @@ void SV3_1aPpTreeShapeListener::enterMultiline_no_args_macro_definition( } if (m_reservedMacroNamesSet.find(macroName) != m_reservedMacroNamesSet.end()) { - logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, 0); + logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, false); } antlr4::tree::TerminalNode *const identifier = ctx->Simple_identifier() ? ctx->Simple_identifier() @@ -1507,7 +1507,7 @@ void SV3_1aPpTreeShapeListener::enterMultiline_args_macro_definition( } if (m_reservedMacroNamesSet.find(macroName) != m_reservedMacroNamesSet.end()) { - logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, 0); + logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, false); } if (m_pp->m_debugMacro) std::cout << "Defining macro:" << macroName << std::endl; @@ -1559,7 +1559,7 @@ void SV3_1aPpTreeShapeListener::enterSimple_args_macro_definition( } if (m_reservedMacroNamesSet.find(macroName) != m_reservedMacroNamesSet.end()) { - logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, 0); + logError(ErrorDefinition::PP_MACRO_NAME_RESERVED, ctx, macroName, false); } if (m_pp->m_debugMacro) std::cout << "Defining macro:" << macroName << std::endl; diff --git a/src/SourceCompile/SV3_1aTreeShapeListener.cpp b/src/SourceCompile/SV3_1aTreeShapeListener.cpp index 60d0b0b61d..fe8e95f28c 100644 --- a/src/SourceCompile/SV3_1aTreeShapeListener.cpp +++ b/src/SourceCompile/SV3_1aTreeShapeListener.cpp @@ -646,7 +646,7 @@ SV3_1aTreeShapeListener::SV3_1aTreeShapeListener( ParseFile *pf, antlr4::CommonTokenStream *tokens, uint32_t lineOffset) : SV3_1aTreeShapeHelper::SV3_1aTreeShapeHelper(pf, tokens, lineOffset) {} -SV3_1aTreeShapeListener::~SV3_1aTreeShapeListener() {} +SV3_1aTreeShapeListener::~SV3_1aTreeShapeListener() = default; void SV3_1aTreeShapeListener::enterPackage_declaration( SV3_1aParser::Package_declarationContext *ctx) { diff --git a/src/Utils/NumUtils.cpp b/src/Utils/NumUtils.cpp index 81dae38cc2..9c7d4eff7b 100644 --- a/src/Utils/NumUtils.cpp +++ b/src/Utils/NumUtils.cpp @@ -88,10 +88,8 @@ std::string NumUtils::toBinary(int32_t size, uint64_t val) { uint64_t NumUtils::getMask(uint64_t wide) { uint64_t mask = 0; uint64_t sizeInBits = sizeof(mask) * 8; - mask = (wide >= sizeInBits) - ? ((uint64_t)-1) - : ((uint64_t)((uint64_t)(((uint64_t)1) << ((uint64_t)wide))) - - (uint64_t)1); + mask = (wide >= sizeInBits) ? ((uint64_t)-1) + : (((((uint64_t)1) << (wide))) - (uint64_t)1); return mask; } diff --git a/src/Utils/StringUtils.cpp b/src/Utils/StringUtils.cpp index 80922f3a83..7567182f26 100644 --- a/src/Utils/StringUtils.cpp +++ b/src/Utils/StringUtils.cpp @@ -293,7 +293,7 @@ std::vector StringUtils::splitLines(std::string_view text) { std::string StringUtils::removeComments(std::string_view text) { std::string result; char c1 = '\0'; - bool inComment = 0; + bool inComment = false; for (char c2 : text) { if ((c2 == '/') && (c1 == '/') && !inComment) { inComment = true; diff --git a/src/hellodesign.cpp b/src/hellodesign.cpp index ec8c1416f4..34aeb36e78 100644 --- a/src/hellodesign.cpp +++ b/src/hellodesign.cpp @@ -44,8 +44,8 @@ class DesignListener final : public UHDM::VpiListener { vpiHandle handle) final { std::string_view instName = object->VpiName(); m_flatTraversal = - (instName.empty()) && ((object->VpiParent() == 0) || - ((object->VpiParent() != 0) && + (instName.empty()) && ((object->VpiParent() == nullptr) || + ((object->VpiParent() != nullptr) && (object->VpiParent()->VpiType() != vpiModule))); if (m_flatTraversal) std::cout << "Entering Module Definition: " << object->VpiDefName() << " " diff --git a/src/hellouhdm.cpp b/src/hellouhdm.cpp index 0c1b7e1f08..7fa61fa655 100644 --- a/src/hellouhdm.cpp +++ b/src/hellouhdm.cpp @@ -54,7 +54,7 @@ int main(int argc, const char** argv) { // clp->setElabUhdm(true); // Request UHDM Uniquification/Elaboration bool success = clp->parseCommandLine(argc, argv); errors->printMessages(clp->muteStdout()); - vpiHandle the_design = 0; + vpiHandle the_design = nullptr; SURELOG::scompiler* compiler = nullptr; if (success && (!clp->help())) { compiler = SURELOG::start_compiler(clp); diff --git a/src/roundtrip.cpp b/src/roundtrip.cpp index 5f6767b137..e4e58c022f 100644 --- a/src/roundtrip.cpp +++ b/src/roundtrip.cpp @@ -56,25 +56,25 @@ static constexpr char kOverwriteMarker = '\0'; -typedef std::vector file_content_t; -typedef std::map design_content_t; - -typedef std::unordered_map op_type_names_t; -typedef std::unordered_map direction_names_t; -typedef std::unordered_map net_type_names_t; -typedef std::unordered_map - typespec_names_t; -typedef std::unordered_map - variable_type_names_t; -typedef std::unordered_map edge_names_t; -typedef std::unordered_map always_type_names_t; -typedef std::unordered_map case_type_names_t; -typedef std::unordered_map case_qualifier_names_t; - -typedef std::pair comparison_result_t; -typedef std::tuple - file_statistics_t; -typedef std::vector design_statistics_t; +using file_content_t = std::vector; +using design_content_t = std::map; + +using op_type_names_t = std::unordered_map; +using direction_names_t = std::unordered_map; +using net_type_names_t = std::unordered_map; +using typespec_names_t = + std::unordered_map; +using variable_type_names_t = + std::unordered_map; +using edge_names_t = std::unordered_map; +using always_type_names_t = std::unordered_map; +using case_type_names_t = std::unordered_map; +using case_qualifier_names_t = std::unordered_map; + +using comparison_result_t = std::pair; +using file_statistics_t = + std::tuple; +using design_statistics_t = std::vector; static std::regex re_strip_single_line_comments("//.+$"); static std::regex re_strip_block_comments("/\\*.*\\*/");