Skip to content

Commit 5982cfd

Browse files
committed
[clang-format] Handle Verilog delay control
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; ```
1 parent d442bf0 commit 5982cfd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,7 +3410,8 @@ class ExpressionParser {
34103410
} else {
34113411
break;
34123412
}
3413-
} else if (Tok->is(tok::hash)) {
3413+
} else if (Tok->is(Keywords.kw_verilogHash)) {
3414+
// Delay control.
34143415
if (Next->is(tok::l_paren))
34153416
Next = Next->MatchingParen;
34163417
if (Next)

clang/unittests/Format/FormatTestVerilog.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,15 @@ TEST_F(FormatTestVerilog, Declaration) {
391391
verifyFormat("wire mynet, mynet1;");
392392
verifyFormat("wire mynet, //\n"
393393
" mynet1;");
394+
verifyFormat("wire #0 mynet, mynet1;");
395+
verifyFormat("wire logic #0 mynet, mynet1;");
396+
verifyFormat("wire #(1, 2, 3) mynet, mynet1;");
397+
verifyFormat("wire #0 mynet, //\n"
398+
" mynet1;");
399+
verifyFormat("wire logic #0 mynet, //\n"
400+
" mynet1;");
401+
verifyFormat("wire #(1, 2, 3) mynet, //\n"
402+
" mynet1;");
394403
verifyFormat("wire mynet = enable;");
395404
verifyFormat("wire mynet = enable, mynet1;");
396405
verifyFormat("wire mynet = enable, //\n"

0 commit comments

Comments
 (0)