From 73f5e3f8087d526122af1ad9d26983e804b21741 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 2 Feb 2020 10:34:29 -0500 Subject: [PATCH] Internals: Add missing const. No functional change. --- src/V3Ast.h | 198 ++++++++++++++++++++++++++++----------------- src/V3Error.h | 14 ++-- src/V3FileLine.h | 2 +- src/V3Global.h | 14 +++- src/V3Graph.h | 6 +- src/V3Options.h | 22 +++-- src/V3OrderGraph.h | 14 +++- 7 files changed, 170 insertions(+), 100 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index c3c9cca4e..385fd458b 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -82,11 +82,11 @@ public: inline AstType(en _e) : m_e(_e) {} explicit inline AstType(int _e) : m_e(static_cast(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(AstType lhs, AstType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(AstType lhs, AstType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(AstType::en lhs, AstType rhs) { return (lhs == rhs.m_e); } - inline std::ostream& operator<<(std::ostream& os, const AstType& rhs) { return os<(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(AstPragmaType lhs, AstPragmaType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(AstPragmaType lhs, AstPragmaType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(AstPragmaType::en lhs, AstPragmaType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const AstPragmaType& lhs, const AstPragmaType& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const AstPragmaType& lhs, AstPragmaType::en rhs) { return lhs.m_e == rhs; } +inline bool operator==(AstPragmaType::en lhs, const AstPragmaType& rhs) { return lhs == rhs.m_e; } //###################################################################### @@ -184,10 +188,12 @@ public: bool isTrace() const { return (m_e==TRACE_INIT || m_e==TRACE_INIT_SUB || m_e==TRACE_FULL || m_e==TRACE_FULL_SUB || m_e==TRACE_CHANGE || m_e==TRACE_CHANGE_SUB); } - }; - inline bool operator==(AstCFuncType lhs, AstCFuncType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(AstCFuncType lhs, AstCFuncType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(AstCFuncType::en lhs, AstCFuncType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const AstCFuncType& lhs, const AstCFuncType& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const AstCFuncType& lhs, AstCFuncType::en rhs) { return lhs.m_e == rhs; } +inline bool operator==(AstCFuncType::en lhs, const AstCFuncType& rhs) { return lhs == rhs.m_e; } //###################################################################### @@ -273,10 +279,10 @@ public: inline VEdgeType(en _e) : m_e(_e) {} explicit inline VEdgeType(int _e) : m_e(static_cast(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(VEdgeType lhs, VEdgeType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(VEdgeType lhs, VEdgeType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(VEdgeType::en lhs, VEdgeType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const VEdgeType& lhs, const VEdgeType& rhs) { return lhs.m_e == rhs.m_e; } +inline bool operator==(const VEdgeType& lhs, VEdgeType::en rhs) { return lhs.m_e == rhs; } +inline bool operator==(VEdgeType::en lhs, const VEdgeType& rhs) { return lhs == rhs.m_e; } //###################################################################### @@ -345,10 +351,12 @@ public: inline AstAttrType(en _e) : m_e(_e) {} explicit inline AstAttrType(int _e) : m_e(static_cast(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(AstAttrType lhs, AstAttrType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(AstAttrType lhs, AstAttrType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(AstAttrType::en lhs, AstAttrType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const AstAttrType& lhs, const AstAttrType& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const AstAttrType& lhs, AstAttrType::en rhs) { return lhs.m_e == rhs; } +inline bool operator==(AstAttrType::en lhs, const AstAttrType& rhs) { return lhs == rhs.m_e; } //###################################################################### @@ -472,10 +480,16 @@ public: } bool isDouble() const { return m_e==DOUBLE; } bool isString() const { return m_e==STRING; } - }; - inline bool operator==(AstBasicDTypeKwd lhs, AstBasicDTypeKwd rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(AstBasicDTypeKwd lhs, AstBasicDTypeKwd::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(AstBasicDTypeKwd::en lhs, AstBasicDTypeKwd rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const AstBasicDTypeKwd& lhs, const AstBasicDTypeKwd& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const AstBasicDTypeKwd& lhs, AstBasicDTypeKwd::en rhs) { + return lhs.m_e == rhs; +} +inline bool operator==(AstBasicDTypeKwd::en lhs, const AstBasicDTypeKwd& rhs) { + return lhs == rhs.m_e; +} //###################################################################### @@ -517,11 +531,13 @@ public: bool isWritable() const { return m_e == OUTPUT || m_e == INOUT || m_e == REF; } bool isRefOrConstRef() const { return m_e == REF || m_e == CONSTREF; } - }; - inline bool operator==(VDirection lhs, VDirection rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(VDirection lhs, VDirection::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(VDirection::en lhs, VDirection rhs) { return (lhs == rhs.m_e); } - inline std::ostream& operator<<(std::ostream& os, const VDirection& rhs) { return os<(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(VCaseType lhs, VCaseType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(VCaseType lhs, VCaseType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(VCaseType::en lhs, VCaseType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const VCaseType& lhs, const VCaseType& rhs) { return lhs.m_e == rhs.m_e; } +inline bool operator==(const VCaseType& lhs, VCaseType::en rhs) { return lhs.m_e == rhs; } +inline bool operator==(VCaseType::en lhs, const VCaseType& rhs) { return lhs == rhs.m_e; } //###################################################################### @@ -763,10 +801,16 @@ public: static const char* const names[] = { "display", "write", "info", "error", "warning", "fatal"}; return names[m_e]; } - }; - inline bool operator==(AstDisplayType lhs, AstDisplayType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(AstDisplayType lhs, AstDisplayType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(AstDisplayType::en lhs, AstDisplayType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const AstDisplayType& lhs, const AstDisplayType& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const AstDisplayType& lhs, AstDisplayType::en rhs) { + return lhs.m_e == rhs; +} +inline bool operator==(AstDisplayType::en lhs, const AstDisplayType& rhs) { + return lhs == rhs.m_e; +} //###################################################################### @@ -786,11 +830,15 @@ public: static const char* const names[] = { "", "TEXT", "PREDOT"}; return names[m_e]; } - }; - inline bool operator==(VParseRefExp lhs, VParseRefExp rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(VParseRefExp lhs, VParseRefExp::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(VParseRefExp::en lhs, VParseRefExp rhs) { return (lhs == rhs.m_e); } - inline std::ostream& operator<<(std::ostream& os, const VParseRefExp& rhs) { return os<(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(VWidthMinUsage lhs, VWidthMinUsage rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(VWidthMinUsage lhs, VWidthMinUsage::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(VWidthMinUsage::en lhs, VWidthMinUsage rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const VWidthMinUsage& lhs, const VWidthMinUsage& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const VWidthMinUsage& lhs, VWidthMinUsage::en rhs) { + return lhs.m_e == rhs; +} +inline bool operator==(VWidthMinUsage::en lhs, const VWidthMinUsage& rhs) { + return lhs == rhs.m_e; +} //###################################################################### // V3Global - The top level class for the entire program diff --git a/src/V3Graph.h b/src/V3Graph.h index 2af27c93c..c57aa3923 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -71,9 +71,9 @@ public: bool forward() const { return m_e == FORWARD; } bool reverse() const { return m_e != FORWARD; } }; -inline bool operator==(GraphWay lhs, GraphWay rhs) { return (lhs.m_e == rhs.m_e); } -inline bool operator==(GraphWay lhs, GraphWay::en rhs) { return (lhs.m_e == rhs); } -inline bool operator==(GraphWay::en lhs, GraphWay rhs) { return (lhs == rhs.m_e); } +inline 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; } +inline bool operator==(GraphWay::en lhs, const GraphWay& rhs) { return lhs == rhs.m_e; } //============================================================================ diff --git a/src/V3Options.h b/src/V3Options.h index 244ab5135..dac7c3402 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -62,11 +62,15 @@ public: static const char* const names[] = { "DEFAULT_FALSE", "DEFAULT_TRUE", "TRUE", "FALSE"}; return names[m_e]; } - }; - inline bool operator==(VOptionBool lhs, VOptionBool rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(VOptionBool lhs, VOptionBool::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(VOptionBool::en lhs, VOptionBool rhs) { return (lhs == rhs.m_e); } - inline std::ostream& operator<<(std::ostream& os, const VOptionBool& rhs) { return os< V3StringList; typedef std::set V3StringSet; diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index 64765db27..c4e6280b7 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -103,10 +103,16 @@ struct OrderVEdgeType { inline OrderVEdgeType(en _e) : m_e(_e) {} explicit inline OrderVEdgeType(int _e) : m_e(static_cast(_e)) {} operator en() const { return m_e; } - }; - inline bool operator==(OrderVEdgeType lhs, OrderVEdgeType rhs) { return (lhs.m_e == rhs.m_e); } - inline bool operator==(OrderVEdgeType lhs, OrderVEdgeType::en rhs) { return (lhs.m_e == rhs); } - inline bool operator==(OrderVEdgeType::en lhs, OrderVEdgeType rhs) { return (lhs == rhs.m_e); } +}; +inline bool operator==(const OrderVEdgeType& lhs, const OrderVEdgeType& rhs) { + return lhs.m_e == rhs.m_e; +} +inline bool operator==(const OrderVEdgeType& lhs, OrderVEdgeType::en rhs) { + return lhs.m_e == rhs; +} +inline bool operator==(OrderVEdgeType::en lhs, const OrderVEdgeType& rhs) { + return lhs == rhs.m_e; +} //###################################################################### // Graph types