Summary:
http://llvm.org/bugs/show_bug.cgi?id=20892
Add support of C-style formatting enabling/disabling directives. Now the following two styles are supported:
// clang-format on
/* clang-format on */
The flexibility in comments (support of extra spaces and/or slashes, etc.) is deliberately avoided to simplify search in large code bases.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, curdeius, klimek
Differential Revision: http://reviews.llvm.org/D5309
llvm-svn: 217588
On a single line:
switch (a) {
case 1: x = 1; return;
case 2: x = 2; return;
default: break;
}
Not on a single line:
switch (a) {
case 1:
x = 1;
return;
case 2:
x = 2;
return;
default:
break;
}
This partly addresses llvm.org/PR16535. In the long run, we probably want to
lay these out in columns.
llvm-svn: 217501
Before:
var regex = / a\//; int i;
After:
var regex = /a\//;
int i;
This required pushing the Lexer into its wrapper class and generating a
new one in this specific case. Otherwise, the sequence get lexed as a
//-comment. This is hacky, but I don't know a better way (short of
supporting regex literals in the Lexer).
Pushing the Lexer down seems to make all the call sites simpler.
llvm-svn: 217444
Before:
e&& e.SomeFunction();
After:
e && e.SomeFunction();
Yeah, this might be useful for C++, too, but it is not such a frequent
pattern there (plus the fix is much harder).
llvm-svn: 217237
This permits to add a space after closing parenthesis of a C-style cast.
Defaults to false to preserve old behavior.
Fixes llvm.org/PR19982.
Before:
(int)i;
After:
(int) i;
Patch by Marek Kurdej.
llvm-svn: 217022
Only those callers who are dynamically passing ownership should need the
3 argument form. Those accepting the default ("do pass ownership")
should do so explicitly with a unique_ptr now.
llvm-svn: 216614
Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording.
llvm-svn: 215982
Before:
template <class T>
T *f(T &c) // Problem here: no line break before f
{
return NULL;
}
After:
template <class T>
T *
f(T &c)
{
return NULL;
}
Patch by Marek Kurdej, thank you!
llvm-svn: 215633
Summary:
http://llvm.org/bugs/show_bug.cgi?id=20587
Added K&R style. It could be enabled by the following option:
```
BreakBeforeBraces: KernighanRitchie
```
This style is like `Attach`, but break *only* before function
declarations.
As I can see, no additional logic required to support this style, any
style different from other styles automagically satisfies K&R.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D4837
llvm-svn: 215354
Before:
auto f (int x) -> decltype(x) { return sizeof(x); }
int g () noexcept(someCall ());
static_assert(sizeof(char) == 1, "Your compiler is broken");
After:
auto f (int x) -> decltype (x) { return sizeof (x); }
int g () noexcept (someCall ());
static_assert (sizeof (char) == 1, "Your compiler is broken");
This fixes llvm.org/PR20559.
Patch by Roman Kashitsyn, thank you!
llvm-svn: 214969
With this patch:
int ThisWillBeFormatted;
// clang-format off
int ThisWontBeFormatted;
// clang-format on
int Formatted;
This is for regions where a significantly nicer code layout can be found
knowing the content of the code.
This fixes llvm.org/PR20463.
llvm-svn: 214966
Before:
auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
typename aaaaaaaaaaaaaaaaaaaaaaaa();
After:
auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
typename aaaaaaaaaaaaaaaaaaaaaaaa();
llvm-svn: 214964
This is required for GNU coding style, among others.
Also update the configuration documentation.
Modified from an original patch by Jarkko Hietaniemi, thank you!
llvm-svn: 214858