diff options
author | sstwcw <f0gukp2nk@protonmail.com> | 2023-05-16 02:50:07 +0000 |
---|---|---|
committer | sstwcw <f0gukp2nk@protonmail.com> | 2023-05-16 02:56:58 +0000 |
commit | 369e8762b4d658e6e8f8310200aadf043bd7f01e (patch) | |
tree | e135f081cfd6b053f0493d628318bcf03afddb51 /clang/docs | |
parent | 4ddae8b941398a6579d3a6f25aa39a260e441371 (diff) | |
download | llvm-369e8762b4d658e6e8f8310200aadf043bd7f01e.tar.gz |
[clang-format] Stop comment disrupting indentation of Verilog ports
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 will 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 was 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.
Reviewed By: HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D149562
Diffstat (limited to 'clang/docs')
-rw-r--r-- | clang/docs/ClangFormatStyleOptions.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index ce4c39694e0c..56b6b62e3138 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -5069,9 +5069,12 @@ the configuration (without a prefix: ``Auto``). The number of spaces before trailing line comments (``//`` - comments). - This does not affect trailing block comments (``/*`` - comments) as - those commonly have different usage patterns and a number of special - cases. + This does not affect trailing block comments (``/*`` - comments) as those + commonly have different usage patterns and a number of special cases. In + the case of Verilog, it doesn't affect a comment right after the opening + parenthesis in the port or parameter list in a module header, because it + is probably for the port on the following line instead of the parenthesis + it follows. .. code-block:: c++ |