summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Support ObjC's NS_ENUMs.Daniel Jasper2014-01-301-1/+10
| | | | | | | | | | | | | | | | | | | | | | | Before: typedef NS_ENUM(NSInteger, MyType) { /// Information about someDecentlyLongValue. someDecentlyLongValue, /// Information about anotherDecentlyLongValue. anotherDecentlyLongValue, /// Information about aThirdDecentlyLongValue. aThirdDecentlyLongValue}; After: typedef NS_ENUM(NSInteger, MyType) { /// Information about someDecentlyLongValue. someDecentlyLongValue, /// Information about anotherDecentlyLongValue. anotherDecentlyLongValue, /// Information about aThirdDecentlyLongValue. aThirdDecentlyLongValue }; llvm-svn: 200469
* clang-format: More custom option fixes for protocol buffer files.Daniel Jasper2014-01-291-1/+2
| | | | | | | | | | | | | | | Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = { aaaaaaaaaaaaaaaa : AAAAAAAAAA, bbbbbbbbbbbbbbbb : BBBBBBBBBB }]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa : AAAAAAAAAA, bbbbbbbbbbbbbbbb : BBBBBBBBBB}]; llvm-svn: 200406
* clang-format: Fix formatting of custom proto options.Daniel Jasper2014-01-291-1/+1
| | | | | | | | | | | | | Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = { aaaaaaaaaaaaaaaaa : AAAAAAAA }]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}]; llvm-svn: 200405
* Fix crash on unmatched #endif's.Manuel Klimek2014-01-291-1/+3
| | | | | | | | The following snippet would crash: #endif #if A llvm-svn: 200381
* clang-format: Understand __attribute__s preceding parameter lists.Daniel Jasper2014-01-283-13/+16
| | | | | | | | | | | | | | Before: ReturnType __attribute__((unused)) function(int i); After: ReturnType __attribute__((unused)) function(int i); This fixes llvm.org/PR18632. llvm-svn: 200337
* clang-format: Fix option formatting in protocol buffer files.Daniel Jasper2014-01-281-0/+1
| | | | | | | | | | Before: optional int32 foo[ default = true, deprecated = true ]; After: optional int32 foo[default = true, deprecated = true]; llvm-svn: 200327
* clang-format: Add support for a space after @propertyDaniel Jasper2014-01-282-0/+8
| | | | | | | | | Mozilla and WebKit seem to use a space after @property (verified by grepping their codebases) so we turn this on there as well. Change by Christian Legnitto. Thank you! llvm-svn: 200320
* clang-format: Fix incorrect space removal.Daniel Jasper2014-01-251-1/+1
| | | | | | | | | | | | Before: Deleted &operator=(const Deleted &)&= default; Deleted &operator=(const Deleted &)&&= delete; After: Deleted &operator=(const Deleted &)& = default; Deleted &operator=(const Deleted &)&& = delete; llvm-svn: 200073
* Get rid of special parsing for return statements.Manuel Klimek2014-01-242-38/+0
| | | | | | | | This was done when we were not able to parse lambdas to handle some edge cases for block formatting different in return statements, but is not necessary any more. llvm-svn: 199982
* clang-format: Fix incorrect lambda recognition.Daniel Jasper2014-01-221-1/+2
| | | | | | | | | | | | | Before: std::unique_ptr<int[]> foo() {} After: std::unique_ptr<int []> foo() {} Also, the formatting could go severely wrong after such a function before. llvm-svn: 199817
* clang-format: Treat "." in protos like namespace separators.Daniel Jasper2014-01-221-1/+2
| | | | | | | | | | | | | Before: optional really.really.long.and.qualified.type.aaaaaaa .aaaaaaaa another_fiiiiiiiiiiiiiiiiiiiiield = 2; After: optional really.really.long.and.qualified.type.aaaaaaa.aaaaaaaa another_fiiiiiiiiiiiiiiiiiiiiield = 2; llvm-svn: 199796
* clang-format: text following #if is likely an expression.Daniel Jasper2014-01-211-1/+2
| | | | | | | | | | Before: #if AAAA &&BBBB After: #if AAAA && BBBB llvm-svn: 199713
* clang-format: Properly format custom options in protocol buffer definitions.Daniel Jasper2014-01-201-1/+2
| | | | | | | | | | Before: option(my_option) = "abc"; After: option (my_option) = "abc"; llvm-svn: 199672
* clang-format: Leave 2 empty lines in Google's JavaScript style.Daniel Jasper2014-01-201-0/+1
| | | | | | | As per the style guide, two lines are required between top-level elements. llvm-svn: 199660
* clang-format: Better support and testing for protocol buffers.Daniel Jasper2014-01-192-5/+37
| | | | | | | | | With this patch, there is dedicated testing for protocol buffers (https://developers.google.com/protocol-buffers/). Also some minor tweaks formatting tweaks. llvm-svn: 199580
* clang-format: Fix ObjC block as first call parameter formatting.Daniel Jasper2014-01-191-0/+2
| | | | | | | | | Before: foo (^{ bar(); }); After: foo(^{ bar(); }); llvm-svn: 199573
* clang-format: Don't break lines starting with "import <string-literal>"Daniel Jasper2014-01-171-0/+9
| | | | | | | | | The author might be missing the "#" or these might be protocol buffer definitions. Either way, we should not break the line or the string. There don't seem to be other valid use cases. llvm-svn: 199501
* clang-format: Improve formatting of ObjC Blocks with return type.Daniel Jasper2014-01-161-4/+10
| | | | | | | | | | Before: int a = [operation block:^int(int * i) { return 1; }]; After: int a = [operation block:^int(int *i) { return 1; }]; llvm-svn: 199411
* clang-format: Enable formatting of lambdas with explicit return type.Daniel Jasper2014-01-164-34/+43
| | | | | | | | | So clang-format can now format: int c = []()->int { return 2; }(); int c = []()->vector<int> { return { 2 }; }(); llvm-svn: 199368
* clang-format: Fixed formatting of JavaScript container literalsDaniel Jasper2014-01-152-8/+8
| | | | | | | | | | | | Before: var arr = [ 1, 2, 3 ]; var obj = {a : 1, b : 2, c : 3}; After: var arr = [1, 2, 3]; var obj = {a: 1, b: 2, c: 3}; llvm-svn: 199317
* clang-format: Fix bug introduced in r198871.Daniel Jasper2014-01-142-2/+8
| | | | | | | | | | | | We cannot simply change the start column to accomodate for the @ in an ObjC string literal as that will make clang-format happily violate the column limit. Use a different workaround instead. However, a better long-term solution might be to join the @ and the rest of the literal into a single token. llvm-svn: 199198
* clang-format: Fix corner case with comment in ctor initializer.Daniel Jasper2014-01-131-0/+1
| | | | | | | | | | | | | | | | | | | | Formatting: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} Before: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} After: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} llvm-svn: 199107
* clang-format: Don't indent relative to ./->.Daniel Jasper2014-01-131-2/+0
| | | | | | | | | | | | | | | Before: SomeThing // break .SomeFunction( // break param); After: SomeThing // break .SomeFunction( // break param); Seems to be more common in editors and codebases I have looked at. llvm-svn: 199105
* clang-format: Slightly adapt line break in edge case.Daniel Jasper2014-01-101-1/+1
| | | | | | | | | | | | | | | Before: SomeMap[std::pair(aaaaaaaaaaaa, bbbbbbbbbbbbbbb)] .insert(ccccccccccccccccccccccc); After: SomeMap[std::pair(aaaaaaaaaaaa, bbbbbbbbbbbbbbb)].insert( ccccccccccccccccccccccc); This seems to be about 3:1 more common in Google and Chromium style and I found only a handful of instances inside the LLVM codebase. llvm-svn: 198924
* clang-format: Understand ObjC boxed expressions.Daniel Jasper2014-01-101-0/+1
| | | | | | | | | Before: [dictionary setObject:@(1)forKey:@"number"]; After: [dictionary setObject:@(1) forKey:@"number"]; llvm-svn: 198920
* clang-format: Add @s when breaking NSString literals.Daniel Jasper2014-01-092-3/+11
| | | | | | | | While it is allowed to not have an @ on subsequent lines, it seems general practice to add them. If undesired, the code author can easily remove them again and clang-format won't re-add them. llvm-svn: 198871
* clang-format: Understand #pragma markDaniel Jasper2014-01-091-0/+15
| | | | | | | | | Before: #pragma mark Any non - hyphenated or hyphenated string(including parentheses). After: #pragma mark Any non-hyphenated or hyphenated string (including parentheses). llvm-svn: 198870
* clang-format: Some tweaks to braces list formatting:Daniel Jasper2014-01-093-19/+46
| | | | | | | | | - Format a braced list with one element per line if it has nested braced lists. - Use a column layout only when the list has 6+ elements (instead of the current 4+ elements). llvm-svn: 198869
* clang-format: Don't hang forever when encountering a stray "}" in an ↵Benjamin Kramer2014-01-081-0/+4
| | | | | | | | @implementation block. PR18406. llvm-svn: 198770
* clang-format: Fix spacing in Cpp11 braced lists:Daniel Jasper2014-01-081-1/+1
| | | | | | | | | | Before: vector<int> foo{ ::SomeFunction()}; After: vector<int> foo{::SomeFunction()}; llvm-svn: 198769
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-072-2/+2
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* clang-format: Spacing inside enum braces.Daniel Jasper2014-01-051-1/+3
| | | | | | | | | | Before (in Google style): enum ShortEnum {A, B, C}; After: enum ShortEnum { A, B, C }; llvm-svn: 198559
* clang-format: Allow formatting short enums on a single line.Daniel Jasper2014-01-052-7/+12
| | | | | | | | | | | | | | | | | Before: enum ShortEnum { A, B, C }; After: enum ShortEnum { A, B, C }; This seems to be the predominant choice in LLVM/Clang as well as in Google style. llvm-svn: 198558
* clang-format: Recognize single-line macro usages inside macros.Daniel Jasper2014-01-031-1/+1
| | | | | | | | | | | | | | | | | Before: #define LIST(L) \ L(FirstElement) L(SecondElement) L(ThirdElement) L(FourthElement) \ L(FifthElement) After: #define LIST(L) \ L(FirstElement) \ L(SecondElement) \ L(ThirdElement) \ L(FourthElement) \ L(FifthElement) llvm-svn: 198407
* Added an option to avoid splitting certain kinds of comments into lines.Alexander Kornienko2014-01-023-1/+10
| | | | | | | | | | | | | | Summary: Added CommentPragmas option for this. Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2460 llvm-svn: 198310
* Fix and reword some typosAlp Toker2013-12-301-1/+1
| | | | llvm-svn: 198191
* clang-format: Break default arguments less eagerly.Daniel Jasper2013-12-271-0/+2
| | | | | | | | | | | | Before: void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1); After: void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( int aaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1); llvm-svn: 198070
* clang-format: (WebKit) Disallow 1-line constructors with initializers.Daniel Jasper2013-12-241-5/+16
| | | | | | | | | | | | | | | Before: Constructor() : a(a) {} After: Constructor() : a(a) { } This style guide is pretty precise about this. llvm-svn: 197980
* clang-format: Fix invalid write discovered by ASAN.Daniel Jasper2013-12-231-1/+2
| | | | | | Introduced in r197900. llvm-svn: 197906
* clang-format: Fix various problems in formatting ObjC blocks.Daniel Jasper2013-12-236-31/+134
| | | | | | Among other things, this fixes llvm.org/PR15269. llvm-svn: 197900
* clang-format: Better support for multi-line wide string literals.Daniel Jasper2013-12-203-18/+12
| | | | | | | | | | | Before: SomeFunction(L"A" L"B"); After: SomeFunction(L"A" L"B"); llvm-svn: 197785
* clang-format: Add special case for leading comments in braced lists.Daniel Jasper2013-12-192-7/+17
| | | | | | | | | | | | | | | | | | | A comment following the "{" of a braced list seems to almost always refer to the first element of the list and thus should be aligned to it. Before (with Cpp11 braced list style): SomeFunction({ // Comment 1 "first entry", // Comment 2 "second entry"}); After: SomeFunction({// Comment 1 "first entry", // Comment 2 "second entry"}); llvm-svn: 197725
* clang-format: Increase penalty for breaking comments.Daniel Jasper2013-12-191-1/+1
| | | | | | | | | | | | | Unexpectedly, it seems that people commonly know what they were doing when writing a comment. Also, being more conservative about comment breaking has the advantage of giving more flexibility. If a linebreak within the comment can improve formatting, the author can add it (after which clang-format won't undo it). There is no way to override clang-format's behavior if it breaks a comment. llvm-svn: 197698
* clang-format: Slightly adapt decision of when to break before <<.Daniel Jasper2013-12-191-1/+1
| | | | | | | | | | | | Before: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaa); After: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa); llvm-svn: 197690
* clang-format: Fix indentation corner case.Daniel Jasper2013-12-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | Before: aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); Probably still not ideal, but should be a step into the right direction. llvm-svn: 197557
* clang-format: Fix ObjC method expr in binary expressions.Daniel Jasper2013-12-181-1/+1
| | | | | | | | | | | | | | Before: bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa || [aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaaaaa); After: bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa || [aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaaaaa); This fixes llvm.org/PR18271. llvm-svn: 197552
* clang-format: Don't adapt local format to macros.Daniel Jasper2013-12-171-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formatting this: void f() { // 1 space initial indent. int i; #define A \ int i; \ int j; int k; // Format this line. } void f() { #define A 1 // Format this line. } Before: void f() { // 1 space initial indent. int i; #define A \ int i; \ int j; int k; // Format this line. } void f() { #define A 1 // Format this line. } After: void f() { // 1 space initial indent. int i; #define A \ int i; \ int j; int k; // Format this line. } void f() { #define A 1 // Format this line. } llvm-svn: 197494
* clang-format: Keep trailing annotations together.Daniel Jasper2013-12-162-6/+14
| | | | | | | | | | | | | | | | Before: virtual void aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa aaaa, aaaaaaaaaaa aaaaa) const override; virtual void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() const override; After: virtual void aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa aaaa, aaaaaaaaaaa aaaaa) const override; virtual void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() const override; llvm-svn: 197391
* Always break before the colon in constructor initializers, whenAlexander Kornienko2013-12-163-9/+11
| | | | | | | | | | | BreakConstructorInitializersBeforeComma is true. This option is used in WebKit style, so this also ensures initializer lists are not put on a single line, as per the WebKit coding guidelines. Patch by Florian Sowade! llvm-svn: 197386
* clang-format: Fix formatting of function type parameters.Daniel Jasper2013-12-161-5/+10
| | | | | | | | | Before: void f() { typedef void (*f)(int * a); } After: void f() { typedef void (*f)(int *a); } llvm-svn: 197369
OpenPOWER on IntegriCloud