summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Force line break between "endl" and "<<".Daniel Jasper2015-01-081-0/+4
| | | | | | | | | | | | | | | | This makes piped output easier to read in many instances. Before: llvm::errs() << aaaa << std::endl << bbbb << std::endl; After: llvm::errs() << aaaa << std::endl << bbbb << std::endl; Also fix a few instance of "don't use else after return" as per the coding standards. llvm-svn: 225444
* clang-format: Improve template parameter detection.Daniel Jasper2015-01-081-0/+1
| | | | | | | | | | Before: struct A < std::enable_if<sizeof(T2) <sizeof(int32)>::type>; After: struct A<std::enable_if<sizeof(T2) < sizeof(int32)>::type>; llvm-svn: 225435
* clang-format: Understand single-line comments at the end of blocks.Daniel Jasper2015-01-071-0/+8
| | | | | | | | | | | This prevents clang-format from moving/aligning the comment in the snippet: void f() { int i; // some comment // some unrelated comment } llvm-svn: 225352
* clang-format: Fix unary operator detection.Daniel Jasper2015-01-071-0/+1
| | | | | | | | | | Before: ** outparam = 1; After: **outparam = 1; llvm-svn: 225349
* clang-format: Fix incorrect detection of ObjC "in" keyword.Daniel Jasper2014-12-181-0/+1
| | | | | | | | | | Before: for (auto v : in [1]) { .. After: for (auto v : in[1]) { .. llvm-svn: 224513
* Don't break single-line raw string literals.Alexander Kornienko2014-12-141-21/+8
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6636 llvm-svn: 224223
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-121-2/+7
| | | | | | | | | | | | | | | | | | | | | | This fixed llvm.org/PR21804 and hopefully a few other strange cases. Before: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } After: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } llvm-svn: 224112
* clang-format: Add a test for PR19603 which seems fixed (maybe by r221338?).Nico Weber2014-12-091-0/+3
| | | | llvm-svn: 223850
* clang-format: Support commas in lambda return types.Daniel Jasper2014-12-081-0/+1
| | | | | | | | | | Before: auto next_pair = [](A * a) -> pair<A*, A*>{}; After: auto next_pair = [](A* a) -> pair<A*, A*>{}; llvm-svn: 223652
* clang-format: Don't merge lines with comments.Daniel Jasper2014-12-071-0/+5
| | | | | | | | | | | | | | Before: int f() { // comment return 42; } After: int f() { // comment return 42; } This fixes llvm.org/PR21769. llvm-svn: 223609
* clang-format: Support NS_OPTIONS, CF_ENUM and CF_OPTIONS.Daniel Jasper2014-12-051-0/+15
| | | | | | This fixes llvm.org/PR21756. llvm-svn: 223458
* clang-format: More restrictively classify import declarations.Daniel Jasper2014-12-041-0/+4
| | | | | | | | | | | Before: import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 223345
* clang-format: Fix fake parentheses placement with comments.Daniel Jasper2014-12-031-0/+7
| | | | | | | | | | | | | | | | Before: return (a > b // comment1 // comment2 || c); After: return (a > b // comment1 // comment2 || c); llvm-svn: 223234
* clang-format: Add option to suppress operator alignment.Daniel Jasper2014-12-021-2/+61
| | | | | | | | | | | | | | | | With alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; Without alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; This fixes llvm.org/PR21666. llvm-svn: 223117
* clang-format: precedence-based indentation when breaking before operators.Daniel Jasper2014-12-021-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; After: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; Not particularly pretty, but can probably help to uncover bugs. And if this bugs somebody, parentheses can help. llvm-svn: 223111
* clang-format: Add SFS_Empty to only empty functions on a single line.Daniel Jasper2014-11-261-0/+2
| | | | | | | | Activated for and tested by Google's Java style. This fixes llvm.org/PR21667. llvm-svn: 222819
* clang-format: Make short case labels work with #ifsDaniel Jasper2014-11-231-0/+6
| | | | | | | | | | | | | | | | | | | Before: switch (a) { #if FOO case 0: return 0; #endif } After: switch (a) { #if FOO case 0: return 0; #endif } This fixed llvm.org/PR21544. llvm-svn: 222642
* clang-format: Improve ObjC blocks with return type.Daniel Jasper2014-11-231-0/+1
| | | | | | | | | | | | Before: Block b = ^int * (A * a, B * b) {} After: Block b = ^int *(A *a, B *b) {} This fixed llvm.org/PR21619. llvm-svn: 222639
* clang-format: Understand more lambda return types.Daniel Jasper2014-11-211-0/+3
| | | | | | | | | | Before: auto a = [&b, c ](D * d) -> D * {} After: auto a = [&b, c](D* d) -> D* {} llvm-svn: 222534
* clang-format: Use nested block special case for all languages.Daniel Jasper2014-11-211-22/+30
| | | | | | | | | | | | | | | | | | | Previously this was only used for JavaScript. Before: functionCall({ int i; int j; }, aaaa, bbbb, cccc); After: functionCall({ int i; int j; }, aaaa, bbbb, cccc); llvm-svn: 222531
* clang-format: Handle comments in short case labels.Daniel Jasper2014-11-211-0/+5
| | | | | | | | | | | | | | | With AllowShortCaseLabelsOnASingleLine set to true: This gets now left unchanged: case 1: // comment return; Whereas before it was changed into: case 1: // comment return; This fixes llvm.org/PR21630. llvm-svn: 222529
* clang-format: Add option to disable alignment after opening bracketsDaniel Jasper2014-11-181-1/+39
| | | | | | | | | | | | | | Before: SomeFunction(parameter, parameter); After: SomeFunction(parameter, parameter); Patch by Harry Terkelsen, thank you! llvm-svn: 222284
* clang-format: Fix more incorrect pointer detection.Daniel Jasper2014-11-171-0/+1
| | | | | | | | | | Before: Constructor() : a(a), b(c, d *e) {} After: Constructor() : a(a), b(c, d * e) {} llvm-svn: 222158
* clang-format: Fix regression introduced in r221609.Daniel Jasper2014-11-171-0/+1
| | | | | | | | | | Before: void f() { f(a, c *d); } After: void f() { f(a, c * d); } llvm-svn: 222128
* clang-format: Correctly detect multiplication in ctor initializer.Daniel Jasper2014-11-141-0/+1
| | | | | | | | | | Before: Constructor() : a(a), area(width *height) {} After: Constructor() : a(a), area(width * height) {} llvm-svn: 222010
* clang-format: Improve function parameter packing.Daniel Jasper2014-11-141-0/+4
| | | | | | | | | | | | | | | Before: void SomeLoooooooooooongFunction( std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); After: void SomeLoooooooooooongFunction( std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); llvm-svn: 221989
* clang-format: Support assignments as conditional operands.Daniel Jasper2014-11-141-0/+20
| | | | | | | | | | | | | | | | | | | | | Before: return a != b // comment ? a : a = a != b // comment ? a = b : a; After: return a != b // comment ? a : a = a != b // comment ? a = b : a; llvm-svn: 221987
* clang-format: Improve indentation of comments in expressions.Daniel Jasper2014-11-141-0/+8
| | | | | | | | | | | | | | | | | | | | | Before: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; After: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; llvm-svn: 221985
* clang-format: Format extern "C" blocks like namespace blocks.Nico Weber2014-11-131-1/+24
| | | | | | | | | | | | | | | | | | | | | namespace blocks act as if KeepEmptyLinesAtTheStartOfBlocks is always true, and aren't collapsed to a single line even if they would fit. Do the same for extern "C" blocks. Before, extern "C" { void ExternCFunction(); } was collapsed into `extern "C" { void ExternCFunction(); }`. Now it stays like it was. Fixes http://crbug.com/432640 and part of PR21419. llvm-svn: 221897
* clang-format: Improve handling of comments in binary expressions.Daniel Jasper2014-11-111-0/+3
| | | | | | | | | | | | | | | | | Before: b = a && // Comment b.c && d; After: b = a && // Comment b.c && d; This fixes llvm.org/PR21535. llvm-svn: 221727
* clang-format: Preserve trailing-comma logic even with comments.Daniel Jasper2014-11-111-3/+10
| | | | | | | | | | | | | | | Before: vector<int> SomeVector = {// aaa 1, 2, }; After: vector<int> SomeVector = { // aaa 1, 2, }; llvm-svn: 221699
* clang-format: Fix pointer formatting.Daniel Jasper2014-11-101-0/+3
| | | | | | | | | Before: void f(Bar* a = nullptr, Bar * b); After: void f(Bar* a = nullptr, Bar* b); llvm-svn: 221609
* Revert "clang-format: [js] Updates to Google's JavaScript style."Daniel Jasper2014-11-051-2/+2
| | | | | | | | This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b. Apparently, this change was a bit premature. llvm-svn: 221365
* clang-format: Add test to prevent regression in r221125.Daniel Jasper2014-11-051-1/+2
| | | | llvm-svn: 221339
* clang-format: Improve free-standing macro detection.Daniel Jasper2014-11-051-0/+5
| | | | | | | | | | | | Before: SOME_WEIRD_LOG_MACRO << "Something long enough to cause a line break"; After: SOME_WEIRD_LOG_MACRO << "Something long enough to cause a line break"; llvm-svn: 221338
* clang-format: Fix false positive in lambda detection.Daniel Jasper2014-11-021-0/+1
| | | | | | | | | | | | Before: delete [] a -> b; After: delete[] a->b; This fixes part of llvm.org/PR21419. llvm-svn: 221114
* clang-format: [js] Updates to Google's JavaScript style.Daniel Jasper2014-10-311-2/+2
| | | | | | The style guide is changing.. llvm-svn: 220977
* clang-format: Format line if invoked on the trailing newline.Daniel Jasper2014-10-291-1/+13
| | | | llvm-svn: 220883
* clang-format: Improve && detection as binary operator.Daniel Jasper2014-10-281-1/+8
| | | | | | | | | | | | | | | | Before: template <class T, class = typename ::std::enable_if< ::std::is_array<T>{}&& ::std::is_array<T>{}>::type> void F(); After: template <class T, class = typename ::std::enable_if< ::std::is_array<T>{} && ::std::is_array<T>{}>::type> void F(); llvm-svn: 220813
* clang-format: Fix test.Daniel Jasper2014-10-281-1/+1
| | | | llvm-svn: 220807
* clang-format: Improve && detection as binary operators.Daniel Jasper2014-10-281-0/+5
| | | | | | | | | | | | | | | Before: template <class T, class = typename std::enable_if<std::is_integral< T>::value &&(sizeof(T) > 1 || sizeof(T) < 8)>::type> void F(); After: template <class T, class = typename std::enable_if< std::is_integral<T>::value && (sizeof(T) > 1 || sizeof(T) < 8)>::type> void F(); llvm-svn: 220805
* clang-format: Improve function declaration detection.Daniel Jasper2014-10-281-0/+2
| | | | | | | | | | | | | | | | | Before: ReturnType MACRO FunctionName() {} After: ReturnType MACRO FunctionName() {} This fixes llvm.org/PR21404. I wonder what the motivation for that if-condition was. But as no test breaks, ... llvm-svn: 220801
* clang-format: [ObjC] Add separate flag to control indentation in blocksDaniel Jasper2014-10-281-37/+45
| | | | | | | | | | Apparently, people are very much divided on what the "correct" indentation is. So, best to give them a choice. The new flag is called ObjCBlockIndentWidth and the default is now set to the same value as IndentWidth for the pre-defined styles. llvm-svn: 220784
* clang-format: Don't break after very short return types.Daniel Jasper2014-10-271-10/+10
| | | | | | | | | | | | | | Before: void SomeFunction(int parameter); After: void SomeFunction( int parameter); (Unless AlwaysBreakAfterDefinitionReturnType after type is set). llvm-svn: 220686
* clang-format: Fix bad merging of lines in nested blocks.Daniel Jasper2014-10-271-0/+8
| | | | | | | | | | | | | | | Before: SomeFunction([]() { #define A a return 43; }); After: SomeFunction([]() { #define A a return 43; }); llvm-svn: 220684
* clang-format: Fix incorrect space after "<".Daniel Jasper2014-10-231-0/+1
| | | | | | | | | | Before: bool a = 2 <::SomeFunction(); After: bool a = 2 < ::SomeFunction(); llvm-svn: 220505
* clang-format: Use AllowShortBlocksOnASingleLine for ObjC blocks, too.Daniel Jasper2014-10-221-17/+28
| | | | llvm-svn: 220375
* clang-format: Fix broken test.Daniel Jasper2014-10-221-1/+1
| | | | llvm-svn: 220374
* clang-format: Fix incorrect trailing return arrow detection.Daniel Jasper2014-10-221-0/+1
| | | | | | | | | | Before: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa -> f()) {} After: auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {} llvm-svn: 220373
* clang-format: [ObjC] Fix spacing in block variable parameters.Daniel Jasper2014-10-211-0/+1
| | | | | | | | | | Before: { void (^block)(Object * x); } After: { void (^block)(Object *x); } llvm-svn: 220270
OpenPOWER on IntegriCloud