-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow rule aliasing #935
base: master
Are you sure you want to change the base?
Allow rule aliasing #935
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ VERILOG_REGISTER_LINT_RULE(UndersizedBinaryLiteralRule); | |
|
||
const LintRuleDescriptor& UndersizedBinaryLiteralRule::GetDescriptor() { | ||
static const LintRuleDescriptor d{ | ||
.name = "undersized-binary-literal", | ||
.name = "undersized-numeric-literal", | ||
.topic = "number-literals", | ||
.desc = | ||
"Checks that the digits of binary literals for the configured " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the 'numeric' literal, we should now actually switch all This would be also the typical application of the aliases: rules evolve and will get more features, but somtimes we don't want to expose these features in a rule that had a very specific name (like in this case where 'binary' kindof indicates that it only deals with one type of number). So let's have here all features turned on and in the binary rule the ones not |
||
|
@@ -73,6 +73,20 @@ const LintRuleDescriptor& UndersizedBinaryLiteralRule::GetDescriptor() { | |
return d; | ||
} | ||
|
||
const std::vector<LintRuleAliasDescriptor>& | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of having a separate function (Recently I cleaned up the rules that had multiple static functions for their descriptions to just return one descriptor which made things simpler; I'd like to avoid it getting more compilcated again) |
||
UndersizedBinaryLiteralRule::GetAliasDescriptors() { | ||
static const std::vector<LintRuleAliasDescriptor> d{ | ||
{ | ||
.name = "undersized-binary-literal", | ||
.param_defaults = | ||
{ | ||
{"bin", "true"}, | ||
}, | ||
}, | ||
}; | ||
return d; | ||
} | ||
|
||
// Broadly, start by matching all number nodes with a | ||
// constant width and based literal. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,12 @@ struct LintRuleDescriptor { | |
std::vector<LintConfigParameterDescriptor> param; | ||
}; | ||
|
||
struct LintRuleAliasDescriptor { | ||
LintRuleId name; // ID/name of the alias. | ||
std::vector<std::pair<absl::string_view, absl::string_view>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe we can re-use the name/value thing we have going on in So have a little hierarchy (usually, I'd be in favor of composition instead of inheritance, but we already have a bunch of descriptors defined that all would need changing; it is not too bad struct LintConfigParameterNameValue {
absl::string_view name;
std::string default_value;
};
// The descriptor also has a human readable description of this parameter
struct LintConfigParameterDescriptor : public LintConfigParameterNameValue {
std::string description;
}; Then, replace the pair with our new name/value struct: struct LintRuleAliasDescriptor {
LintRuleId name; // ID/name of the alias.
std::vector<LintConfigParameterNameValue> param_defaults; // List of param values set by the alias
}; |
||
param_defaults; // List of param values set by the alias | ||
}; | ||
|
||
} // namespace analysis | ||
} // namespace verilog | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably rename the whole class to be
UndersizedNumericLiteralRule
, also the naming of the header and test.This should probably be a separate PR after this is done, so that we don't have too many changes at once.