Skip to content

Commit

Permalink
[clang-format] Handle Verilog delay control (llvm#95703)
Browse files Browse the repository at this point in the history
I made a mistake when I tried to make the code handle the backtick
character like the hash character.  The code did not recognize the delay
control structure.  It caused net names in the declaration to be aligned
to the type name instead of the first net name.

new

```Verilog
wire logic #0 mynet, //
              mynet1;
```

old

```Verilog
wire logic #0 mynet, //
     mynet1;
```
  • Loading branch information
sstwcw committed Jun 17, 2024
1 parent 470d59d commit ef18986
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,8 @@ class ExpressionParser {
} else {
break;
}
} else if (Tok->is(tok::hash)) {
} else if (Tok->is(Keywords.kw_verilogHash)) {
// Delay control.
if (Next->is(tok::l_paren))
Next = Next->MatchingParen;
if (Next)
Expand Down
9 changes: 9 additions & 0 deletions clang/unittests/Format/FormatTestVerilog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,15 @@ TEST_F(FormatTestVerilog, Declaration) {
verifyFormat("wire mynet, mynet1;");
verifyFormat("wire mynet, //\n"
" mynet1;");
verifyFormat("wire #0 mynet, mynet1;");
verifyFormat("wire logic #0 mynet, mynet1;");
verifyFormat("wire #(1, 2, 3) mynet, mynet1;");
verifyFormat("wire #0 mynet, //\n"
" mynet1;");
verifyFormat("wire logic #0 mynet, //\n"
" mynet1;");
verifyFormat("wire #(1, 2, 3) mynet, //\n"
" mynet1;");
verifyFormat("wire mynet = enable;");
verifyFormat("wire mynet = enable, mynet1;");
verifyFormat("wire mynet = enable, //\n"
Expand Down

0 comments on commit ef18986

Please sign in to comment.