[llvm-bugs] [Bug 36460] New: trailing comma in inializer list confuses formatter
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 20 12:47:08 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36460
Bug ID: 36460
Summary: trailing comma in inializer list confuses formatter
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: andy.somerville at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Created attachment 19917
--> https://bugs.llvm.org/attachment.cgi?id=19917&action=edit
minimal example of trailing comma issue
including trailing comma in initializer list causes formatter to switch
indentation style and splits short parameters one per line.
////////////////// BEGIN minimal example input //////////////////
#include <set>
void someFunction( std::set<int> & someSet )
{
// initializer lists inside a constructor
std::set<std::set<int >> firstSet{
{ 1, 2, 3, 5,}, // final comma internal initializer
{ 6, 7, 8,9}
};
std::set<std::set<int >> otherSet = {
{ 1, 2, 3, 5}, // no final comma internal initializer
{ 6, 7, 8,9}
};
auto middleSet = std::set<std::set<int >>{
{ 1, 2, 3, 5, }, // final comma external initializer
{ 6, 7, 8,9},
};
auto finalSet = std::set<std::set<int >>({
{ 1, 2, 3, 5 }, // final comma external initializer
{ 6, 7, 8,9},
});
}
////////////////// END minimal example input //////////////////
$ clang-format-5.0 -style=llvm ./minimal_initializer_test.cpp
////////////////// BEGIN minimal example output //////////////////
#include <set>
void someFunction(std::set<int> &someSet) {
// initializer lists inside a constructor
std::set<std::set<int>> firstSet{{
1,
2,
3,
5,
}, // final comma internal initializer
{6, 7, 8, 9}};
std::set<std::set<int>> otherSet = {
{1, 2, 3, 5}, // no final comma internal initializer
{6, 7, 8, 9}};
auto middleSet = std::set<std::set<int>>{
{
1,
2,
3,
5,
}, // final comma external initializer
{6, 7, 8, 9},
};
auto finalSet = std::set<std::set<int>>({
{1, 2, 3, 5}, // final comma external initializer
{6, 7, 8, 9},
});
}
////////////////// END minimal example output //////////////////
--
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/20180220/6f51f632/attachment.html>
More information about the llvm-bugs
mailing list