Internals: Enforce types on C++ enums. No functional change intended.
This commit is contained in:
parent
c0dc77c908
commit
c507dcf610
|
|
@ -140,7 +140,7 @@ enum VerilatedVarType : uint8_t {
|
|||
VLVT_REAL // AKA double
|
||||
};
|
||||
|
||||
enum VerilatedVarFlags {
|
||||
enum VerilatedVarFlags : uint32_t {
|
||||
VLVD_0 = 0, // None
|
||||
VLVD_IN = 1, // == vpiInput
|
||||
VLVD_OUT = 2, // == vpiOutput
|
||||
|
|
|
|||
|
|
@ -5329,7 +5329,7 @@ public:
|
|||
class AstAtoN final : public AstNodeUniop {
|
||||
// string.atoi(), atobin(), atohex(), atooct(), atoireal()
|
||||
public:
|
||||
enum FmtType { ATOI = 10, ATOHEX = 16, ATOOCT = 8, ATOBIN = 2, ATOREAL = -1 };
|
||||
enum FmtType : int { ATOI = 10, ATOHEX = 16, ATOOCT = 8, ATOBIN = 2, ATOREAL = -1 };
|
||||
|
||||
private:
|
||||
const FmtType m_fmt; // Operation type
|
||||
|
|
|
|||
|
|
@ -1455,7 +1455,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
enum operation m_operation;
|
||||
operation m_operation;
|
||||
|
||||
public:
|
||||
AstAssignCompound(AstAssignCompound::operation operation, FileLine* fl, AstNodeExpr* lhsp,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public:
|
|||
string resetValue;
|
||||
};
|
||||
|
||||
enum class VarSpecKind {
|
||||
enum class VarSpecKind : uint8_t {
|
||||
PARAM, // Select only matching parameters
|
||||
PORT, // Select only matching ports
|
||||
VAR // Select any matching AstVar (including params and ports)
|
||||
|
|
|
|||
|
|
@ -279,12 +279,12 @@ class EmitCHeader final : public EmitCConstInit {
|
|||
emitUnpackedUOrSBody(sdtypep);
|
||||
}
|
||||
}
|
||||
enum class AttributeType { Width, Dimension };
|
||||
enum class AttributeType : uint8_t { WIDTH, DIMENSION };
|
||||
// Get member attribute based on type
|
||||
int getNodeAttribute(const AstMemberDType* itemp, AttributeType type) {
|
||||
const bool isArrayType = itemp->dtypep()->isNonPackedArray();
|
||||
switch (type) {
|
||||
case AttributeType::Width: {
|
||||
case AttributeType::WIDTH: {
|
||||
if (isArrayType) {
|
||||
// For arrays, get innermost element width
|
||||
const AstNodeDType* dtype = itemp->dtypep();
|
||||
|
|
@ -293,7 +293,7 @@ class EmitCHeader final : public EmitCConstInit {
|
|||
}
|
||||
return itemp->width();
|
||||
}
|
||||
case AttributeType::Dimension: {
|
||||
case AttributeType::DIMENSION: {
|
||||
// Return array dimension or 0 for non-arrays
|
||||
return isArrayType ? itemp->dtypep()->dimensions(true).second : 0;
|
||||
}
|
||||
|
|
@ -345,10 +345,10 @@ class EmitCHeader final : public EmitCConstInit {
|
|||
puts("};\n}\n");
|
||||
|
||||
putns(sdtypep, "\nstd::vector<int> memberWidth(void) const {\n");
|
||||
emitMemberVector<AttributeType::Width>(sdtypep);
|
||||
emitMemberVector<AttributeType::WIDTH>(sdtypep);
|
||||
|
||||
putns(sdtypep, "\nstd::vector<int> memberDimension(void) const {\n");
|
||||
emitMemberVector<AttributeType::Dimension>(sdtypep);
|
||||
emitMemberVector<AttributeType::DIMENSION>(sdtypep);
|
||||
|
||||
needComma = false;
|
||||
putns(sdtypep, "\nauto memberIndices(void) const {\n");
|
||||
|
|
|
|||
|
|
@ -420,12 +420,10 @@ class PackThreads final {
|
|||
// schedule to ensure that indexes for simulation-time thread pool workers are not shadowed
|
||||
// by another tasks.
|
||||
// For retaining control over thread schedules, we distinguish SchedulingModes:
|
||||
enum class SchedulingMode {
|
||||
SCHEDULING // Schedule normal tasks
|
||||
,
|
||||
WIDE_TASK_DISCOVERED // We found a wide task, if this is the only one available,
|
||||
// switch to WIDE_TASK_SCHEDULING
|
||||
,
|
||||
enum class SchedulingMode : uint8_t {
|
||||
SCHEDULING, // Schedule normal tasks
|
||||
WIDE_TASK_DISCOVERED, // Found a wide task, if this is the only one available,
|
||||
// switch to WIDE_TASK_SCHEDULING
|
||||
WIDE_TASK_SCHEDULING // Schedule wide tasks
|
||||
};
|
||||
SchedulingMode mode = SchedulingMode::SCHEDULING;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class FileLineSingleton final {
|
|||
VErrorBitSet m_ctrlEn; // Enabled by control file
|
||||
|
||||
public:
|
||||
enum class Subset {
|
||||
enum class Subset : uint8_t {
|
||||
CODE = 0, // Selects m_codeEn, the enable bits used by in-code directives/metacomments
|
||||
CTRL = 1, // Selects m_ctrlEn, the enable bits used by control files
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class VSymEnt;
|
|||
|
||||
class V3LinkDotIfaceCapture final {
|
||||
public:
|
||||
enum class CaptureType { IFACE, CLASS };
|
||||
enum class CaptureType : uint8_t { IFACE, CLASS };
|
||||
|
||||
// Path-based map key: no pointers, only stable strings.
|
||||
// {ownerModName, refName, cellPath, cloneCellPath} uniquely identifies
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ protected:
|
|||
|
||||
public:
|
||||
// CONSTANTS
|
||||
enum MiscConsts {
|
||||
enum MiscConsts : int {
|
||||
DEFINE_RECURSION_LEVEL_MAX = 1000, // How many `def substitutions before an error
|
||||
INCLUDE_DEPTH_MAX = 500, // How many `includes deep before an error
|
||||
// Streams deep (sometimes `def deep) before an error.
|
||||
|
|
|
|||
|
|
@ -90,6 +90,14 @@ for filename in sorted(files.keys()):
|
|||
r'.*(Need \(\)|: m_e\()|V3OPTION_PARSER_DEF',
|
||||
"Use brace instead of parenthesis-style constructors e.g. ': m_...{...}'")
|
||||
|
||||
check_pattern(
|
||||
filename,
|
||||
contents,
|
||||
r'\s*enum\s+(class\s+)?([a-zA-Z0-9_]+)',
|
||||
# Ignore common m_e enum constructors
|
||||
r' enum m_e | enum en | : [a-zA-Z]',
|
||||
"Add type to enum declaration e.g. 'enum class foo : uint8_t'")
|
||||
|
||||
if re.search(r'\.(c|cpp)', filename):
|
||||
check_pattern(filename, contents, r'(\w+\s+)*(\binline\b)[^\n]*', None,
|
||||
"'inline' keyword is on functions defined in .cpp files")
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const std::vector<int> cbs_to_test{cbValueChange};
|
||||
|
||||
enum CallbackState { PRE_REGISTER, ACTIVE, ACTIVE_AGAIN, REM_REREG_ACTIVE, POST_REMOVE };
|
||||
enum CallbackState : uint8_t { PRE_REGISTER, ACTIVE, ACTIVE_AGAIN, REM_REREG_ACTIVE, POST_REMOVE };
|
||||
const std::vector<CallbackState> cb_states{PRE_REGISTER, ACTIVE, ACTIVE_AGAIN, REM_REREG_ACTIVE,
|
||||
POST_REMOVE};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue