Members that are themselves wrapped in fake parentheses would lead to
AvoidBinPacking be set on the wrong ParenState.
After:
vector<int> aaaa = {
aaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaa.aaaaaaa,
aaaaaa.aaaaaaa,
aaaaaa.aaaaaaa,
aaaaaa.aaaaaaa,
};
Before we were falling back to bin-packing these.
llvm-svn: 290259
We still want to try in linewrap within single elements of a 1-column
list.
After:
Type *Params[] = {PointerType::getUnqual(FunctionType::get(
Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
Builder.getInt8PtrTy(),
Builder.getInt32Ty(),
LongType,
LongType,
LongType};
Before:
No line break in the first element, so column limit violation.
llvm-svn: 290090
column limit.
Single-column layout basically means that we format the list with one
element per line. Not doing that when there is a column limit violation
doesn't change the fact that there is an item that doesn't fit within
the column limit.
Before (with a column limit of 30):
std::vector<int> a = {
aaaaaaaa, aaaaaaaa,
aaaaaaaa, aaaaaaaa,
aaaaaaaaaa, aaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaa};
After:
std::vector<int> a = {
aaaaaaaa,
aaaaaaaa,
aaaaaaaa,
aaaaaaaa,
aaaaaaaaaa,
aaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaa};
(and previously we would have formatted like "After" it wasn't for the one
item that is too long)
llvm-svn: 290084
This patch corresponds to reviews:
http://reviews.llvm.org/D15120http://reviews.llvm.org/D19125
It adds support for the __float128 keyword, literals and target feature to
enable it. Based on the latter of the two aforementioned reviews, this feature
is enabled on Linux on i386/X86 as well as SystemZ.
This is also the second attempt in commiting this feature. The first attempt
did not enable it on required platforms which caused failures when compiling
type_traits with -std=gnu++11.
If you see failures with compiling this header on your platform after this
commit, it is likely that your platform needs to have this feature enabled.
llvm-svn: 268898
Since this patch provided support for the __float128 type but disabled it
on all platforms by default, some platforms can't compile type_traits with
-std=gnu++11 since there is a specialization with __float128.
This reverts the patch until D19125 is approved (i.e. we know which platforms
need this support enabled).
llvm-svn: 266460
This patch corresponds to review:
http://reviews.llvm.org/D15120
It adds support for the __float128 keyword, literals and a target feature to
enable it. This support is disabled by default on all targets and any target
that has support for this type is free to add it.
Based on feedback that I've received from target maintainers, this appears to
be the right thing for most targets. I have not heard from the maintainers of
X86 which I believe supports this type. I will subsequently investigate the
impact of enabling this on X86.
llvm-svn: 266186
initializers. For now, only use it for 20 items or more. Otherwise,
clang-format formats these one-per-line and thus increases the vertical
code size a lot.
llvm-svn: 256246
Summary:
If this option is set, clang-format will always insert a line wrap, e.g.
before the first parameter of a function call unless all parameters fit
on the same line. This obviates the need to make a decision on the
alignment itself.
Use this style for Google's JavaScript style and add some minor tweaks
to correctly handle nested blocks etc. with it. Don't use this option
for for/while loops.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D14104
llvm-svn: 251405
Summary: It breaks the build for the ASTMatchers
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D13893
llvm-svn: 250827
To implement this nicely, add a function that merges two sets of
replacements that are meant to be done in sequence. This functionality
will also be useful for other applications, e.g. formatting the result
of clang-tidy fixes.
llvm-svn: 248367
instead of BinPackParameters. Braced lists are used as constructor
calls in many places and so the bin-packing should follow what is done
for other calls and not what is done for function declarations.
llvm-svn: 238184
comments. At some point, we might to want to a layout with a different
number of columns instead, but at the moment, this causes more
confusion than it's worth.
llvm-svn: 237427
Specifically, calculate the deviation between the shortest and longest
element (which is used to prevent excessive whitespace) per column, not
overall. This automatically handles the corner cases of a single column
and a single row so that the actualy implementation becomes simpler.
Before:
vector<int> x = {1,
aaaaaaaaaaaaaaaaaaaaaa,
2,
bbbbbbbbbbbbbbbbbbbbbb,
3,
cccccccccccccccccccccc};
After:
vector<int> x = {1, aaaaaaaaaaaaaaaaaaaaaa,
2, bbbbbbbbbbbbbbbbbbbbbb,
3, cccccccccccccccccccccc};
llvm-svn: 236992
In particular:
* If the difference between the longest and shortest element, we copped
out of column format completely. Now, we instead allow to arrange
these in a single column, essentially enforcing a one-per-line format.
* Allow column layout even if there are braced lists. Especially, if
there are many short lists, this can be beneficial. The bad case,
where there is a long nested init list is usually caught as we now
limit the length difference of the longest and shortest element.
llvm-svn: 236851
This patch only considers the difference between the length of the
shortest and longest element, but we might want to look at other
features (token count, etc.) in future.
Before:
std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{
aaaaaaa, aaaaaaaaaa,
aaaaa, aaaaaaaaaaaaaaa,
aaa, aaaaaaaaaa,
a, aaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa,
aaaaaaa, a};
After:
std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{
aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a,
aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a};
llvm-svn: 218111
With BinPackParameters=false and Cpp11BracedListStyle=true (i.e. mostly
for Chromium):
Before:
const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff,
ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk};
After:
const Aaaaaa aaaaa = {aaaaa,
bbbbb,
ccccc,
ddddd,
eeeee,
ffffff,
ggggg,
hhhhhh,
iiiiii,
jjjjjj,
kkkkkk};
This fixes llvm.org/PR19359. I am not sure we'll want this in all cases
in the long run, but I'll guess we'll get feedback on that.
llvm-svn: 206458
- Format a braced list with one element per line if it has nested
braced lists.
- Use a column layout only when the list has 6+ elements (instead of the
current 4+ elements).
llvm-svn: 198869
Add a severe penalty for not using column layout for braced lists. If
there are solutions with column layout, these are generally preferable
over bin-packed solutions.
Before:
std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{ aaaaaaa, aaaaaaaaaa, aaaaa,
aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a,
aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaa,
aaaaaaa, a };
After:
std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{
aaaaaaa, aaaaaaaaaa,
aaaaa, aaaaaaaaaaaaaaa,
aaa, aaaaaaaaaa,
a, aaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa,
aaaaaaa, a
};
llvm-svn: 195546
Specifically, if a braced list has at least one nested braced list,
format it either all on one line or in one column (i.e. one item per
line).
This seems in general to be an improvement as the structure of nested
braced lists can make a tightly packed outer braced list hard to read.
llvm-svn: 193345
Summary:
This fixes various issues with mixed tabs and spaces handling, e.g.
when realigning block comments.
Reviewers: klimek, djasper
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1608
llvm-svn: 190395
Specific arrangements of comments after trailing commas could confuse
the column width calculation, e.g. in:
vector<int> x = { a, b,
/* some */ /* comment */ };
llvm-svn: 189211
Before, this was causing errors.
Also exit early in breakProtrudingToken() (before the expensive call to
SourceManager::getSpellingColumnNumber()). This makes formatting huge
(100k+-item) braced lists possible.
llvm-svn: 189094
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018