summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Fix bad space before braced initializer.Daniel Jasper2014-05-071-1/+2
| | | | | | | | | | Before: new int {1}; After: new int{1}; llvm-svn: 208168
* clang-format: [JS] Keep space after closure style comments.Daniel Jasper2014-05-061-2/+2
| | | | | | | | | | Before: var x = /** @type {foo} */ (bar); After: var x = /** @type {foo} */(bar); llvm-svn: 208093
* clang-format: [JS] Keep space between 'return' and '['.Daniel Jasper2014-05-061-3/+4
| | | | llvm-svn: 208090
* clang-format: [JS] Don't indent in goog.scope blocks.Daniel Jasper2014-05-061-2/+20
| | | | | | | | | | | | | | | | Before: goog.scope(function() { var x = a.b; var y = c.d; }); // goog.scope After: goog.scope(function() { var x = a.b; var y = c.d; }); // goog.scope llvm-svn: 208088
* Fixed one issue with castingDinesh Dwivedi2014-05-061-2/+3
| | | | | | | | | | | | Before: (void) SimplifyICmpOperands(Cond, LHS, RHS); After: (void)SimplifyICmpOperands(Cond, LHS, RHS); Differential Revision: http://reviews.llvm.org/D3615 llvm-svn: 208080
* Pulled out cast detection in TokenAnnotator into its own functionDinesh Dwivedi2014-05-061-58/+58
| | | | | | | | This is to remove FIXME added in r207964. Differential Revision: http://reviews.llvm.org/D3619 llvm-svn: 208071
* clang-format: Understand functions with decltype return type.Daniel Jasper2014-05-051-1/+8
| | | | | | | | | | | | Before: decltype(long_name_forcing_break) f() {} After: decltype(long_name_forcing_break) f() {} llvm-svn: 207965
* Added some heuristics to identify c style castingDinesh Dwivedi2014-05-051-10/+34
| | | | | | | | | | | | | | Before: void f() { my_int a = (my_int) * b; } void f() { return P ? (my_int) * P : (my_int)0; } After: void f() { my_int a = (my_int)*b; } void f() { return P ? (my_int)*P : (my_int)0; } Differential Revision: http://reviews.llvm.org/D3576 llvm-svn: 207964
* clang-format: Improve understanding of decltype.Daniel Jasper2014-05-051-1/+2
| | | | | | | | | | Before: SomeFunction([](decltype(x), A * a) {}); After: SomeFunction([](decltype(x), A *a) {}); llvm-svn: 207961
* Fix bug in clang-format while merging short functionDinesh Dwivedi2014-05-051-4/+5
| | | | | | | | | | | | | | | | | | | | | Before: #ifdef _DEBUG int foo( int i = 0 ) #else int foo( int i = 5 ) #endif { return i; } After: #ifdef _DEBUG int foo( int i = 0 ) #else int foo( int i = 5 ) #endif { return i; } llvm-svn: 207958
* clang-format: Fix import statements with ColumnLimit: 0Daniel Jasper2014-05-051-1/+1
| | | | | | These used to interact badly with AlwaysBreakBeforeMultilineStrings. llvm-svn: 207955
* 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
OpenPOWER on IntegriCloud