[flang-dev] Code formatting alignment with LLVM

Michael Kruse via flang-dev flang-dev at lists.llvm.org
Mon Mar 2 10:03:03 PST 2020


Am Mo., 2. März 2020 um 11:40 Uhr schrieb David Truby via flang-dev <
flang-dev at lists.llvm.org>:
> Thanks for the reply. My understanding of the concern is that if you
change a line that has trailing comments in a block for example, and the
length of the line changes, all the comments on other lines will be
realigned, and the diff will show every line as having changed even though
only one has. Does that make sense?

Trailing comments are rare in the LLVM code base. Usually comments are
before the line, since not a lot of text fits into the 80 column limit
after a code statement. clang-format indents all comments to the indention
of the first comment, such as:

AStatmentLineUsingATypicalAmountOfCharacters(); // a comment
                                                // trailing on this
                                                // statement consumes
                                                // multiple lines


My suggestion is to not use trailing comments. clang-format otherwise only
re-formats comments if exceeding the 80 column limit.

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20200302/59244042/attachment.html>


More information about the flang-dev mailing list