Skip to content

Commit 88547bc

Browse files
committed
Recognize backticks
1 parent 1e2283c commit 88547bc

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4441,8 +4441,8 @@ unsigned UnwrappedLineParser::parseVerilogHierarchyHeader() {
44414441
Prev->setFinalizedType(TT_VerilogDimensionedTypeName);
44424442
parseSquare();
44434443
} else if (Keywords.isVerilogIdentifier(*FormatTok) ||
4444-
FormatTok->isOneOf(tok::coloncolon, Keywords.kw_automatic,
4445-
tok::kw_static)) {
4444+
FormatTok->isOneOf(tok::hash, tok::hashhash, tok::coloncolon,
4445+
Keywords.kw_automatic, tok::kw_static)) {
44464446
nextToken();
44474447
} else {
44484448
break;

clang/unittests/Format/FormatTestVerilog.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,13 @@ TEST_F(FormatTestVerilog, Hierarchy) {
706706
verifyFormat("function automatic x::x x\n"
707707
" (input x);\n"
708708
"endfunction : x");
709+
// Names having to do macros should be recognized.
710+
verifyFormat("function automatic x::x x``x\n"
711+
" (input x);\n"
712+
"endfunction : x");
713+
verifyFormat("function automatic x::x `x\n"
714+
" (input x);\n"
715+
"endfunction : x");
709716
verifyNoCrash("x x(x x, x x);");
710717
}
711718

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
26032603
Tokens = Annotate("module x();\nendmodule");
26042604
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
26052605
EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_VerilogMultiLineListLParen);
2606+
Tokens = Annotate("function automatic `x x();\nendmodule");
2607+
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
2608+
EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_VerilogMultiLineListLParen);
2609+
Tokens = Annotate("function automatic x``x x();\nendmodule");
2610+
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
2611+
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_VerilogMultiLineListLParen);
26062612
Tokens = Annotate("function automatic x::x x();\nendmodule");
26072613
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
26082614
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_VerilogMultiLineListLParen);

0 commit comments

Comments
 (0)