[llvm-bugs] [Bug 40459] New: clang-format over-indents inner initialiser lists
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jan 25 01:59:16 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40459
Bug ID: 40459
Summary: clang-format over-indents inner initialiser lists
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: john.j.beard at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Using a format including the following (clang-format version 7.0.1
(tags/RELEASE_701/final)
BasedOnStyle: LLVM
BreakBeforeBraces: Allman
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
IndentWidth: 4
Try to format the following code:
std::vector<std::vector<int>> data{
{
42, // The Answer
},
};
The above is how I expect it to look, considering that
`Cpp11BracedListStyle` is set to `false`, so it should use the block
indent (4), not the continuation indent (8). From the clang-format
docs [1], if this is `true`:
> "Important differences: - No spaces inside the braced list. - No line
> break before the closing brace. - Indentation with the continuation
> indent, not with the block indent."
So, I expected to see the "block indent" (4) used. However, what I
*actually* get is:
std::vector<std::vector<int>> data{
{ // indent 4 - OK
42, // Indented by 4 + 8 (expected 4 + 4)
},
};
As you can see, the "outer" initialiser list is indented by 4 (as
expected), but the "inner" list's elements are indented by a further
8, not 4.
Can be reproduced in the terminal with:
$ echo "std::vector<std::vector<int>data{{42,},};" | clang-format
-style="{BasedOnStyle: llvm, BreakBeforeBraces: Allman,
ContinuationIndentWidth: 8, Cpp11BracedListStyle: false, IndentWidth: 4}"
[1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
--
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/20190125/b217a98e/attachment.html>
More information about the llvm-bugs
mailing list