Age | Commit message (Collapse) | Author |
|
This fixes llvm.org/PR15167.
Before:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {
}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}
After:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175800 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This fixes llvm.org/PR15033.
Also: Always break before a parameter, if the previous parameter was
split over multiple lines. This was necessary to make the right
decisions in for-loops, almost always makes the code more readable and
also fixes llvm.org/PR14873.
Before:
for (llvm::ArrayRef<NamedDecl *>::iterator I = FD->getDeclsInPrototypeScope()
.begin(), E = FD->getDeclsInPrototypeScope().end();
I != E; ++I) {
}
foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccccc), d, bar(e, f));
After:
for (llvm::ArrayRef<NamedDecl *>::iterator
I = FD->getDeclsInPrototypeScope().begin(),
E = FD->getDeclsInPrototypeScope().end();
I != E; ++I) {
}
foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccccc),
d, bar(e, f));
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175741 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Now correctly indents (again):
a = a + "a"
"a"
"a";
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175630 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
We now indent the following correctly:
1. some + "literal" /* comment */
"literal";
2. breaking string literals after which we have another string literal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175628 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
If the code author decides to put empty lines anywhere into the code we
should treat them equally, i.e. reduce them to the configured
MaxEmptyLinesToKeep.
With this change, we e.g. keep the newline in:
SomeType ST = {
// First value
a,
// Second value
b
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175620 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
An alternative strategy to calculating the break on demand when hitting
a token that would need to be broken would be to put all possible breaks
inside the token into the optimizer.
Currently only supports breaking at spaces; more break points to come.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175613 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
.. and a test that triggers it in valid albeit questionable code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175554 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
We can now format:
#define A template <typename T>
Before this created a segfault :-/.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175533 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
The key bug was
if (Other.StartOfLineLevel < StartOfLineLevel) ..
instead of
if (Other.StartOfLineLevel != StartOfLineLevel) ..
Also cleaned up the function to be more consistent in the comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175500 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
In builder-type calls, it can be very confusing to just indent
parameters from the start of the line. Instead, indent 4 from the
correct function call.
Before:
aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break
aaaaaaaaaaaaaa);
aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaaaaaaaaaa();
After:
aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break
aaaaaaaaaaaaaa);
aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()
->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaaaaaaaaaa();
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175444 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);
After:
aaaaaaa->aaaaaaa
->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaa(aaaaaaaaaaaaaaa);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175441 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
An unwrapped line can get moved around if there is no newline before
it and the previous line was formatted.
Example:
template<typename T> // Cursor is on this line when hitting "format"
T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }
"return .." is the second unwrapped line in this scenario. I does not
touch any reformatted region. Thus, the result of formatting is:
template <typename T> T *getFETokenInfo() const { return static_cast<T *>(FETokenInfo); }
After second format (and arguably desired end-result):
template <typename T> T *getFETokenInfo() const {
return static_cast<T *>(FETokenInfo);
}
This fixes: llvm.org/PR15060.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175440 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This fixes llvm.org/PR15248.
Before:
Test::Test(int b) : a(b *b) {}
for (int i = 0; i < a *a; ++i) {}
After:
Test::Test(int b) : a(b * b) {}
for (int i = 0; i < a * a; ++i) {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175439 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Otherwise, other parameters can be quite hidden.
Reformatted unittests/Format/FormatTest.cpp after this.
Before:
someFunction("Always break between multi-line"
" string literals", and, other, parameters);
After:
someFunction("Always break between multi-line"
" string literals",
and, other, parameters);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175436 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175432 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175374 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
The current heuristic assumes that there can't be binary operators in
builder-type calls (excluding assigments). However, it also excluded
< and > in general, which is wrong. Now they are only excluded if they
are template parameters.
Before:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa()i
.aaaaaa() < aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();
After:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <
aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175291 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
ostream &operator
<<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);
After:
ostream &operator<<(ostream &out,
some::ns::SomeReallyLongType WithSomeReallyLongValue);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175286 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This got lost and was untested as the same effect is achieved by
avoiding bin packing, which is active in Google style by default.
However, moving forward, we want more control over the bin packing
option(s) and thus, this flag should work as expected.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175277 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This is almost always more readable.
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa;
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
? aaaaaaaaaaaaaaaaaaaaaaaaaaa
: aaaaaaaaaaaaaaaaaaaaaaaaaaa;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175262 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
.aaaaaaaaaaaaaaaaa());
After:
aaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa());
Not sure which of the formattings above is better, but we should not pick
one by accident.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175165 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This gives a clearer separation of the context, e.g. in GMOCK
statements.
Before:
EXPECT_CALL(SomeObject,
SomeFunction(Parameter)).WillRepeatedly(Return(SomeValue));
After:
EXPECT_CALL(SomeObject, SomeFunction(Parameter))
.WillRepeatedly(Return(SomeValue));
Minor format cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175162 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
So far, clang-format has always assumed the whitespace belonging to the
subsequent token. This has the negative side-effect that when
clang-format formats a line, it does not remove its trailing whitespace,
as it belongs to the next token.
Thus, this patch fixes most of llvm.org/PR15062.
We are not zapping a file's trailing whitespace so far, as this does not
belong to any token we see during formatting. We need to fix this in a
subsequent patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175152 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
The formatter can now format:
void aaaaaaaaaaaaaaaaaa(int level,
double *min_x,
double *max_x,
double *min_y,
double *max_y,
double *min_z,
double *max_z, ) {
}
Although this is invalid code, it frequently happens during development and
clang-format should be nicer :-).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175151 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This fixes llvm.org/PR15179.
Before:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};
After:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175147 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This has so far been disabled for Google style, but should be done
before breaking at nested name specifiers or in template parameters.
Before (in Google style):
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa<
T>::aaaaaaa() {}
After:
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaa() {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175074 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Due to an error in one of the expressions, we used to not align comments
although it would have been possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175068 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Fix some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175052 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
- clear ownership: the SpecificBumpPtrAllocator owns all StateNodes
- this allows us to simplify the memoization data structure into a
std::set (FIXME: figure out whether we want to use a hash based
data structure).
- introduces StateNode as recursive data structure, instead of using
Edge and the Seen-map combined to drill through the graph
- using a count to stabilize the penalty instead of relying on the
container
- pulled out a method to forward-apply states in the end
This leads to a ~40% runtime decrease on Nico's benchmark.
Main FiXME is that the parameter lists of some function get too long.
I'd vote for either pulling the Queue etc into the Formatter proper,
or creating an inner class just for the search algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175051 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
No functionality change. Also add another cast test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175029 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Not all casts are correctly detected yet, but it helps in some cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175028 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175015 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Still the formatting can be improved, but at least we don't assert any
more. This happened when trying to format lib/Sema/SemaType.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175003 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
and instead used a signed integer parameter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174996 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174986 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before (if only the second line was reformatted):
void f() {}
void g() {}
After:
void f() {}
void g() {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174978 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This redoes how '*' and '&' are classified as pointer / reference markers when
followed by ')', '>', or ','.
Previously, determineStarAmpUsage() marked a single '*' and '&' followed by
')', '>', or ',' as pointer or reference marker. Now, all '*'s and '&'s
preceding ')', '>', or ',' are marked as pointer / reference markers. Fixes
PR14884.
Since only the last '*' in 'int ***' was marked as pointer before (the rest
were unary operators, which don't reach spaceRequiredBetween()),
spaceRequiredBetween() now had to be thought about handing multiple '*'s in
sequence.
Before:
return sizeof(int * *);
Type **A = static_cast<Type * *>(P);
Now:
return sizeof(int**);
Type **A = static_cast<Type **>(P);
While here, also make all methods of AnnotatingParser except parseLine()
private.
Review URL: http://llvm-reviews.chandlerc.com/D384
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174975 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
for (id foo in[self getStuffFor : bla]) {
}
Now:
for (id foo in [self getStuffFor:bla]) {
}
"in" is treated as loop keyword if the line starts with "for", and as a
regular identifier else. To check for "in", its IdentifierInfo is handed
through a few layers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174889 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
You can run tests with -debug instead now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174880 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
In google style, trailing comments are separated by two spaces. This
patch fixes the counting of these spaces and prevents clang-format from
creating a line with 81 columns.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174879 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Now correctly formats:
#define A \
\
b;
to
#define A b;
Added the state whether an unwrapped line is a macro to the debug
output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174878 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
operatorvoid*();
operator vector< A< A>>();
After:
operator void *();
operator vector<A<A> >();
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174863 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
The more general code for formatting ObjC method exprs does this and more,
it's no longer necessary to special-case this. No behavior change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174843 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Before:
@{
foo:
bar
}
;
Now:
@{ foo : bar };
parseBracedList() already does the right thing from an UnwrappedLineParser
perspective, so check for "@{" in all loops that process constructs that can
contain expressions and call parseBracedList() if found.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174840 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174823 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Use this to add a space after "@[" and before "]" for now.
Later, I want to use this to format multi-line array literals nicer, too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174822 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This correctly formats:
{
a;
}
where { is incorrectly indented by 2, but is at level 0, when
reformatting only 'a;'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174737 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Fixes llvm.org/PR14916.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174720 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
They are much easier to handle when attached to the previous token.
Before:
unsigned Indent =
formatFirstToken(TheLine.First, IndentForLevel[TheLine.Level] >=
0 ? IndentForLevel[TheLine.Level]
: TheLine.Level * 2, TheLine.InPPDirective, PreviousEndOfLineColumn);
After:
unsigned Indent = formatFirstToken(
TheLine.First, IndentForLevel[TheLine.Level] >= 0
? IndentForLevel[TheLine.Level] : TheLine.Level * 2,
TheLine.InPPDirective, PreviousEndOfLineColumn);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174718 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
With this patch, the formatter introduces 'fake' parenthesis according
to the operator precedence of binary operators.
Before:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA || bbbb &
BBBBBBBBBBBBBBBBBBBBBBBBBBBBB || cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);
After:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ||
bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB ||
cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);
Future improvements:
- Get rid of some of the hacky ways to nicely format certain constructs.
- Merge this parser and the AnnotatingParser as we now have several parsers
that analyze (), [], etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174714 91177308-0d34-0410-b5e6-96231b3b80d8
|