Skip to content

Commit

Permalink
Merge pull request chipsalliance#2276 from hzeller/feature-20241004-r…
Browse files Browse the repository at this point in the history
…ename-line-continuations

Rename forbid-line-continuations rule file to match rule name
  • Loading branch information
fangism authored Oct 4, 2024
2 parents f73c7f1 + cbbc4c9 commit 14eed6a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
14 changes: 7 additions & 7 deletions verilog/analysis/checkers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cc_library(
":explicit-task-lifetime-rule",
":forbid-consecutive-null-statements-rule",
":forbid-defparam-rule",
":forbid-line-continuations-rule",
":forbid-negative-array-dim",
":forbidden-anonymous-enums-rule",
":forbidden-anonymous-structs-unions-rule",
Expand Down Expand Up @@ -66,7 +67,6 @@ cc_library(
":struct-union-name-style-rule",
":suggest-parentheses-rule",
":suspicious-semicolon-rule",
":token-stream-lint-rule",
":truncated-numeric-literal-rule",
":undersized-binary-literal-rule",
":unpacked-dimensions-rule",
Expand Down Expand Up @@ -1103,9 +1103,9 @@ cc_test(
)

cc_library(
name = "token-stream-lint-rule",
srcs = ["token_stream_lint_rule.cc"],
hdrs = ["token_stream_lint_rule.h"],
name = "forbid-line-continuations-rule",
srcs = ["forbid_line_continuations_rule.cc"],
hdrs = ["forbid_line_continuations_rule.h"],
deps = [
"//common/analysis:lint-rule-status",
"//common/analysis:syntax-tree-lint-rule",
Expand All @@ -1125,10 +1125,10 @@ cc_library(
)

cc_test(
name = "token-stream-lint-rule_test",
srcs = ["token_stream_lint_rule_test.cc"],
name = "forbid-line-continuations-rule_test",
srcs = ["forbid_line_continuations_rule_test.cc"],
deps = [
":token-stream-lint-rule",
":forbid-line-continuations-rule",
"//common/analysis:linter-test-utils",
"//common/analysis:syntax-tree-linter-test-utils",
"//verilog/analysis:verilog-analyzer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "verilog/analysis/checkers/token_stream_lint_rule.h"
#include "verilog/analysis/checkers/forbid_line_continuations_rule.h"

#include <algorithm>
#include <set>
Expand All @@ -38,14 +38,14 @@ using verible::LintViolation;
using verible::SyntaxTreeContext;
using verible::matcher::Matcher;

// Register TokenStreamLintRule
VERILOG_REGISTER_LINT_RULE(TokenStreamLintRule);
// Register ForbidLineContinuationsRule
VERILOG_REGISTER_LINT_RULE(ForbidLineContinuationsRule);

static constexpr absl::string_view kMessage =
"The lines can't be continued with \'\\\', use concatenation operator with "
"braces";

const LintRuleDescriptor &TokenStreamLintRule::GetDescriptor() {
const LintRuleDescriptor &ForbidLineContinuationsRule::GetDescriptor() {
static const LintRuleDescriptor d{
.name = "forbid-line-continuations",
.topic = "forbid-line-continuations",
Expand All @@ -62,8 +62,8 @@ static const Matcher &StringLiteralMatcher() {
return matcher;
}

void TokenStreamLintRule::HandleSymbol(const verible::Symbol &symbol,
const SyntaxTreeContext &context) {
void ForbidLineContinuationsRule::HandleSymbol(
const verible::Symbol &symbol, const SyntaxTreeContext &context) {
verible::matcher::BoundSymbolManager manager;
if (!StringLiteralMatcher().Matches(symbol, &manager)) {
return;
Expand All @@ -81,7 +81,7 @@ void TokenStreamLintRule::HandleSymbol(const verible::Symbol &symbol,
}
}

LintRuleStatus TokenStreamLintRule::Report() const {
LintRuleStatus ForbidLineContinuationsRule::Report() const {
return LintRuleStatus(violations_, GetDescriptor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef VERIBLE_VERILOG_ANALYSIS_CHECKERS_TOKEN_STREAM_LINT_RULE_H_
#define VERIBLE_VERILOG_ANALYSIS_CHECKERS_TOKEN_STREAM_LINT_RULE_H_
#ifndef VERIBLE_VERILOG_ANALYSIS_CHECKERS_FORBID_LINE_CONTINUATIONS_RULE_H_
#define VERIBLE_VERILOG_ANALYSIS_CHECKERS_FORBID_LINE_CONTINUATIONS_RULE_H_

#include <set>

Expand All @@ -26,8 +26,7 @@
namespace verilog {
namespace analysis {

// TokenStreamLintRule finds occurrences of any string literal.
class TokenStreamLintRule : public verible::SyntaxTreeLintRule {
class ForbidLineContinuationsRule final : public verible::SyntaxTreeLintRule {
public:
using rule_type = verible::SyntaxTreeLintRule;

Expand All @@ -45,4 +44,4 @@ class TokenStreamLintRule : public verible::SyntaxTreeLintRule {
} // namespace analysis
} // namespace verilog

#endif // VERIBLE_VERILOG_ANALYSIS_CHECKERS_TOKEN_STREAM_LINT_RULE_H_
#endif // VERIBLE_VERILOG_ANALYSIS_CHECKERS_FORBID_LINE_CONTINUATIONS_RULE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "verilog/analysis/checkers/token_stream_lint_rule.h"
#include "verilog/analysis/checkers/forbid_line_continuations_rule.h"

#include <initializer_list>

Expand Down Expand Up @@ -43,7 +43,7 @@ TEST(StringLiteralConcatenationTest, FunctionPass) {
"end\nendmodule"},
};

RunLintTestCases<VerilogAnalyzer, TokenStreamLintRule>(
RunLintTestCases<VerilogAnalyzer, ForbidLineContinuationsRule>(
kStringLiteralTestCases);
}

Expand Down Expand Up @@ -83,7 +83,7 @@ TEST(StringLiteralConcatenationTest, FunctionFailures) {
"end\nendmodule"},
};

RunLintTestCases<VerilogAnalyzer, TokenStreamLintRule>(
RunLintTestCases<VerilogAnalyzer, ForbidLineContinuationsRule>(
kStringLiteralTestCases);
}

Expand Down

0 comments on commit 14eed6a

Please sign in to comment.