[PATCH] D149562: [clang-format] Stop comment disrupting indentation of Verilog ports
sstwcw via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 30 16:55:32 PDT 2023
sstwcw created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
sstwcw requested review of this revision.
Before:
module x
#( //
parameter x)
( //
input y);
endmodule
After:
module x
#(//
parameter x)
(//
input y);
endmodule
If the first line in a port or parameter list is not a comment, the
following lines would be aligned to the first line as intended:
module x
#(parameter x1,
parameter x2)
(input y,
input y2);
endmodule
Previously, the indentation would be changed to an extra continuation
indentation relative to the start of the parenthesis or the hash if
the first token inside the parentheses is a comment. It is a feature
introduced in ddaa9be97839. The feature enabled one to insert a `//`
comment right after an opening parentheses to put the function
arguments on a new line with a small indentation regardless of how
long the function name is, like this:
someFunction(anotherFunction( // Force break.
parameter));
`
People are unlikely to use this feature in a Verilog port list because
the formatter already puts the port list on its own lines. A comment
at the start of a port list is probably a comment for the port on the
next line.
We also removed the space before the comment so that its indentation
would be same as that for a line comment anywhere else in the port
list.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149562
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestVerilog.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149562.518370.patch
Type: text/x-patch
Size: 5576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230430/2f9f5cde/attachment.bin>
More information about the cfe-commits
mailing list