[llvm-bugs] [Bug 45388] New: Clang Format AlignConsecutiveAssignments breaks based on line length and/or identifier length
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 1 11:30:05 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45388
Bug ID: 45388
Summary: Clang Format AlignConsecutiveAssignments breaks based
on line length and/or identifier length
Product: clang
Version: 9.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: clappi77 at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Created attachment 23304
--> https://bugs.llvm.org/attachment.cgi?id=23304&action=edit
Clang format options used to recreate this issue
I found I have to run clang-format more than once sometimes for some reason.
It appears that clang-format will inject a formatting error (probably because
it's confused about column alignment with adjoining lines) which is then
corrected by running a second time.
I was able to recreate the issue on the following snippet.
void Blah() {
const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIFIER_NAME_HERE = (4 * 1024);
//My comment of a specific size 12345678901
const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIF = (4 * 1024);
// My comment of a specific size 12345678901
}
It seems that clang-format will unindent the second constant's assignment,
which then gets resolved if I re-run the formatter a second time. Here's the
output I get after I run clang-format the first time:
void Blah() {
const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIFIER_NAME_HERE = (4 * 1024);
// My comment of a specific size 12345678901
const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIF = (4 * 1024); // My comment
of a specific size 12345678901
}
Then if I run it a second time I get the desired output below:
void Blah() {
const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIFIER_NAME_HERE = (4 * 1024);
// My comment of a specific size 12345678901
const uint32_t MY_REALLY_LONG_CONSTANT_IDENTIF = (4 * 1024);
// My comment of a specific size 12345678901
}
Interestingly, this seems specific to the total line length of the first
constant (the line with the formatting error in the comment) and the constant
identifier length for the second constant. If I shorten either the comment of
the first constant or the name of the second constant at all the formatter
works properly the on the first run and no second run is necessary.
As far as I can tell, the line is still well within the column limit of 150
specified in the options, so I'm not sure why this is happening.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200401/e84dc1ad/attachment-0001.html>
More information about the llvm-bugs
mailing list