Skip to content

Commit

Permalink
added is_lhs
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Dalek <[email protected]>
  • Loading branch information
Lukasz Dalek committed Mar 22, 2021
1 parent 43169ff commit 2ca7f18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void ForbidImplicitDeclarationsRule::Lint(const verible::TextStructureView& text
for (const auto& itr : node.Value().local_references_to_bind) {
ABSL_DIE_IF_NULL(itr.LastLeaf())->ApplyPreOrder(
[&violations, &text_structure](const ReferenceComponent& node) {
if ((node.resolved_symbol == nullptr) || // Unresolved
(node.identifier.begin() < node.resolved_symbol->Key()->begin())) { // Implicit
if ((node.resolved_symbol == nullptr && node.is_lhs) || // Unresolved
(node.resolved_symbol && (node.identifier.begin() < node.resolved_symbol->Key()->begin()))) { // Implicit
const auto& contents = text_structure.Contents();
const auto offset = std::distance(contents.begin(),
node.identifier.begin());
Expand Down
3 changes: 3 additions & 0 deletions verilog/analysis/symbol_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,13 @@ class SymbolTable::Builder : public TreeContextVisitor {
// reference.
DependentReferences& ref(reference_builders_.top());

const bool is_lhs = Context().IsInside(NodeEnum::kLPValue);

const ReferenceComponent new_ref{
.identifier = text,
.ref_type = InferReferenceType(),
.required_metatype = InferMetaType(),
.is_lhs = is_lhs,
};

// For instances' named ports, and types' named parameters,
Expand Down
2 changes: 2 additions & 0 deletions verilog/analysis/symbol_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ struct ReferenceComponent {
// TODO: privatize this member.
const SymbolTableNode* resolved_symbol = nullptr;

bool is_lhs = false;

public:
ReferenceComponent(const ReferenceComponent&) = default; // safe to copy
ReferenceComponent(ReferenceComponent&&) = default;
Expand Down
1 change: 1 addition & 0 deletions verilog/tools/lint/testdata/long_line.sv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module long_line;
wire aaaaaaaaaaaaaaaaaaa;
initial begin
aaaaaaaaaaaaaaaaaaa[12341234] <= cccccccccccccccccccccccc + ddddddddddddddddd * eeeeeeeeeeeeeeeeee;
end
Expand Down

0 comments on commit 2ca7f18

Please sign in to comment.