Skip to content

Commit ef18986

Browse files
committed
[clang-format] Handle Verilog delay control (#95703)
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 470d59d commit ef18986

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
@@ -3414,7 +3414,8 @@ class ExpressionParser {
34143414
} else {
34153415
break;
34163416
}
3417-
} else if (Tok->is(tok::hash)) {
3417+
} else if (Tok->is(Keywords.kw_verilogHash)) {
3418+
// Delay control.
34183419
if (Next->is(tok::l_paren))
34193420
Next = Next->MatchingParen;
34203421
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)