summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Add special case to reduce indentaiton in streams.Daniel Jasper2014-04-161-0/+12
| | | | | | | | | | | | | | | | 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
* Fix assertion when breaking string literals with tab characters.Alexander Kornienko2014-04-151-1/+11
| | | | | | | | | | | | | | 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-151-5/+5
| | | | | | | | | | | | | | | | 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
* xDaniel Jasper2014-04-151-0/+3
| | | | llvm-svn: 206268
* clang-format: Basic support for C++1y.Daniel Jasper2014-04-151-0/+4
| | | | | | | | | | | Before: int bi{1 '000' 000}; After: int bi{1'000'000}; This fixes llvm.org/PR19342. llvm-svn: 206263
* clang-format: Fix regression caused by r206165.Daniel Jasper2014-04-141-0/+10
| | | | llvm-svn: 206173
* clang-format: Fix incorrect &&-detection in macros.Daniel Jasper2014-04-141-0/+1
| | | | | | | | | | | | 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-6/+15
| | | | | | | 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/+14
| | | | | | | | | | | | | | | | 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-141-2/+11
| | | | | | | | | | | | | | | | 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-141-0/+92
| | | | | | | | | | | | | | | | | | | | | 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-6/+7
| | | | | | | | | | | | Before: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY( aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 206155
* clang-format: Fix false positive in braced list detection in protos.Daniel Jasper2014-04-101-0/+8
| | | | llvm-svn: 205954
* clang-format: Treat a trailing comment like a trailing comma in braced lists.Daniel Jasper2014-04-091-3/+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/+3
| | | | | | | | | | | | 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-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | 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-0/+6
| | | | | | | | | | | | | | | | | | | | 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-5/+6
| | | | | | | 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-0/+6
| | | | llvm-svn: 205763
* clang-format: Correctly understand arrays of pointers.Daniel Jasper2014-04-081-0/+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-081-5/+30
| | | | | | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | | | | | | | 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-2/+3
| | | | | | | | | | | | | | | | | | | | 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
* clang-format: Understand that "auto" is a type.Daniel Jasper2014-04-031-0/+6
| | | | | | | | | | Before: MACRO(auto * a); After: MACRO(auto *a); llvm-svn: 205517
* Fixing the MSVC 2012 build bot, which cannot do initializer lists yet. ↵Aaron Ballman2014-04-011-2/+5
| | | | | | Amends r205307. llvm-svn: 205325
* clang-format: Support configurable list of foreach-macros.Daniel Jasper2014-04-011-0/+16
| | | | | | | | This fixes llvm.org/PR17242. Patch by Brian Green, thank you! llvm-svn: 205307
* clang-format: Fix aligning of comments and escaped newlines in macros.Daniel Jasper2014-03-281-0/+5
| | | | | | | | | | | | | | Before: #define A \ int i; /*a*/ \ int jjj; /*b*/ After: #define A \ int i; /*a*/ \ int jjj; /*b*/ llvm-svn: 205011
* clang-format: Recognize more ObjC blocks with parameters/return type.Daniel Jasper2014-03-281-0/+4
| | | | llvm-svn: 204990
* Improve handling of bool expressions in template arguments.Manuel Klimek2014-03-271-0/+6
| | | | | | | Now correctly formats: foo<true && false>(); llvm-svn: 204950
* clang-format: Avoid line-breaks that increase the current column.Daniel Jasper2014-03-271-3/+2
| | | | | | | | | | | | | | | | | | 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
* Fix bool expression special case.Manuel Klimek2014-03-271-0/+8
| | | | | | | | Clang-format now correctly formats: some_type<a * b> v; template <bool a, bool b> typename enabled_if<a && b>::type f() {} llvm-svn: 204913
* clang-format: Correctly identify ObjC Block with return type.Daniel Jasper2014-03-271-0/+4
| | | | llvm-svn: 204905
* clang-format: Fix incorrect &/* detection.Daniel Jasper2014-03-251-0/+2
| | | | | | | | | | Before: STATIC_ASSERT((a &b) == 0); After: STATIC_ASSERT((a & b) == 0); llvm-svn: 204709
* clang-format: Add flag for removing empty lines at the start of blocks.Daniel Jasper2014-03-211-2/+22
| | | | | | | This unbreaks polly-formatting-tests and we can make a decision for LLVM style independently. llvm-svn: 204467
* clang-format: Don't remove empty lines at the start of namespaces.Daniel Jasper2014-03-211-0/+10
| | | | llvm-svn: 204462
* clang-format: Remove empty lines at the beginning of blocks.Daniel Jasper2014-03-211-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | They very rarely aid readability. Formatting: void f() { if (a) { f(); } } Now leads to: void f() { if (a) { f(); } } llvm-svn: 204460
* clang-format: Let a trailing comma in braced lists enforce linebreaks.Daniel Jasper2014-03-211-4/+10
| | | | | | | | | | | | | | Before: vector<int> x{1, 2, 3, 4, }; After: vector<int> x{ 1, 2, 3, 4, }; This fixes llvm.org/PR18519. llvm-svn: 204458
* clang-format: Fix for r204456.Daniel Jasper2014-03-211-0/+7
| | | | llvm-svn: 204457
* clang-format: Preserve meaning of trailing comments on parameters.Daniel Jasper2014-03-211-0/+19
| | | | | | | | | | | | | | | | | | Formatting: SomeFunction(a, b, // comment c); Before: SomeFunction(a, b, // comment c); After: SomeFunction(a, b, // comment c); llvm-svn: 204456
* clang-format: Detect function-like macros only when upper case is used.Alexander Kornienko2014-03-181-12/+33
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D3110 llvm-svn: 204156
* Fix crasher bug.Manuel Klimek2014-03-181-0/+14
| | | | | | | | | | | | | | | Due to not resetting the fake rparen data on the token when iterating over annotated lines, we would pop the last element of the paren stack. This patch fixes the underlying root cause, and makes the code more robust against similar problems in the future: - reset the first token when iterating on the same annotated lines due to preprocessor branches - never pop the last element from the paren stack, so we do not crash, but rather incorrectly format - add assert()s so we can figure out if our assumptions are violated llvm-svn: 204140
* clang-format: Indent from dict literal labels.Daniel Jasper2014-03-171-0/+5
| | | | | | | | | | | | | | | | Before: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, }; After: @{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee : regularFont, }; llvm-svn: 204041
* clang-format: Prevent ObjC code from confusing the braced-init detectionDaniel Jasper2014-03-131-0/+8
| | | | | | | | | | | | | | | | | | | | | | | This was leading to bad formatting, e.g.: Before: f(^{ @autoreleasepool { if (a) { g(); } } }); After: f(^{ @autoreleasepool { if (a) { g(); } } }); llvm-svn: 203777
* clang-format: Fix crasher.Daniel Jasper2014-03-121-0/+4
| | | | | | | | | | Caused by unknown tokens (e.g. "\n") not properly updating the state. Example: const char* c = STRINGIFY( \na : b); llvm-svn: 203645
* clang-format: Avoid unnecessary break before lambda return type.Daniel Jasper2014-03-111-0/+4
| | | | | | | | | | | | | | | | | Before: auto aaaaaaaa = [](int i, // break int j) -> int { return fffffffffffffffffffffffffffffffffffffff(i * j); }; After: auto aaaaaaaa = [](int i, // break int j) -> int { return fffffffffffffffffffffffffffffffffffffff(i * j); }; llvm-svn: 203562
* clang-format: Fix another false positive in the lambda detection.Daniel Jasper2014-03-111-0/+1
| | | | | | | | | | Before: int i = (*b)[a] -> f(); After: int i = (*b)[a]->f(); llvm-svn: 203557
* clang-format: Fix incorrect lambda recognition exposed by r203452.Daniel Jasper2014-03-111-0/+1
| | | | | | | | | | Before: int i = a[a][a] -> f(); After: int i = a[a][a]->f(); llvm-svn: 203556
* clang-format: Detect weird macro lambda usage.Daniel Jasper2014-03-111-0/+5
| | | | | | | | | | | | | | Before: void f() { MACRO((const AA & a) { return 1; }); } After: void f() { MACRO((const AA &a) { return 1; }); } llvm-svn: 203551
* clang-format: Add spaces between lambdas and comments.Daniel Jasper2014-03-101-0/+6
| | | | | | | | | | | | | | | | | | Before: void f() { bar([]() {}// Does not respect SpacesBeforeTrailingComments ); } After: void f() { bar([]() {} // Does not respect SpacesBeforeTrailingComments ); } This fixes llvm.org/PR19017. llvm-svn: 203466
OpenPOWER on IntegriCloud