| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa,
aaaa)) {}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa, aaaa)) {}
llvm-svn: 194210
|
|
|
|
|
|
|
|
| |
As a side-effect, constructors definitions will correctly be recognized
and formatted as function declarations. Tests will be added in a
follow-up patch actually using the correct recognition.
llvm-svn: 194209
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
Constructor::Constructor()
: some_value{ //
aaaaaaa //
} {}
After:
Constructor::Constructor()
: some_value{ //
aaaaaaa //
} {}
llvm-svn: 194204
|
|
|
|
|
|
| |
No functional changes (intended).
llvm-svn: 194179
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, clang-format would always format entire nested blocks, which
can be unwanted e.g. for long DEBUG({...}) statements. Also
clang-format would not allow to merge lines in nested blocks (e.g. to
put "if (a) return;" on one line in Google style).
This is the first step of several refactorings mostly focussing on the
additional functionality (by reusing the "format many lines" code to
format the children of a nested block). The next steps are:
* Pull out the line merging into its own class.
* Seperate the formatting of many lines from the formatting of a single
line (and the analysis of the solution space).
llvm-svn: 194090
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
if (a) {
f();
}
// or else ..
else {
g();
}
After:
if (a) {
f();
}
// or else ..
else {
g();
}
llvm-svn: 193684
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before (clang-format wouldn't change):
#include "a.h"
#include<a>
After:
#include "a.h"
#include <a>
This fixes llvm.org/PR16151.
llvm-svn: 193683
|
|
|
|
|
|
| |
Patch by Christopher Olsen. Thank you!
llvm-svn: 193678
|
|
|
|
|
|
|
|
|
|
|
| |
Same as SpacesInParentheses, this option allows adding a space inside
the '<' and '>' of a template parameter list.
Patch by Christopher Olsen.
This fixes llvm.org/PR17301.
llvm-svn: 193614
|
|
|
|
|
|
|
|
|
|
| |
Before:
operator::A();
After:
operator ::A();
llvm-svn: 193605
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
_versionLabel.text = [
NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"),
[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]
];
After:
_versionLabel.text =
[NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"),
[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]];
This fixed llvm.org/PR17695.
llvm-svn: 193475
|
|
|
|
|
|
| |
clang first so that the build still works.
llvm-svn: 193428
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Specifically make clang-format less eager to break after the opening
parenthesis of a function call.
Before:
aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
Apparently that is preferable. This penalties are adapted
conservatively, we might have to increase them a little bit further.
llvm-svn: 193410
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes llvm.org/PR17682.
Without this patch, the following code leads to invalid reads/writes:
DEBUG({
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
});
#if a
#else
#endif
Because of the #if-#else structure, the code is formatted and annotated
twice and becauce of the nested block, the annotated lines form a
hierarchical structure. This structure was not properly reset between
runs.
llvm-svn: 193352
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
Significant changes:
- Also recognize these literals with missing "@" for robustness.
- Reorganize tests.
llvm-svn: 193325
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Style guide demands a two-space indent.
Before:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];
After:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];
llvm-svn: 193168
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
NSArray *arguments =
@[ kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets", @"--productid", @"com.google.Chrome" ];
After:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];
This fixes llvm.org/PR15231.
llvm-svn: 193167
|
|
|
|
|
|
|
|
|
|
| |
If we run into the second preprocessor branch chain, the first branch
chain might have already set the maximum branch count on that level to
something > 0.
Fixes PR17645.
llvm-svn: 193153
|
|
|
|
|
|
|
|
| |
Now that we iterate on the formatting multiple times when we
have chains of preprocessor branches, we need to correctly reset
the token's previous and next pointer for the first / last token.
llvm-svn: 193071
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
auto PointerBinding = [](const char * S) {};
After:
auto PointerBinding = [](const char *S) {};
This fixes llvm.org/PR17618.
llvm-svn: 193054
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
DEBUG({ // Comment that used to confuse clang-format.
fdafas();
});
Before:
DEBUG({ // Comments are now fine.
fdafas();
});
This fixed llvm.org/PR17619.
llvm-svn: 193051
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before (note the missing space before "..." which can lead to compile
errors):
switch (x) {
case 'A'... 'Z':
case 1... 5:
break;
}
After:
switch (x) {
case 'A' ... 'Z':
case 1 ... 5:
break;
}
llvm-svn: 193050
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
NSDictionary *d = @{ @"nam" : NSUserNam(), @"dte" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo]
};
After:
NSDictionary *d = @{
@"nam" : NSUserNam(),
@"dte" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo]
};
llvm-svn: 193049
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, clang-format would not adjust leading indents if it found a
structural error (e.g. unmatched {}). It seems, however, that
clang-format has gotten good enough at parsing the code structure that
this hurts in almost all cases. Commonly, while writing code, it is
very useful to be able to correclty indent incomplete if statements or
for loops.
In case this leads to errors that we don't anticipate, we need to find
out and fix those.
This fixed llvm.org/PR17594.
llvm-svn: 192988
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This looks ugly and leads to llvm.org/PR17590.
Before (with AlwaysBreakBeforeMultilineStrings):
return
"aaaa"
"bbbb";
After:
return "aaaa"
"bbbb";
llvm-svn: 192984
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Specifically, prefer breaking before trailing annotations over breaking
before the first parameter.
Before:
void ffffffffffffffffffffffff(
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;
After:
void ffffffffffffffffffffffff(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
OVERRIDE;
llvm-svn: 192983
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa().has<
bbbbbbbbbbbbbbbbbbbbb>();
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaa()
.aaaaaaaaaaaaaaaaaaaaaaaaaa()
.has<bbbbbbbbbbbbbbbbbbbbb>();
llvm-svn: 192981
|
|
|
|
|
|
| |
Patch by Kim Gräsman. Thank you!
llvm-svn: 192964
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
indentation with tabs.
Summary:
Store IndentationLevel in ParentState and use it instead of the
Line::Level when indening.
Also fixed incorrect indentation level calculation in formatFirstToken.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1797
llvm-svn: 192563
|
|
|
|
|
|
|
|
| |
While it is mostly a user error to have the extra semicolon,
formatting it graciously will correctly format in the cases
where we do not fully understand the code (macros).
llvm-svn: 192543
|
|
|
|
| |
llvm-svn: 192535
|
|
|
|
| |
llvm-svn: 192524
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
This way we avoid breaking code which uses unknown preprocessor
directives with long string literals. The specific use case in
http://llvm.org/PR17035 isn't very common, but it seems to be a good idea to
avoid this kind of problem anyway.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1813
llvm-svn: 192507
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now correctly format:
void SomeFunction(int param1,
#ifdef X
NoTemplate param2,
#else
template <
#ifdef A
MyType<Some> >
#else
Type1, Type2>
#endif
param2,
#endif
param3) {
f();
}
llvm-svn: 192503
|
|
|
|
|
|
|
|
|
|
|
| |
In certain macros or incorrect string literals, the token stream can
contain 'unknown' tokens, e.g. a single backslash or a set of empty
ticks. clang-format simply treated them as whitespace and removed them
prior to this patch.
This fixes llvm.org/PR17215
llvm-svn: 192490
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Colon was incorrectly detected as a start of inheritance list. Fixed.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1884
llvm-svn: 192349
|
|
|
|
|
|
|
|
|
| |
Before, clang-format would always insert a linebreak before the comment
in code like:
template <typename T> // T can be A, B or C.
struct S {};
llvm-svn: 192297
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< //
aaaaaaaaaaaaaaaa> {};
struct aaaaaaaaaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa<
aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa> {};
After:
struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< //
aaaaaaaaaaaaaaaa> {};
struct aaaaaaaaaaaaaaaaaaaa
: public aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaa> {};
llvm-svn: 192187
|
|
|
|
|
|
|
|
|
| |
Specifically make ConstructorInitializerAllOnOneLineOrOnePerLine work
nicely with BreakConstructorInitializersBeforeComma.
This fixes llvm.org/PR17395.
llvm-svn: 192168
|
|
|
|
| |
llvm-svn: 192094
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Formatting:
class C {
public:
f();
};
Now leads to:
class C {
public:
f();
};
llvm-svn: 192062
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Pure refactoring, should be no semantic changes.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1796
llvm-svn: 191772
|
|
|
|
|
|
|
|
|
| |
The help text for clang-format's -style option and the function that processes
its value is moved to libFormat in this patch. The goal is to enable other
tools that use libFormat and also have a -style option to behave consistently
with clang-format.
llvm-svn: 191666
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, comments, could totally confuse it.
Before:
return
// true if code is one of a or b.
code == a ||
code == b;
After:
return
// true if code is one of a or b.
code == a || code == b;
llvm-svn: 191654
|
|
|
|
|
|
|
|
| |
Before, this could would lead to an assert:
llvm::errs() << "
<< a;
llvm-svn: 191639
|
|
|
|
| |
llvm-svn: 191530
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Changed UseTab to be a enum with three options: Never, Always,
ForIndentation (true/false are still supported when reading .clang-format).
IndentLevel should currently be propagated correctly for all tokens, except for
block comments. Please take a look at the general idea before I start dealing
with block comments.
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1770
llvm-svn: 191527
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
divisible by TabWidth.
Summary:
The width of the first inserted tab character depends on the initial
column, so we need to handle the first tab in a special manner.
Reviewers: klimek, djasper
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1763
llvm-svn: 191497
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override
final;
After:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override final;
llvm-svn: 191494
|