| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
@{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
: regularFont, };
Now:
@{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
regularFont, };
':'s in dictionary literals (and the corresponding {}s) are now marked as
TT_ObjCDictLiteral too, which makes further improvements to dict literal
layout possible.
llvm-svn: 182716
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Added stack of preprocessor branching directives, and ignore all tokens
inside #if 0 except for preprocessor directives.
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D855
llvm-svn: 182658
|
|
|
|
|
|
| |
Before: f(new vector<int> { 1, 2, 3 });
After: f(new vector<int>{ 1, 2, 3 });
llvm-svn: 182614
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously we started sequences to align for single line comments when
the previous line had a trailing comment, but the sequence was broken
for other reasons.
Now we re-format:
// a
// b
f(); // c
to:
// a
// b
f(); // c
llvm-svn: 182608
|
|
|
|
|
|
|
|
|
|
| |
Now correctly leaves:
f(); // comment
// comment
g(); // comment
... alone if the middle comment was aligned with g() before formatting.
llvm-svn: 182605
|
|
|
|
|
|
| |
Also fix a minor bug for constructor initializers with braced init lists.
llvm-svn: 182601
|
|
|
|
|
|
| |
Before: vector<int> v{ -1};
After: vector<int> v{-1};
llvm-svn: 182597
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously we would align:
f(); // comment
// other comment
g();
Even if // other comment was at the start of the line. Now we do not
align trailing comments if they have been already aligned correctly
with the next line.
Thus,
f(); // comment
// other comment
g();
will not be changed, while:
f(); // comment
// other commment
g();
will lead to the two trailing comments being aligned.
llvm-svn: 182577
|
|
|
|
|
|
|
|
|
|
|
| |
Replaces the use of WhitespaceStart + WhitspaceLength.
This made a bug in the formatter obvous where we would incorrectly
calculate the next column.
FIXME: There's a similar bug left regarding TokenLength. We should
probably also move to have a TokenRange instead.
llvm-svn: 182572
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
vector<int> x { 1, 2, 3 };
After:
vector<int> x{ 1, 2, 3 };
Also add a style option to remove the spaces inside braced lists,
so that the above becomes:
std::vector<int> v{1, 2, 3};
llvm-svn: 182570
|
|
|
|
| |
llvm-svn: 182569
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allows formatting of C++11 braced init list constructs, like:
vector<int> v { 1, 2, 3 };
f({ 1, 2 });
This involves some changes of how tokens are handled in the
UnwrappedLineFormatter. Note that we have a plan to evolve the
design of the token flow into one where we create all tokens
up-front and then annotate them in the various layers (as we
currently already have to create all tokens at once anyway, the
current abstraction does not help). Thus, this introduces
FIXMEs towards that goal.
llvm-svn: 182568
|
|
|
|
| |
llvm-svn: 182476
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of selectively storing some changes and directly generating
replacements for others, we now notify the WhitespaceManager of the
whitespace before every token (and optionally with more changes inside
tokens).
Then, we run over all whitespace in the very end in original source
order, where we have all information available to correctly align
comments and escaped newlines.
The future direction is to pull more of the comment alignment
implementation that is now in the BreakableToken into the
WhitespaceManager.
This fixes a bug when aligning comments or escaped newlines in unwrapped
lines that are handled out of order:
#define A \
f({ \
g(); \
});
... now gets correctly layouted.
llvm-svn: 182467
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
clang-format was a bit too aggressive when trying to keep labels and
values on the same line.
Before:
llvm::outs()
<< "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 182458
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This only affects styles that prevent bin packing. There, a break after
a template declaration also forced a line break after the function name.
Before:
template <class SomeType, class SomeOtherType>
SomeType
SomeFunction(SomeType Type, SomeOtherType OtherType) {}
After:
template <class SomeType, class SomeOtherType>
SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}
This fixes llvm.org/PR16072.
llvm-svn: 182457
|
|
|
|
|
|
|
| |
Reduce the preference for breaking before a trailing 'const' according
to review comments on r182362.
llvm-svn: 182455
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If clang-format is confronted with long and deeply nested lines (e.g.
complex static initializers or function calls), it can currently try too
hard to find the optimal solution and never finish. The reason is that
the memoization does not work effectively for deeply nested lines.
This patch removes an earlier workaround and instead opts for
accepting a non-optimal solution in rare cases. However, it only does
so only in cases where it would have to analyze an excessive number of
states (currently set to 10000 - the most complex line in Format.cpp
requires ~800 states) so this should not change the behavior in a
relevant way.
llvm-svn: 182449
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
void someLongFunction(
int someLongParameter) const;
After:
void someLongFunction(int someLongParameter)
const;
Also slightly cleanup tests.
llvm-svn: 182362
|
|
|
|
|
|
| |
configuration files invalid.
llvm-svn: 182290
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: + improved handling of default style and predefined styles.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D813
llvm-svn: 182205
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Basically, the new rule is: The opening "{" always has to be on the
same line as the first element if the braced list is nested
(e.g. in another braced list or in a function).
The solution that clang-format produces almost always adheres to this
rule anyway and this makes clang-format significantly faster for larger
lists. Added a test cases for the only exception I could find
(which doesn't seem to be very important at first sight).
llvm-svn: 182082
|
|
|
|
| |
llvm-svn: 182003
|
|
|
|
|
|
|
|
|
|
| |
This enables things like:
for (int &v : vec) v *= 2;
Enabled for Google style.
llvm-svn: 182000
|
|
|
|
|
|
|
|
|
|
|
|
| |
It turns out that several implementations go through the trouble of
setting up a SourceManager and Lexer and abstracting this into a
function makes usage easier.
Also abstracts SourceManager-independent ranges out of
tooling::Refactoring and provides a convenience function to create them
from line ranges.
llvm-svn: 181997
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
void f() {}
void g() {
} // comment
After:
void f() {}
void g() {} // comment
llvm-svn: 181996
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
f("a", "b"
"c");
After:
f("a", "b"
"c");
llvm-svn: 181980
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
namespace abc { class SomeClass; }
namespace def { void someFunction() {} }
After:
namespace abc {
class Def;
}
namespace def {
void someFunction() {}
}
Rationale:
a) Having anything other than forward declaration on the same line
as a namespace looks confusing.
b) Formatting namespace-forward-declaration-combinations different
from other stuff is inconsistent.
c) Wasting vertical space close to such forward declarations really
does not affect readability.
llvm-svn: 181887
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the long run, this will probably be better fixed by a proper
expression parser..
Before:
template <typename F>
Matcher(const Matcher<F> & Other,
typename enable_if_c < is_base_of<F, T>::value &&
!is_same<F, T>::value > ::type * = 0)
: Implementation(new ImplicitCastMatcher<F>(Other)) {}
After:
template <typename F>
Matcher(const Matcher<F> & Other,
typename enable_if_c<is_base_of<F, T>::value &&
!is_same<F, T>::value>::type * = 0)
: Implementation(new ImplicitCastMatcher<F>(Other)) {}
llvm-svn: 181884
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
template <typename A>
SomeLoooooooooooooooooooooongType<
typename some_namespace::SomeOtherType<A>::Type> Function() {}
After:
template <typename A>
SomeLoooooooooooooooooooooongType<
typename some_namespace::SomeOtherType<A>::Type>
Function() {}
llvm-svn: 181877
|
|
|
|
| |
llvm-svn: 181872
|
|
|
|
|
|
|
| |
We only ever implemented one and that one is not actually all that
helpful (e.g. gets incorrectly triggered by macros).
llvm-svn: 181871
|
|
|
|
|
|
|
|
|
|
|
| |
The function type detection in r181438 and r181764 detected function
types too eagerly. This led to inconsistent formatting of inline
assembly and (together with r181687) to an incorrect formatting of calls
in macros.
Before: #define DEREF_AND_CALL_F(parameter) f (*parameter)
After: #define DEREF_AND_CALL_F(parameter) f(*parameter)
llvm-svn: 181870
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
llvm-svn: 181828
|
|
|
|
| |
llvm-svn: 181779
|
|
|
|
|
|
|
|
|
|
|
| |
We have been assuming that CharSourceRange::getTokenRange() by itself
expands a range until the end of a token, but in fact it only sets
IsTokenRange to true. Thus, we have so far only considered the first
character of the last token to belong to an unwrapped line. This
did not really manifest in symptoms as all edit integrations
expand ranges to fully lines.
llvm-svn: 181778
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before (in styles that allow it), clang-format would not merge an
if statement onto a single line, if only the second line was format
(e.g. in an editor integration):
if (a)
return; // clang-format invoked on this line.
With this patch, this gets properly merged to:
if (a) return; // ...
llvm-svn: 181770
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes indentation where there are for example multiple closing
parentheses after a string literal, and where those parentheses
run over the end of the line.
During testing this revealed a bug in the implementation of
breakProtrudingToken: we don't want to change the state if we didn't
actually do anything.
llvm-svn: 181767
|
|
|
|
|
|
| |
Before: A<sizeof (*x)> a;
After: A<sizeof(*x)> a;
llvm-svn: 181764
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
#define A(X) \
"aaaaa" #X "bbbbbb" \
"ccccc"
After:
#define A(X) \
"aaaaa" #X "bbbbbb" \
"ccccc"
llvm-svn: 181732
|
|
|
|
|
|
| |
manually calling .flush().
llvm-svn: 181702
|
|
|
|
| |
llvm-svn: 181701
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now support "Linux" and "Stroustrup" brace breaking styles, which
gets us one step closer to support formatting WebKit, KDE & Linux code.
Linux brace breaking style:
namespace a
{
class A
{
void f()
{
if (x) {
f();
} else {
g();
}
}
}
}
Stroustrup brace breaking style:
namespace a {
class A {
void f()
{
if (x) {
f();
} else {
g();
}
}
}
}
llvm-svn: 181700
|
|
|
|
|
|
| |
Thanks to Kim Gräsman for help!
llvm-svn: 181699
|
|
|
|
|
|
| |
This is required for kernel linux kernel style formatting.
llvm-svn: 181693
|
|
|
|
|
|
|
|
| |
Fake parentheses (i.e. emulated parentheses used to correctly handle
binary expressions) used to prevent the optimization implemented in
r180264.
llvm-svn: 181692
|
|
|
|
|
|
|
| |
This is required for various styles that are for example based on
8-indent.
llvm-svn: 181690
|
|
|
|
|
|
|
|
|
| |
This seems to be the vastly more common case. If we find enough
examples to the contrary, we can make it smarter.
Before: #define MACRO void f(int * a)
After: #define MACRO void f(int *a)
llvm-svn: 181687
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Otherwise (when indenting from the wrapped -> or .), this looks
like a confusing indent.
Before:
aaaaaaa //
.aaaaaaa( //
aaaaaaa);
After:
aaaaaaa //
.aaaaaaa( //
aaaaaaa);
llvm-svn: 181595
|
|
|
|
|
|
|
|
| |
Thereby, the macro is consistently formatted (including the trailing
escaped newlines) even if clang-format is invoked only on single lines
of the macro.
llvm-svn: 181590
|