summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
* Fixes issue with Allman BreakBeforeBraces for Objective C @interfaceDinesh Dwivedi2014-05-021-2/+5
| | | | | | | | | | | | | | | | | | | Before: @interface BSApplicationController () { @private id _extraIvar; } @end After: @interface BSApplicationController () { @private id _extraIvar; } @end llvm-svn: 207849
* Fix typo (first commit to test commit access).Dinesh Dwivedi2014-05-011-1/+1
| | | | llvm-svn: 207775
* clang-format: Don't bin-pack text-proto-formatted options.Daniel Jasper2014-04-291-0/+1
| | | | | | | | | | | | | | | Before: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA, bbbbbbb: BBBB, bbbb: BBB}]; After: repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA, bbbbbbb: BBBB, bbbb: BBB}]; llvm-svn: 207538
* clang-format: Remove accidentally added debug output.Daniel Jasper2014-04-291-2/+0
| | | | llvm-svn: 207533
* clang-format: Allow single-line function in WebKit style.Daniel Jasper2014-04-292-2/+4
| | | | | | | | | | | Before: void f() { return; } After: void f() { return; } llvm-svn: 207527
* clang-format: Improve binary operator detection.Daniel Jasper2014-04-281-1/+1
| | | | | | | | | | | | Before: *(int *)(p &~3UL) = 0; After: *(int *)(p & ~3UL) = 0; This fixes llvm.org/PR19464. llvm-svn: 207405
* clang-format: Fixes spaces in case statements.Daniel Jasper2014-04-281-2/+3
| | | | | | | | | | | | | | | | | | This fixes llvm.org/PR19482. Before: switch (a) { case(B) : return; } After: switch (a) { case (B): return; } llvm-svn: 207402
* clang-format: Don't wrap after @interface.Daniel Jasper2014-04-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | This fixes llvm.org/PR19450. Before: @interface BookmarkHomeHandsetViewController ()<BookmarkAllCollectionViewDelegate, BookmarkFolderCollectionViewDelegate, BookmarkMenuViewControllerDelegate, BookmarkSearchViewControllerDelegate> { } After: @interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> { } llvm-svn: 207400
* clang-format: Fix bug when aligning trailing /**/-comments in macros.Daniel Jasper2014-04-271-1/+2
| | | | | | | Previously this could lead to a column limit violation with the required escaped newlines. llvm-svn: 207351
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-224-8/+8
| | | | | | | | | | definition below all of the header #include lines, clang edition. If you want more details about this, you can see some of the commits to Debug.h in LLVM recently. This is just the clang section of a cleanup I've done for all uses of DEBUG_TYPE in LLVM. llvm-svn: 206849
* [Modules] Update Clang's two files that use DEBUG(...) without definingChandler Carruth2014-04-211-0/+2
| | | | | | DEBUG_TYPE to do so. LLVM's Debug.h requires this as of r206822. llvm-svn: 206823
* Fix alignment of trailing block comments.Alexander Kornienko2014-04-174-70/+112
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch ensures that the lines of the block comments retain relative column offsets. In order to do this WhitespaceManager::Changes representing continuation of block comments keep a pointer on the change representing the whitespace change before the block comment, and a relative column offset to this change, so that the correct column can be reconstructed at the end of alignment process. Fixes http://llvm.org/PR19325 Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D3408 llvm-svn: 206472
* clang-format: Respect BinPackParameters in Cpp11BracedListStyle.Daniel Jasper2014-04-172-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | With BinPackParameters=false and Cpp11BracedListStyle=true (i.e. mostly for Chromium): Before: const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk}; After: const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk}; This fixes llvm.org/PR19359. I am not sure we'll want this in all cases in the long run, but I'll guess we'll get feedback on that. llvm-svn: 206458
* clang-format: Add special case to reduce indentaiton in streams.Daniel Jasper2014-04-163-8/+20
| | | | | | | | | | | | | | | | This is similar to how we treat assignments and seems to be generally desirable. Before: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 206384
* Format.cpp: Don't use initializer list.NAKAMURA Takumi2014-04-151-2/+2
| | | | llvm-svn: 206339
* Fix assertion when breaking string literals with tab characters.Alexander Kornienko2014-04-151-0/+6
| | | | | | | | | | | | | | Summary: Fixes http://llvm.org/PR19368 Reviewers: djasper, klimek Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D3379 llvm-svn: 206295
* clang-format: Understand proto text format without commas.Daniel Jasper2014-04-153-1/+10
| | | | | | | | | | | | | | | | Also removed spaces before colons as they don't seem to be used frequently. Before: optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa : 123 bbbbbbbbbbbbbbbbbbbbbbbb : "baz"}]; After: optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa: 123, bbbbbbbbbbbbbbbbbbbbbbbb:"baz"}]; llvm-svn: 206269
* clang-format: Basic support for C++1y.Daniel Jasper2014-04-151-0/+1
| | | | | | | | | | | Before: int bi{1 '000' 000}; After: int bi{1'000'000}; This fixes llvm.org/PR19342. llvm-svn: 206263
* clang-format: Early cut-off for inlining nested blocks.Daniel Jasper2014-04-151-0/+7
| | | | | | | | | | | | | | Specifically, for a nested block or lambda, don't try to put the single statement body inline, if it exceeds the column limit. This should not change any observable behavior (as those would never have led to the 'best' solution), but significantly speeds up formatting time. This fixes llvm.org/PR18761. Formatting time goes down from ~100s to a few ms. llvm-svn: 206260
* clang-format: Cache results of formatting nested blocks.Daniel Jasper2014-04-151-0/+14
| | | | | | | This somewhat improves the performance problem reported in llvm.org/PR18761. No other behavior changes intended. llvm-svn: 206258
* clang-format: Fix regression caused by r206165.Daniel Jasper2014-04-141-1/+3
| | | | llvm-svn: 206173
* clang-format: Fix incorrect &&-detection in macros.Daniel Jasper2014-04-141-0/+3
| | | | | | | | | | | | Before: #define A(a, b) (a &&b) After: #define A(a, b) (a && b) This fixes llvm.org/PR19343. llvm-svn: 206165
* clang-format: Improve array literal formatting fix in r206161.Daniel Jasper2014-04-141-1/+1
| | | | | | | Instead of choosing based on the number of elements, simply respect the user's choice of where to wrap array literals. llvm-svn: 206162
* clang-format: With ColumnLimit=0, keep short array literals on a line.Daniel Jasper2014-04-141-0/+1
| | | | | | | | | | | | | | | | Before: NSArray* a = [[NSArray alloc] initWithArray:@[ @"a" ] copyItems:YES]; After: NSArray* a = [[NSArray alloc] initWithArray:@[ @"a" ] copyItems:YES]; This fixed llvm.org/PR19080. llvm-svn: 206161
* clang-format: Don't allow hanging indentation for operators on new linesDaniel Jasper2014-04-143-19/+41
| | | | | | | | | | | | | | | | Before: if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap == cccccccccccccc) ... After: if (aaaaaaaa && bbbbbbbbbbbbbbb // need to wrap == cccccccccccccc) ... The same rule has already be implemented for BreakBeforeBinaryOperators set to false in r205527. llvm-svn: 206159
* Format code around VCS conflict markers.Manuel Klimek2014-04-144-31/+132
| | | | | | | | | | | | | | | | | | | | | Now correctly formats: { int a; void f() { callme(some(parameter1, <<<<<<< text by the vcs parameter2), ||||||| text by the vcs parameter2), parameter3, ======= text by the vcs parameter2, parameter3), >>>>>>> text by the vcs otherparameter); } } llvm-svn: 206157
* clang-format: Improve formatting of annotated variables.Daniel Jasper2014-04-141-0/+1
| | | | | | | | | | | | Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 206155
* Correctly handle escaped newlines when the next token starts without a space.Manuel Klimek2014-04-114-6/+14
| | | | | | | We will need this to correctly handle conflict markers inside macro definitions. llvm-svn: 206029
* clang-format: Fix false positive in braced list detection in protos.Daniel Jasper2014-04-101-12/+19
| | | | llvm-svn: 205954
* clang-format: Treat a trailing comment like a trailing comma in braced lists.Daniel Jasper2014-04-091-5/+7
| | | | | | | | | | | | | | | | | Before: static StructInitInfo module = {MODULE_BUILTIN, /* type */ "streams" /* name */ }; After: static StructInitInfo module = { MODULE_BUILTIN, /* type */ "streams" /* name */ }; This fixes llvm.org/PR19378. llvm-svn: 205851
* clang-format: Fix bug where clang-format would break the code.Daniel Jasper2014-04-091-0/+4
| | | | | | | | | | | | Before, it would turn: SomeFunction([]() { // Cool function.. return 43; }); Into this: SomeFunction([]() { // Cool function.. return 43; }); llvm-svn: 205849
* clang-format: Improve format of calls with several lambdas.Daniel Jasper2014-04-092-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | Before: SomeFunction([]() { int i = 42; return i; }, []() { int j = 43; return j; }); After: SomeFunction([]() { int i = 42; return i; }, []() { int j = 43; return j; }); llvm-svn: 205848
* clang-format: Allow breaking between trailing annotations in more cases.Daniel Jasper2014-04-091-5/+5
| | | | | | | | | | | | Before: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA( aaaaaaaaaaaaaaa); After: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa); llvm-svn: 205846
* clang-format: Keep more trailing annotations on the same line.Daniel Jasper2014-04-091-4/+2
| | | | | | | | | | | | | | | | | | | | More precisely keep all short annotations (<10 characters) on the same line if possible. Previously, clang-format would only prefer to do so for "const", "override" and "final". However, it seems to be generally preferable, especially because some codebases have to wrap those in macros for backwards compatibility. Before: void someLongFunction(int someLongParameter) OVERRIDE {} After: void someLongFunction( int someLongParameter) OVERRIDE {} This fixes llvm.org/PR19363. llvm-svn: 205845
* clang-format: Recognize lists ending in trailing commas correctly.Daniel Jasper2014-04-091-7/+11
| | | | | | | Previously, this did not look through trailing comments leading to a few formatting oddities. llvm-svn: 205843
* clang-format: Fix incorrect multi-block-parameter computation.Daniel Jasper2014-04-081-3/+2
| | | | llvm-svn: 205763
* clang-format: Correctly understand arrays of pointers.Daniel Jasper2014-04-081-1/+1
| | | | | | | | | | | | Before: A<int * []> a; After: A<int *[]> a; This fixes llvm.org/PR19360. llvm-svn: 205761
* clang-format: Extend AllowShortFunctions.. to only merge inline functions.Daniel Jasper2014-04-082-7/+23
| | | | | | | | | | | | | | | | | Before AllowShortFunctionsOnASingleLine could either be true, merging all functions, or false, merging no functions. This patch adds a third value "Inline", which can be used to only merge short functions defined inline in a class, i.e.: void f() { return 42; } class C { void f() { return 42; } }; llvm-svn: 205760
* clang-format: Don't merge simple blocks in case statements.Daniel Jasper2014-04-041-1/+1
| | | | | | | | | | | | | | | | Before: switch (a) { case 1: { return 'a'; } } After: switch (a) { case 1: { return 'a'; } } llvm-svn: 205611
* clang-format: Prefer an additional line-break over hanging indent.Daniel Jasper2014-04-031-0/+12
| | | | | | | | | | | | | | | | | | | | Don't allow the RHS of an operator to be split over multiple lines unless there is a line-break right after the operator. Before: if (aaaa && bbbbb || // break cccc) { } After: if (aaaa && bbbbb || // break cccc) { } In most cases, this seems to increase readability. llvm-svn: 205527
* xDaniel Jasper2014-04-031-1/+1
| | | | llvm-svn: 205526
* clang-format: Understand that "auto" is a type.Daniel Jasper2014-04-031-1/+1
| | | | | | | | | | Before: MACRO(auto * a); After: MACRO(auto *a); llvm-svn: 205517
* clang-format: Support configurable list of foreach-macros.Daniel Jasper2014-04-014-8/+41
| | | | | | | | This fixes llvm.org/PR17242. Patch by Brian Green, thank you! llvm-svn: 205307
* clang-format: Solve issues found and fixed by clang-tidy.Daniel Jasper2014-03-312-2/+2
| | | | llvm-svn: 205193
* clang-format: Fix aligning of comments and escaped newlines in macros.Daniel Jasper2014-03-281-0/+4
| | | | | | | | | | | | | | Before: #define A \ int i; /*a*/ \ int jjj; /*b*/ After: #define A \ int i; /*a*/ \ int jjj; /*b*/ llvm-svn: 205011
* Get rid of the adapted isLiteral method.Manuel Klimek2014-03-282-7/+6
| | | | | | We don't want to deviate from clang's standard terminology. llvm-svn: 204997
* clang-format: Recognize more ObjC blocks with parameters/return type.Daniel Jasper2014-03-281-2/+6
| | | | llvm-svn: 204990
* Improve handling of bool expressions in template arguments.Manuel Klimek2014-03-272-3/+11
| | | | | | | Now correctly formats: foo<true && false>(); llvm-svn: 204950
* clang-format: Avoid line-breaks that increase the current column.Daniel Jasper2014-03-271-5/+9
| | | | | | | | | | | | | | | | | | While these might make sense for some rule (e.g. break after multi-line operand), they generally appear ugly and confusing. Before: fffffffffff(R\"x( multiline raw string literal xxxxxxxxxxxxxx )x\" + bbbbbb) After: fffffffffff(R\"x( multiline raw string literal xxxxxxxxxxxxxx )x\" + bbbbbb) llvm-svn: 204937
* clang-format: Extract getNewLineColumn out of addTokenOnNewLine.Daniel Jasper2014-03-272-74/+103
| | | | | | No functional changes intended. llvm-svn: 204930
OpenPOWER on IntegriCloud