Merge branch 'master' into develop-v5

This commit is contained in:
Geza Lore 2022-09-23 11:21:12 +01:00
commit 3a8a314566
7 changed files with 179 additions and 160 deletions

View File

@ -95,18 +95,18 @@ public:
// cppcheck-suppress uninitVar // responsibility of each subclass // cppcheck-suppress uninitVar // responsibility of each subclass
VNType() = default; VNType() = default;
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VNType(en _e) constexpr VNType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VNType(int _e) explicit VNType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
inline bool operator==(const VNType& lhs, const VNType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VNType& lhs, const VNType& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const VNType& lhs, VNType::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VNType& lhs, VNType::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VNType::en lhs, const VNType& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VNType::en lhs, const VNType& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VNType& rhs) { return os << rhs.ascii(); } inline std::ostream& operator<<(std::ostream& os, const VNType& rhs) { return os << rhs.ascii(); }
//###################################################################### // ######################################################################
class VLifetime final { class VLifetime final {
public: public:
@ -119,23 +119,25 @@ public:
VLifetime() VLifetime()
: m_e{NONE} {} : m_e{NONE} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VLifetime(en _e) constexpr VLifetime(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VLifetime(int _e) explicit VLifetime(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool isNone() const { return m_e == NONE; } bool isNone() const { return m_e == NONE; }
bool isAutomatic() const { return m_e == AUTOMATIC; } bool isAutomatic() const { return m_e == AUTOMATIC; }
bool isStatic() const { return m_e == STATIC; } bool isStatic() const { return m_e == STATIC; }
}; };
inline bool operator==(const VLifetime& lhs, const VLifetime& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VLifetime& lhs, const VLifetime& rhs) {
inline bool operator==(const VLifetime& lhs, VLifetime::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VLifetime::en lhs, const VLifetime& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VLifetime& lhs, VLifetime::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VLifetime::en lhs, const VLifetime& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VLifetime& rhs) { inline std::ostream& operator<<(std::ostream& os, const VLifetime& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VAccess final { class VAccess final {
public: public:
@ -160,11 +162,11 @@ public:
VAccess() VAccess()
: m_e{READ} {} : m_e{READ} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VAccess(en _e) constexpr VAccess(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VAccess(int _e) explicit VAccess(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
VAccess invert() const { VAccess invert() const {
return (m_e == READWRITE) ? VAccess{m_e} : (m_e == WRITE ? VAccess{READ} : VAccess{WRITE}); return (m_e == READWRITE) ? VAccess{m_e} : (m_e == WRITE ? VAccess{READ} : VAccess{WRITE});
} }
@ -174,12 +176,12 @@ public:
bool isWriteOrRW() const { return m_e == WRITE || m_e == READWRITE; } bool isWriteOrRW() const { return m_e == WRITE || m_e == READWRITE; }
bool isRW() const { return m_e == READWRITE; } bool isRW() const { return m_e == READWRITE; }
}; };
inline bool operator==(const VAccess& lhs, const VAccess& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VAccess& lhs, const VAccess& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const VAccess& lhs, VAccess::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VAccess& lhs, VAccess::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VAccess::en lhs, const VAccess& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VAccess::en lhs, const VAccess& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VAccess& rhs) { return os << rhs.ascii(); } inline std::ostream& operator<<(std::ostream& os, const VAccess& rhs) { return os << rhs.ascii(); }
//###################################################################### // ######################################################################
class VSigning final { class VSigning final {
public: public:
@ -197,26 +199,26 @@ public:
VSigning() VSigning()
: m_e{UNSIGNED} {} : m_e{UNSIGNED} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VSigning(en _e) constexpr VSigning(en _e)
: m_e{_e} {} : m_e{_e} {}
static VSigning fromBool(bool isSigned) { // Factory method static VSigning fromBool(bool isSigned) { // Factory method
return isSigned ? VSigning{SIGNED} : VSigning{UNSIGNED}; return isSigned ? VSigning{SIGNED} : VSigning{UNSIGNED};
} }
explicit VSigning(int _e) explicit VSigning(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool isSigned() const { return m_e == SIGNED; } bool isSigned() const { return m_e == SIGNED; }
bool isNosign() const { return m_e == NOSIGN; } bool isNosign() const { return m_e == NOSIGN; }
// No isUnsigned() as it's ambiguous if NOSIGN should be included or not. // No isUnsigned() as it's ambiguous if NOSIGN should be included or not.
}; };
inline bool operator==(const VSigning& lhs, const VSigning& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VSigning& lhs, const VSigning& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const VSigning& lhs, VSigning::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VSigning& lhs, VSigning::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VSigning::en lhs, const VSigning& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VSigning::en lhs, const VSigning& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VSigning& rhs) { inline std::ostream& operator<<(std::ostream& os, const VSigning& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VPragmaType final { class VPragmaType final {
public: public:
@ -237,19 +239,19 @@ public:
VPragmaType() VPragmaType()
: m_e{ILLEGAL} {} : m_e{ILLEGAL} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VPragmaType(en _e) constexpr VPragmaType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VPragmaType(int _e) explicit VPragmaType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
inline bool operator==(const VPragmaType& lhs, const VPragmaType& rhs) { constexpr bool operator==(const VPragmaType& lhs, const VPragmaType& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VPragmaType& lhs, VPragmaType::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VPragmaType& lhs, VPragmaType::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VPragmaType::en lhs, const VPragmaType& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VPragmaType::en lhs, const VPragmaType& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VEdgeType final { class VEdgeType final {
public: public:
@ -333,17 +335,19 @@ public:
VEdgeType() VEdgeType()
: m_e{ET_ILLEGAL} {} : m_e{ET_ILLEGAL} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VEdgeType(en _e) constexpr VEdgeType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VEdgeType(int _e) explicit VEdgeType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
inline bool operator==(const VEdgeType& lhs, const VEdgeType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VEdgeType& lhs, const VEdgeType& rhs) {
inline bool operator==(const VEdgeType& lhs, VEdgeType::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VEdgeType::en lhs, const VEdgeType& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VEdgeType& lhs, VEdgeType::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VEdgeType::en lhs, const VEdgeType& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VAttrType final { class VAttrType final {
public: public:
@ -414,17 +418,19 @@ public:
VAttrType() VAttrType()
: m_e{ILLEGAL} {} : m_e{ILLEGAL} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VAttrType(en _e) constexpr VAttrType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VAttrType(int _e) explicit VAttrType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
inline bool operator==(const VAttrType& lhs, const VAttrType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VAttrType& lhs, const VAttrType& rhs) {
inline bool operator==(const VAttrType& lhs, VAttrType::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VAttrType::en lhs, const VAttrType& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VAttrType& lhs, VAttrType::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VAttrType::en lhs, const VAttrType& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VBasicDTypeKwd final { class VBasicDTypeKwd final {
public: public:
@ -523,11 +529,11 @@ public:
VBasicDTypeKwd() VBasicDTypeKwd()
: m_e{UNKNOWN} {} : m_e{UNKNOWN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VBasicDTypeKwd(en _e) constexpr VBasicDTypeKwd(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VBasicDTypeKwd(int _e) explicit VBasicDTypeKwd(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
int width() const { int width() const {
switch (m_e) { switch (m_e) {
case BIT: return 1; // scalar, can't bit extract unless ranged case BIT: return 1; // scalar, can't bit extract unless ranged
@ -612,13 +618,13 @@ public:
} }
} }
}; };
inline bool operator==(const VBasicDTypeKwd& lhs, const VBasicDTypeKwd& rhs) { constexpr bool operator==(const VBasicDTypeKwd& lhs, const VBasicDTypeKwd& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VBasicDTypeKwd& lhs, VBasicDTypeKwd::en rhs) { constexpr bool operator==(const VBasicDTypeKwd& lhs, VBasicDTypeKwd::en rhs) {
return lhs.m_e == rhs; return lhs.m_e == rhs;
} }
inline bool operator==(VBasicDTypeKwd::en lhs, const VBasicDTypeKwd& rhs) { constexpr bool operator==(VBasicDTypeKwd::en lhs, const VBasicDTypeKwd& rhs) {
return lhs == rhs.m_e; return lhs == rhs.m_e;
} }
@ -631,11 +637,11 @@ public:
VDirection() VDirection()
: m_e{NONE} {} : m_e{NONE} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VDirection(en _e) constexpr VDirection(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VDirection(int _e) explicit VDirection(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = {"NONE", "INPUT", "OUTPUT", "INOUT", "REF", "CONSTREF"}; static const char* const names[] = {"NONE", "INPUT", "OUTPUT", "INOUT", "REF", "CONSTREF"};
return names[m_e]; return names[m_e];
@ -659,14 +665,16 @@ public:
bool isWritable() const { return m_e == OUTPUT || m_e == INOUT || m_e == REF; } bool isWritable() const { return m_e == OUTPUT || m_e == INOUT || m_e == REF; }
bool isRefOrConstRef() const { return m_e == REF || m_e == CONSTREF; } bool isRefOrConstRef() const { return m_e == REF || m_e == CONSTREF; }
}; };
inline bool operator==(const VDirection& lhs, const VDirection& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VDirection& lhs, const VDirection& rhs) {
inline bool operator==(const VDirection& lhs, VDirection::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VDirection::en lhs, const VDirection& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VDirection& lhs, VDirection::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VDirection::en lhs, const VDirection& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VDirection& rhs) { inline std::ostream& operator<<(std::ostream& os, const VDirection& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
/// Boolean or unknown /// Boolean or unknown
class VBoolOrUnknown final { class VBoolOrUnknown final {
@ -677,7 +685,7 @@ public:
VBoolOrUnknown() VBoolOrUnknown()
: m_e{BU_UNKNOWN} {} : m_e{BU_UNKNOWN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VBoolOrUnknown(en _e) constexpr VBoolOrUnknown(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VBoolOrUnknown(int _e) explicit VBoolOrUnknown(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
@ -692,13 +700,13 @@ public:
bool unknown() const { return m_e == BU_UNKNOWN; } bool unknown() const { return m_e == BU_UNKNOWN; }
void setTrueOrFalse(bool flag) { m_e = flag ? BU_TRUE : BU_FALSE; } void setTrueOrFalse(bool flag) { m_e = flag ? BU_TRUE : BU_FALSE; }
}; };
inline bool operator==(const VBoolOrUnknown& lhs, const VBoolOrUnknown& rhs) { constexpr bool operator==(const VBoolOrUnknown& lhs, const VBoolOrUnknown& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VBoolOrUnknown& lhs, VBoolOrUnknown::en rhs) { constexpr bool operator==(const VBoolOrUnknown& lhs, VBoolOrUnknown::en rhs) {
return lhs.m_e == rhs; return lhs.m_e == rhs;
} }
inline bool operator==(VBoolOrUnknown::en lhs, const VBoolOrUnknown& rhs) { constexpr bool operator==(VBoolOrUnknown::en lhs, const VBoolOrUnknown& rhs) {
return lhs == rhs.m_e; return lhs == rhs.m_e;
} }
inline std::ostream& operator<<(std::ostream& os, const VBoolOrUnknown& rhs) { inline std::ostream& operator<<(std::ostream& os, const VBoolOrUnknown& rhs) {
@ -716,7 +724,7 @@ public:
VJoinType() VJoinType()
: m_e{JOIN} {} : m_e{JOIN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VJoinType(en _e) constexpr VJoinType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VJoinType(int _e) explicit VJoinType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
@ -732,14 +740,16 @@ public:
bool joinAny() const { return m_e == JOIN_ANY; } bool joinAny() const { return m_e == JOIN_ANY; }
bool joinNone() const { return m_e == JOIN_NONE; } bool joinNone() const { return m_e == JOIN_NONE; }
}; };
inline bool operator==(const VJoinType& lhs, const VJoinType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VJoinType& lhs, const VJoinType& rhs) {
inline bool operator==(const VJoinType& lhs, VJoinType::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VJoinType::en lhs, const VJoinType& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VJoinType& lhs, VJoinType::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VJoinType::en lhs, const VJoinType& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VJoinType& rhs) { inline std::ostream& operator<<(std::ostream& os, const VJoinType& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VVarType final { class VVarType final {
public: public:
@ -769,11 +779,11 @@ public:
VVarType() VVarType()
: m_e{UNKNOWN} {} : m_e{UNKNOWN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VVarType(en _e) constexpr VVarType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VVarType(int _e) explicit VVarType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = { static const char* const names[] = {
"?", "GPARAM", "LPARAM", "GENVAR", "VAR", "SUPPLY0", "SUPPLY1", "?", "GPARAM", "LPARAM", "GENVAR", "VAR", "SUPPLY0", "SUPPLY1",
@ -804,14 +814,14 @@ public:
return (m_e == BLOCKTEMP || m_e == MODULETEMP || m_e == STMTTEMP || m_e == XTEMP); return (m_e == BLOCKTEMP || m_e == MODULETEMP || m_e == STMTTEMP || m_e == XTEMP);
} }
}; };
inline bool operator==(const VVarType& lhs, const VVarType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VVarType& lhs, const VVarType& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const VVarType& lhs, VVarType::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VVarType& lhs, VVarType::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VVarType::en lhs, const VVarType& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VVarType::en lhs, const VVarType& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VVarType& rhs) { inline std::ostream& operator<<(std::ostream& os, const VVarType& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VBranchPred final { class VBranchPred final {
public: public:
@ -821,11 +831,11 @@ public:
VBranchPred() VBranchPred()
: m_e{BP_UNKNOWN} {} : m_e{BP_UNKNOWN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VBranchPred(en _e) constexpr VBranchPred(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VBranchPred(int _e) explicit VBranchPred(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool unknown() const { return m_e == BP_UNKNOWN; } bool unknown() const { return m_e == BP_UNKNOWN; }
bool likely() const { return m_e == BP_LIKELY; } bool likely() const { return m_e == BP_LIKELY; }
bool unlikely() const { return m_e == BP_UNLIKELY; } bool unlikely() const { return m_e == BP_UNLIKELY; }
@ -843,16 +853,16 @@ public:
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VBranchPred& lhs, const VBranchPred& rhs) { constexpr bool operator==(const VBranchPred& lhs, const VBranchPred& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VBranchPred& lhs, VBranchPred::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VBranchPred& lhs, VBranchPred::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VBranchPred::en lhs, const VBranchPred& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VBranchPred::en lhs, const VBranchPred& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VBranchPred& rhs) { inline std::ostream& operator<<(std::ostream& os, const VBranchPred& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VVarAttrClocker final { class VVarAttrClocker final {
public: public:
@ -862,11 +872,11 @@ public:
VVarAttrClocker() VVarAttrClocker()
: m_e{CLOCKER_UNKNOWN} {} : m_e{CLOCKER_UNKNOWN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VVarAttrClocker(en _e) constexpr VVarAttrClocker(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VVarAttrClocker(int _e) explicit VVarAttrClocker(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool unknown() const { return m_e == CLOCKER_UNKNOWN; } bool unknown() const { return m_e == CLOCKER_UNKNOWN; }
VVarAttrClocker invert() const { VVarAttrClocker invert() const {
if (m_e == CLOCKER_YES) { if (m_e == CLOCKER_YES) {
@ -882,13 +892,13 @@ public:
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VVarAttrClocker& lhs, const VVarAttrClocker& rhs) { constexpr bool operator==(const VVarAttrClocker& lhs, const VVarAttrClocker& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VVarAttrClocker& lhs, VVarAttrClocker::en rhs) { constexpr bool operator==(const VVarAttrClocker& lhs, VVarAttrClocker::en rhs) {
return lhs.m_e == rhs; return lhs.m_e == rhs;
} }
inline bool operator==(VVarAttrClocker::en lhs, const VVarAttrClocker& rhs) { constexpr bool operator==(VVarAttrClocker::en lhs, const VVarAttrClocker& rhs) {
return lhs == rhs.m_e; return lhs == rhs.m_e;
} }
inline std::ostream& operator<<(std::ostream& os, const VVarAttrClocker& rhs) { inline std::ostream& operator<<(std::ostream& os, const VVarAttrClocker& rhs) {
@ -904,21 +914,23 @@ public:
VAlwaysKwd() VAlwaysKwd()
: m_e{ALWAYS} {} : m_e{ALWAYS} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VAlwaysKwd(en _e) constexpr VAlwaysKwd(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VAlwaysKwd(int _e) explicit VAlwaysKwd(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = {"always", "always_ff", "always_latch", "always_comb"}; static const char* const names[] = {"always", "always_ff", "always_latch", "always_comb"};
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VAlwaysKwd& lhs, const VAlwaysKwd& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VAlwaysKwd& lhs, const VAlwaysKwd& rhs) {
inline bool operator==(const VAlwaysKwd& lhs, VAlwaysKwd::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VAlwaysKwd::en lhs, const VAlwaysKwd& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VAlwaysKwd& lhs, VAlwaysKwd::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VAlwaysKwd::en lhs, const VAlwaysKwd& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VCaseType final { class VCaseType final {
public: public:
@ -927,17 +939,19 @@ public:
VCaseType() VCaseType()
: m_e{CT_CASE} {} : m_e{CT_CASE} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VCaseType(en _e) constexpr VCaseType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VCaseType(int _e) explicit VCaseType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
inline bool operator==(const VCaseType& lhs, const VCaseType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VCaseType& lhs, const VCaseType& rhs) {
inline bool operator==(const VCaseType& lhs, VCaseType::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VCaseType::en lhs, const VCaseType& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VCaseType& lhs, VCaseType::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VCaseType::en lhs, const VCaseType& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VDisplayType final { class VDisplayType final {
public: public:
@ -955,11 +969,11 @@ public:
VDisplayType() VDisplayType()
: m_e{DT_DISPLAY} {} : m_e{DT_DISPLAY} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VDisplayType(en _e) constexpr VDisplayType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VDisplayType(int _e) explicit VDisplayType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool addNewline() const { return m_e != DT_WRITE; } bool addNewline() const { return m_e != DT_WRITE; }
bool needScopeTracking() const { return m_e != DT_DISPLAY && m_e != DT_WRITE; } bool needScopeTracking() const { return m_e != DT_DISPLAY && m_e != DT_WRITE; }
const char* ascii() const { const char* ascii() const {
@ -968,13 +982,13 @@ public:
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VDisplayType& lhs, const VDisplayType& rhs) { constexpr bool operator==(const VDisplayType& lhs, const VDisplayType& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VDisplayType& lhs, VDisplayType::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VDisplayType& lhs, VDisplayType::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VDisplayType::en lhs, const VDisplayType& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VDisplayType::en lhs, const VDisplayType& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VDumpCtlType final { class VDumpCtlType final {
public: public:
@ -983,24 +997,24 @@ public:
VDumpCtlType() VDumpCtlType()
: m_e{ON} {} : m_e{ON} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VDumpCtlType(en _e) constexpr VDumpCtlType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VDumpCtlType(int _e) explicit VDumpCtlType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = {"$dumpfile", "$dumpvars", "$dumpall", "$dumpflush", static const char* const names[] = {"$dumpfile", "$dumpvars", "$dumpall", "$dumpflush",
"$dumplimit", "$dumpoff", "$dumpon"}; "$dumplimit", "$dumpoff", "$dumpon"};
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VDumpCtlType& lhs, const VDumpCtlType& rhs) { constexpr bool operator==(const VDumpCtlType& lhs, const VDumpCtlType& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VDumpCtlType& lhs, VDumpCtlType::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VDumpCtlType& lhs, VDumpCtlType::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VDumpCtlType::en lhs, const VDumpCtlType& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VDumpCtlType::en lhs, const VDumpCtlType& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VParseRefExp final { class VParseRefExp final {
public: public:
@ -1013,26 +1027,26 @@ public:
VParseRefExp() VParseRefExp()
: m_e{PX_NONE} {} : m_e{PX_NONE} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VParseRefExp(en _e) constexpr VParseRefExp(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VParseRefExp(int _e) explicit VParseRefExp(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = {"", "$root", "TEXT", "PREDOT"}; static const char* const names[] = {"", "$root", "TEXT", "PREDOT"};
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VParseRefExp& lhs, const VParseRefExp& rhs) { constexpr bool operator==(const VParseRefExp& lhs, const VParseRefExp& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VParseRefExp& lhs, VParseRefExp::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VParseRefExp& lhs, VParseRefExp::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VParseRefExp::en lhs, const VParseRefExp& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VParseRefExp::en lhs, const VParseRefExp& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VParseRefExp& rhs) { inline std::ostream& operator<<(std::ostream& os, const VParseRefExp& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VStrength final { class VStrength final {
public: public:
@ -1040,28 +1054,29 @@ public:
enum en m_e; enum en m_e;
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VStrength(en strengthLevel) constexpr VStrength(en strengthLevel)
: m_e(strengthLevel) {} : m_e(strengthLevel) {}
explicit VStrength(int _e) explicit VStrength(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
constexpr operator en() const { return m_e; }
operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] static const char* const names[]
= {"highz", "small", "medium", "weak", "large", "pull", "strong", "supply"}; = {"highz", "small", "medium", "weak", "large", "pull", "strong", "supply"};
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VStrength& lhs, const VStrength& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VStrength& lhs, const VStrength& rhs) {
inline bool operator==(const VStrength& lhs, VStrength::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VStrength::en lhs, const VStrength& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VStrength& lhs, VStrength::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VStrength::en lhs, const VStrength& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VStrength& rhs) { inline std::ostream& operator<<(std::ostream& os, const VStrength& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
// VNumRange - Structure containing numeric range information // VNumRange - Structure containing numeric range information
// See also AstRange, which is a symbolic version of this // See also AstRange, which is a symbolic version of this
class VNumRange final { class VNumRange final {
public: public:
@ -1137,26 +1152,26 @@ public:
VUseType() VUseType()
: m_e{IMP_FWD_CLASS} {} : m_e{IMP_FWD_CLASS} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VUseType(en _e) constexpr VUseType(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VUseType(int _e) explicit VUseType(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
bool isInclude() const { return m_e == IMP_INCLUDE || m_e == INT_INCLUDE; } bool isInclude() const { return m_e == IMP_INCLUDE || m_e == INT_INCLUDE; }
bool isFwdClass() const { return m_e == IMP_FWD_CLASS || m_e == INT_FWD_CLASS; } bool isFwdClass() const { return m_e == IMP_FWD_CLASS || m_e == INT_FWD_CLASS; }
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = {"IMP_INC", "INT_INC", "IMP_FWD", "INT_FWD"}; static const char* const names[] = {"IMP_INC", "INT_INC", "IMP_FWD", "INT_FWD"};
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const VUseType& lhs, const VUseType& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VUseType& lhs, const VUseType& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const VUseType& lhs, VUseType::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VUseType& lhs, VUseType::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VUseType::en lhs, const VUseType& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VUseType::en lhs, const VUseType& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const VUseType& rhs) { inline std::ostream& operator<<(std::ostream& os, const VUseType& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class VBasicTypeKey final { class VBasicTypeKey final {
public: public:

View File

@ -46,7 +46,7 @@ private:
public: public:
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VCtorType(en _e) constexpr VCtorType(en _e)
: m_e{_e} {} : m_e{_e} {}
bool isClass() const { return m_e == CLASS; } bool isClass() const { return m_e == CLASS; }
bool isCoverage() const { return m_e == COVERAGE; } bool isCoverage() const { return m_e == COVERAGE; }

View File

@ -153,12 +153,12 @@ public:
V3ErrorCode() V3ErrorCode()
: m_e{EC_MIN} {} : m_e{EC_MIN} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
V3ErrorCode(en _e) constexpr V3ErrorCode(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit V3ErrorCode(const char* msgp); // Matching code or ERROR explicit V3ErrorCode(const char* msgp); // Matching code or ERROR
explicit V3ErrorCode(int _e) explicit V3ErrorCode(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
// clang-format off // clang-format off
static const char* const names[] = { static const char* const names[] = {
@ -229,16 +229,16 @@ public:
|| m_e == VARHIDDEN); || m_e == VARHIDDEN);
} }
}; };
inline bool operator==(const V3ErrorCode& lhs, const V3ErrorCode& rhs) { constexpr bool operator==(const V3ErrorCode& lhs, const V3ErrorCode& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const V3ErrorCode& lhs, V3ErrorCode::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const V3ErrorCode& lhs, V3ErrorCode::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(V3ErrorCode::en lhs, const V3ErrorCode& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(V3ErrorCode::en lhs, const V3ErrorCode& rhs) { return lhs == rhs.m_e; }
inline std::ostream& operator<<(std::ostream& os, const V3ErrorCode& rhs) { inline std::ostream& operator<<(std::ostream& os, const V3ErrorCode& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class V3Error final { class V3Error final {
// Base class for any object that wants debugging and error reporting // Base class for any object that wants debugging and error reporting

View File

@ -70,19 +70,19 @@ public:
VWidthMinUsage() VWidthMinUsage()
: m_e{LINT_WIDTH} {} : m_e{LINT_WIDTH} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VWidthMinUsage(en _e) constexpr VWidthMinUsage(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VWidthMinUsage(int _e) explicit VWidthMinUsage(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
inline bool operator==(const VWidthMinUsage& lhs, const VWidthMinUsage& rhs) { constexpr bool operator==(const VWidthMinUsage& lhs, const VWidthMinUsage& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VWidthMinUsage& lhs, VWidthMinUsage::en rhs) { constexpr bool operator==(const VWidthMinUsage& lhs, VWidthMinUsage::en rhs) {
return lhs.m_e == rhs; return lhs.m_e == rhs;
} }
inline bool operator==(VWidthMinUsage::en lhs, const VWidthMinUsage& rhs) { constexpr bool operator==(VWidthMinUsage::en lhs, const VWidthMinUsage& rhs) {
return lhs == rhs.m_e; return lhs == rhs.m_e;
} }

View File

@ -61,7 +61,7 @@ public:
: m_e{_e} {} : m_e{_e} {}
explicit constexpr GraphWay(int _e) explicit constexpr GraphWay(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
const char* ascii() const { const char* ascii() const {
static const char* const names[] = {"FORWARD", "REVERSE"}; static const char* const names[] = {"FORWARD", "REVERSE"};
return names[m_e]; return names[m_e];
@ -71,9 +71,9 @@ public:
constexpr bool forward() const { return m_e == FORWARD; } constexpr bool forward() const { return m_e == FORWARD; }
constexpr bool reverse() const { return m_e != FORWARD; } constexpr bool reverse() const { return m_e != FORWARD; }
}; };
inline bool operator==(const GraphWay& lhs, const GraphWay& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const GraphWay& lhs, const GraphWay& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const GraphWay& lhs, GraphWay::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const GraphWay& lhs, GraphWay::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(GraphWay::en lhs, const GraphWay& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(GraphWay::en lhs, const GraphWay& rhs) { return lhs == rhs.m_e; }
//============================================================================ //============================================================================

View File

@ -58,12 +58,12 @@ public:
V3LangCode() V3LangCode()
: m_e{L_ERROR} {} : m_e{L_ERROR} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
V3LangCode(en _e) constexpr V3LangCode(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit V3LangCode(const char* textp); explicit V3LangCode(const char* textp);
explicit V3LangCode(int _e) explicit V3LangCode(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
}; };
//###################################################################### //######################################################################

View File

@ -42,24 +42,24 @@ public:
VOptionBool() VOptionBool()
: m_e{OPT_DEFAULT_FALSE} {} : m_e{OPT_DEFAULT_FALSE} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VOptionBool(en _e) constexpr VOptionBool(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VOptionBool(int _e) explicit VOptionBool(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; } bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; }
bool isTrue() const { return m_e == OPT_TRUE || m_e == OPT_DEFAULT_TRUE; } bool isTrue() const { return m_e == OPT_TRUE || m_e == OPT_DEFAULT_TRUE; }
bool isSetTrue() const { return m_e == OPT_TRUE; } bool isSetTrue() const { return m_e == OPT_TRUE; }
bool isSetFalse() const { return m_e == OPT_FALSE; } bool isSetFalse() const { return m_e == OPT_FALSE; }
void setTrueOrFalse(bool flag) { m_e = flag ? OPT_TRUE : OPT_FALSE; } void setTrueOrFalse(bool flag) { m_e = flag ? OPT_TRUE : OPT_FALSE; }
}; };
inline bool operator==(const VOptionBool& lhs, const VOptionBool& rhs) { constexpr bool operator==(const VOptionBool& lhs, const VOptionBool& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const VOptionBool& lhs, VOptionBool::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const VOptionBool& lhs, VOptionBool::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(VOptionBool::en lhs, const VOptionBool& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(VOptionBool::en lhs, const VOptionBool& rhs) { return lhs == rhs.m_e; }
//###################################################################### // ######################################################################
class VTimescale final { class VTimescale final {
public: public:
@ -81,7 +81,7 @@ public:
VTimescale() VTimescale()
: m_e{NONE} {} : m_e{NONE} {}
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VTimescale(en _e) constexpr VTimescale(en _e)
: m_e{_e} {} : m_e{_e} {}
explicit VTimescale(int _e) explicit VTimescale(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
@ -116,26 +116,30 @@ public:
return values[m_e]; return values[m_e];
} }
}; };
inline bool operator==(const VTimescale& lhs, const VTimescale& rhs) { return lhs.m_e == rhs.m_e; } constexpr bool operator==(const VTimescale& lhs, const VTimescale& rhs) {
inline bool operator==(const VTimescale& lhs, VTimescale::en rhs) { return lhs.m_e == rhs; } return lhs.m_e == rhs.m_e;
inline bool operator==(VTimescale::en lhs, const VTimescale& rhs) { return lhs == rhs.m_e; } }
constexpr bool operator==(const VTimescale& lhs, VTimescale::en rhs) { return lhs.m_e == rhs; }
constexpr bool operator==(VTimescale::en lhs, const VTimescale& rhs) { return lhs == rhs.m_e; }
// Comparisons are based on time, not enum values, so seconds > milliseconds // Comparisons are based on time, not enum values, so seconds > milliseconds
inline bool operator<(const VTimescale& lhs, const VTimescale& rhs) { return lhs.m_e > rhs.m_e; } constexpr bool operator<(const VTimescale& lhs, const VTimescale& rhs) {
return lhs.m_e > rhs.m_e;
}
inline std::ostream& operator<<(std::ostream& os, const VTimescale& rhs) { inline std::ostream& operator<<(std::ostream& os, const VTimescale& rhs) {
return os << rhs.ascii(); return os << rhs.ascii();
} }
//###################################################################### // ######################################################################
class TraceFormat final { class TraceFormat final {
public: public:
enum en : uint8_t { VCD = 0, FST } m_e; enum en : uint8_t { VCD = 0, FST } m_e;
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
TraceFormat(en _e = VCD) constexpr TraceFormat(en _e = VCD)
: m_e{_e} {} : m_e{_e} {}
explicit TraceFormat(int _e) explicit TraceFormat(int _e)
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning : m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; } constexpr operator en() const { return m_e; }
bool fst() const { return m_e == FST; } bool fst() const { return m_e == FST; }
bool vcd() const { return m_e == VCD; } bool vcd() const { return m_e == VCD; }
string classBase() const { string classBase() const {
@ -147,16 +151,16 @@ public:
return names[m_e]; return names[m_e];
} }
}; };
inline bool operator==(const TraceFormat& lhs, const TraceFormat& rhs) { constexpr bool operator==(const TraceFormat& lhs, const TraceFormat& rhs) {
return lhs.m_e == rhs.m_e; return lhs.m_e == rhs.m_e;
} }
inline bool operator==(const TraceFormat& lhs, TraceFormat::en rhs) { return lhs.m_e == rhs; } constexpr bool operator==(const TraceFormat& lhs, TraceFormat::en rhs) { return lhs.m_e == rhs; }
inline bool operator==(TraceFormat::en lhs, const TraceFormat& rhs) { return lhs == rhs.m_e; } constexpr bool operator==(TraceFormat::en lhs, const TraceFormat& rhs) { return lhs == rhs.m_e; }
using V3StringList = std::vector<std::string>; using V3StringList = std::vector<std::string>;
using V3StringSet = std::set<std::string>; using V3StringSet = std::set<std::string>;
//###################################################################### // ######################################################################
// Information given by --hierarchical-block option // Information given by --hierarchical-block option
class V3HierarchicalBlockOption final { class V3HierarchicalBlockOption final {