#
8360a86c |
| 08-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix handling of fake parenthesis during formatting.
They are much easier to handle when attached to the previous token.
Before: unsigned Indent = formatFirstToken(TheLine.First, IndentForLevel[
Fix handling of fake parenthesis during formatting.
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);
llvm-svn: 174718
show more ...
|
#
400adc64 |
| 08-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Implement a tiny expression parser to improve formatting decisions.
With this patch, the formatter introduces 'fake' parenthesis according to the operator precedence of binary operators.
Before: re
Implement a tiny expression parser to improve formatting decisions.
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.
llvm-svn: 174714
show more ...
|
#
acc33666 |
| 08-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Avoid unnecessary line breaks in nested ObjC calls.
Before: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonD
Avoid unnecessary line breaks in nested ObjC calls.
Before: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonDragType]; After: [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] forType:kBookmarkButtonDragType];
llvm-svn: 174701
show more ...
|
#
14556747 |
| 07-Feb-2013 |
Daniel Jasper <djasper@google.com> |
clang-format: Don't put useless space in f( ::g()).
llvm-svn: 174662
|
#
0588b509 |
| 07-Feb-2013 |
Nico Weber <nicolasweber@gmx.de> |
Formatter: Move ObjC literal tests to its own test case.
Slightly expand the boxed expressions test with a few more snippets from http://clang.llvm.org/docs/ObjectiveCLiterals.html
llvm-svn: 174559
|
#
f79f935f |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix bug in the alignment of comments.
Before: const char *test[] = { // A "aaaa", // B "aaaaa", };
After: const char *test[] = { // A "aaaa", // B "aaaaa", };
llvm-svn
Fix bug in the alignment of comments.
Before: const char *test[] = { // A "aaaa", // B "aaaaa", };
After: const char *test[] = { // A "aaaa", // B "aaaaa", };
llvm-svn: 174549
show more ...
|
#
ba9ddb66 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Become a little smarter with formatting long chains of pipes.
Assign a high penalty to breaking before "<<" if the previous token is a string literal ending in ":" or "=".
Before: llvm::outs()
Become a little smarter with formatting long chains of pipes.
Assign a high penalty to breaking before "<<" if the previous token is a string literal ending in ":" or "=".
Before: llvm::outs() << "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa << "bbbbbbbbbbbbbbbbb = " << bbbbbbbbbbbbbbbbb << "ccccccccccccccccc = " << ccccccccccccccccc << "ddddddddddddddddd = " << ddddddddddddddddd << "eeeeeeeeeeeeeeeee = " << eeeeeeeeeeeeeeeee;
After: llvm::outs() << "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa << "bbbbbbbbbbbbbbbbb = " << bbbbbbbbbbbbbbbbb << "ccccccccccccccccc = " << ccccccccccccccccc << "ddddddddddddddddd = " << ddddddddddddddddd << "eeeeeeeeeeeeeeeee = " << eeeeeeeeeeeeeeeee;
llvm-svn: 174545
show more ...
|
#
94f0e138 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Align trailing block comments like trailing line comments.
llvm-svn: 174537
|
#
ac9bde23 |
| 06-Feb-2013 |
Nico Weber <nicolasweber@gmx.de> |
Formatter: Correctly detect ObjC message expressions preceded by a comment.
llvm-svn: 174521
|
#
82b836a6 |
| 06-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Fix handling of comments in macros.
We now correctly format: // Written as a macro, it is reformatted from: #define foo(a) \ do {
Fix handling of comments in macros.
We now correctly format: // Written as a macro, it is reformatted from: #define foo(a) \ do { \ /* Initialize num to zero. */ \ int num = 10; \ /* This line ensures a is never zero. */ \ int i = a == 0 ? 1 : a; \ i = num / i; /* This division is OK. */ \ return i; \ } while (false)
llvm-svn: 174517
show more ...
|
#
046b9306 |
| 06-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Much semicolon after namespaces.
We now leave the semicolon in the line of the closing brace in: namespace { ... };
llvm-svn: 174514
|
#
c485b4e5 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix formatting of ObjC method calls.
This fixes llvm.org/PR15165.
We now correctly align: [image_rep drawInRect:drawRect fromRect:NSZeroRect operation:NSCompositeCopy
Fix formatting of ObjC method calls.
This fixes llvm.org/PR15165.
We now correctly align: [image_rep drawInRect:drawRect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0 ssssssssdd:NO hints:nil];
llvm-svn: 174513
show more ...
|
#
d265090c |
| 06-Feb-2013 |
Manuel Klimek <klimek@google.com> |
Parse record declarations with token pasted identifiers.
This is pretty common in macros: #define A(X, Y) class X##Y {};
llvm-svn: 174512
|
#
38396591 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix a formatting bug caused by comments in expressions.
This fixes llvm.org/PR15162.
Before: bool aaaaaaaaaaaaa = // comment aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaa
Fix a formatting bug caused by comments in expressions.
This fixes llvm.org/PR15162.
Before: bool aaaaaaaaaaaaa = // comment aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After: bool aaaaaaaaaaaaa = // comment aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 174508
show more ...
|
#
7fce3ab0 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Optionally derive formatting information from the input file.
With this patch, clang-format can analyze the input file for two properties: 1. Is "int *a" or "int* a" more common. 2. Are non-C++03 co
Optionally derive formatting information from the input file.
With this patch, clang-format can analyze the input file for two properties: 1. Is "int *a" or "int* a" more common. 2. Are non-C++03 constructs used, e.g. A<A<A>>.
With Google-style, clang-format will now use the more common style for (1) and format C++03 compatible, unless it finds C++11 constructs in the input.
llvm-svn: 174504
show more ...
|
#
8035b0a6 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix an issue with the formatting of stars in default values.
Before: void f(int *a = d *e, int b = 0); After: void f(int *a = d * e, int b = 0); llvm-svn: 174500
|
#
c697ad29 |
| 06-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Handle nested ObjC calls.
Properly handle annotation contexts while calculating extra information for each token. This enable nested ObjC calls and thus solves (most of) llvm.org/PR15164. E.g., we c
Handle nested ObjC calls.
Properly handle annotation contexts while calculating extra information for each token. This enable nested ObjC calls and thus solves (most of) llvm.org/PR15164. E.g., we can now format:
[contentsContainer replaceSubview:[subviews objectAtIndex:0] with:contentsNativeView];
Also fix a problem with the formatting of types in casts as this was trivial now.
llvm-svn: 174498
show more ...
|
#
5d2624e5 |
| 06-Feb-2013 |
Nico Weber <nicolasweber@gmx.de> |
Formatter: No space after & and * in front of ObjC message expressions.
1. let determineStarAmp() check of unary operators before checking for "is next '['". That check was added in r173150, and
Formatter: No space after & and * in front of ObjC message expressions.
1. let determineStarAmp() check of unary operators before checking for "is next '['". That check was added in r173150, and the test from that revision passes either way.
2. change determineStarAmp() to categorize '*' and '&' after '=' as unary operator.
3. don't let parseSquare() overwrite the type of a '*' or '&' before the start of an objc message expression if has the role of unary operator.
llvm-svn: 174489
show more ...
|
#
b76de882 |
| 05-Feb-2013 |
Nico Weber <nicolasweber@gmx.de> |
Formatter: Detect ObjC method expressions after unary operators.
llvm-svn: 174384
|
#
1ac3e05b |
| 05-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Initial support for formatting ObjC method declarations/calls.
We can now format stuff like: - (void)doSomethingWith:(GTMFoo *)theFoo rect:(NSRect)theRect interval:
Initial support for formatting ObjC method declarations/calls.
We can now format stuff like: - (void)doSomethingWith:(GTMFoo *)theFoo rect:(NSRect)theRect interval:(float)theInterval { [myObject doFooWith:arg1 // name:arg2 error:arg3];
}
This seems to fix everything mentioned in llvm.org/PR14939.
llvm-svn: 174364
show more ...
|
#
b9ebd5d3 |
| 05-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix some linebreak decisions in Google format.
Before: f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa); aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaa
Fix some linebreak decisions in Google format.
Before: f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa); aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));
After: f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa); aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));
llvm-svn: 174363
show more ...
|
#
a885dbeb |
| 05-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Fix formatting regression introduced by r174307.
In preprocessor definitions, we would not parse all the tokens and thus not annotate them anymore. This led to a wrong formatting of comments in goog
Fix formatting regression introduced by r174307.
In preprocessor definitions, we would not parse all the tokens and thus not annotate them anymore. This led to a wrong formatting of comments in google style:
#endif // HEADER_GUARD -- requires two spaces
llvm-svn: 174361
show more ...
|
#
14e40ec8 |
| 04-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Improve handling of trailing block comments
This is a follow up to r174309 to actually make it work.
llvm-svn: 174314
|
#
2603ee0d |
| 04-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Improve formatting of stream operators.
If there are string literals on either side of a '<<', chances are high that they represent logically separate concepts. Otherwise, the author could just have
Improve formatting of stream operators.
If there are string literals on either side of a '<<', chances are high that they represent logically separate concepts. Otherwise, the author could just have just a single literal (possible split over multiple lines).
So, we can now nicely format things like: cout << "somepacket = {\n" << " val a = " << ValueA << "\n" << " val b = " << ValueB << "\n" << "}";
llvm-svn: 174310
show more ...
|
#
1f140981 |
| 04-Feb-2013 |
Daniel Jasper <djasper@google.com> |
Improve handling of trailing block comments.
We can now (even in non-bin-packing modes) format: someFunction(1, /* comment 1 */ 2, /* comment 2 */ 3, /* comment 3 */
Improve handling of trailing block comments.
We can now (even in non-bin-packing modes) format: someFunction(1, /* comment 1 */ 2, /* comment 2 */ 3, /* comment 3 */ aaa);
llvm-svn: 174309
show more ...
|