summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Make wrapping after "./->" cheaper, even if the elementDaniel Jasper2015-12-071-4/+14
| | | | | | | | | | | | | | | | | | | before it is not a closing parenthesis. Otherwise, this frequently leads to "hanging" indents that users perceive as "weird". Before: return !soooooooooooooome_map.insert( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .second; After: return !soooooooooooooome_map .insert(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .second; llvm-svn: 254933
* clang-format: Make it possible to turn off comment reflowing.Daniel Jasper2015-12-011-0/+8
| | | | llvm-svn: 254414
* clang-format: treat Q_SIGNALS as an access modifierDaniel Jasper2015-12-011-3/+13
| | | | | | Patch by Alexander Richardson, thank you! llvm-svn: 254407
* This fixes https://llvm.org/bugs/show_bug.cgi?id=25329, as well asDaniel Jasper2015-12-011-1/+55
| | | | | | | | | | | misalignments like the following: int a, b = 2; int c = 3; Patch by Beren Minor, thanks! llvm-svn: 254406
* clang-format: Re-add code path deleted in r253873 and add missing test.Daniel Jasper2015-11-231-0/+1
| | | | llvm-svn: 253900
* clang-format: Fix incorrect cast detection.Daniel Jasper2015-11-231-0/+1
| | | | | | | | | | Before: bool b = f(g<int>)&&c; After: bool b = f(g<int>) && c; llvm-svn: 253872
* clang-format: If the template list of a variable declaration spansDaniel Jasper2015-11-231-1/+2
| | | | | | | | | | | | | | | multiple lines, also break before the variable name. Before: std::vector<aaaaaa, // wrap aa> aaa; After: std::vector<aaaaaa, // wrap aa> aaa; llvm-svn: 253871
* clang-format: Make moving of the Cursor work properly when sorting #includes.Daniel Jasper2015-11-231-0/+20
| | | | llvm-svn: 253860
* clang-format: Make sorting includes respect // clang-format offDaniel Jasper2015-11-211-0/+19
| | | | llvm-svn: 253772
* clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"Daniel Jasper2015-11-201-0/+6
| | | | | | work properly. llvm-svn: 253674
* clang-format: [JS] Properly add a space after "in" in for loops.Daniel Jasper2015-11-201-0/+5
| | | | llvm-svn: 253672
* clang-format: [JS] struct and union aren't keywords / reserved words.Daniel Jasper2015-11-201-0/+2
| | | | llvm-svn: 253671
* clang-format: Don't use incorrect space in macro calls with operators.Daniel Jasper2015-11-201-0/+2
| | | | | | | | | | | | Before: MACRO(> ); After: MACRO(>); Not overly important, but easy and good for symmetry reasons :-). llvm-svn: 253669
* clang-format: [Proto] Support extending message.Daniel Jasper2015-11-201-0/+5
| | | | | | | | | | | | Before: extend.foo.Bar { } After: extend .foo.Bar { } llvm-svn: 253667
* clang-format: Enable #include sorting by default.Daniel Jasper2015-11-162-0/+12
| | | | | | | | | This has seen quite some usage and I am not aware of any issues. Also add a style option to enable/disable include sorting. The existing command line flag can from now on be used to override whatever is set in the style. llvm-svn: 253202
* clang-format: Simplify and improve stop condition for formattingDaniel Jasper2015-11-021-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | unaffected lines with incorrect initial indent. Starting from: namespace { int i; // There shouldn't be indentation here. int j; // <- call clang-format on this line. } Before: namespace { int i; int j; } After: namespace { int i; int j; } llvm-svn: 251824
* clang-format: Be slightly more cautious when formatting subsequent lines ↵Daniel Jasper2015-11-011-0/+21
| | | | | | | | | | | | | | | | | after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing closing brace, e.g. while writing code in an editor. Summary: With this change, clang-format stops formatting when either it leaves the current scope or when it comes back to the initial scope after going into a nested one. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14213 llvm-svn: 251760
* Format: support inline namespacesSaleem Abdulrasool2015-10-301-0/+7
| | | | | | | | Correct handling for C++17 inline namespaces. We would previously fail to identify the inline namespaces as a namespace name since multiple ones may be concatenated now with C++17. llvm-svn: 251690
* clang-format: [JS] Add goog.setTestOnly to the list of stuff thatDaniel Jasper2015-10-291-0/+2
| | | | | | is import-statement-like and shouldn't be wrapped. llvm-svn: 251643
* clang-format: When a line is formatted, also format subsequence lines if ↵Daniel Jasper2015-10-281-8/+18
| | | | | | | | | | | | | | their indent is off. Summary: This is especially important so that if a change is solely inserting a block around a few statements, clang-format-diff.py will still clean up and add indentation to the inner parts. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14105 llvm-svn: 251474
* clang-format: Undo unwanted format change done in r251405.Daniel Jasper2015-10-271-0/+5
| | | | | | | | Specifically, don't wrap between the {} of an empty constructor if the "}" falls on column 81 and ConstructorInitializerAllOnOneLineOrOnePerLine is set. llvm-svn: 251406
* clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.Daniel Jasper2015-10-272-56/+82
| | | | | | | | | | | | | | | | | | | | Summary: If this option is set, clang-format will always insert a line wrap, e.g. before the first parameter of a function call unless all parameters fit on the same line. This obviates the need to make a decision on the alignment itself. Use this style for Google's JavaScript style and add some minor tweaks to correctly handle nested blocks etc. with it. Don't use this option for for/while loops. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14104 llvm-svn: 251405
* clang-format: Fix false positive in cast detection.Daniel Jasper2015-10-261-0/+5
| | | | | | | | | | Before (with spaces in parentheses): void inFunction() { std::function<void( int, int )> fct; } After: void inFunction() { std::function<void( int, int)> fct; } llvm-svn: 251284
* clang-format: Teach --sort-includes to interleave #include and #import.Nico Weber2015-10-211-0/+9
| | | | | | | | | | clang accepts both #include and #import for includes (the latter having an implicit header guard). Let clang-format interleave both types if --sort-includes is passed. #import is used frequently in Objective-C code. http://reviews.llvm.org/D13853 llvm-svn: 250909
* clang-format: Extend main header include sorting heuristic to Objective-C files.Nico Weber2015-10-191-0/+7
| | | | llvm-svn: 250675
* clang-format: [JS] Handle string literals spanning character classes.Daniel Jasper2015-10-181-0/+10
| | | | | | | | | | | | | | | If a RegExp contains a character group with a quote (/["]/), the trailing end of it is first tokenized as a string literal, which leads to the merging code seeing an unbalanced bracket. This change parses regex literals from the left hand side. That simplifies the parsing code and also allows correctly handling escapes and character classes, hopefully correctly parsing all regex literals. Patch by Martin Probst, thank you. Review: http://reviews.llvm.org/D13765 llvm-svn: 250648
* clang-format/java: Break after annotations on fields in Chromium style.Nico Weber2015-10-151-0/+4
| | | | | | | | | | | Chromium follows the Android style guide for Java code, and that doesn't make the distinction between fields and non-fields that the Google Java style guide makes: https://source.android.com/source/code-style.html#use-standard-java-annotations https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations llvm-svn: 250422
* clang-format: Fixed typecast getting put on a separate line from theDaniel Jasper2015-10-121-0/+7
| | | | | | | | | | key in Obj-C dictionary literals This fixes: https://llvm.org/PR22647 Patch by Kent Sutherland. Thank you. llvm-svn: 250010
* clang-format: [JS] handle character classes in regexes.Daniel Jasper2015-10-121-0/+6
| | | | | | | | | Slashes in regular expressions do not need to be escaped and do not terminate the regular expression even without a preceding backslash. Patch by Martin Probst. Thank you. llvm-svn: 250009
* clang-format: Fixed missing space between Obj-C for/in and a typecast.Daniel Jasper2015-10-071-0/+13
| | | | | | | | | | | | | | | | | Fixes this bug: https://llvm.org/bugs/show_bug.cgi?id=24504 TokenAnnotator::spaceRequiredBetween was handling TT_ForEachMacro but not TT_ObjCForIn, so lines that look like: for (id nextObject in (NSArray *)myArray) would incorrectly turn into: for (id nextObject in(NSArray *)myArray) Patch by Kent Sutherland, thank you. llvm-svn: 249553
* [clang-format] Stop alignment sequences on open braces and parens whenDaniel Jasper2015-10-071-0/+30
| | | | | | | | | | | | | | | | | aligning assignments. This was done correctly when aligning the declarations, but not when aligning assignments. FIXME: The code between assignments and declarations alignment is roughly duplicated and would benefit from factorization. Bug 25090: https://llvm.org/bugs/show_bug.cgi?id=25090 Patch by Beren Minor. Thank you. llvm-svn: 249552
* Make clang-format actually respect custom brace wrapping flags.Daniel Jasper2015-10-071-2/+11
| | | | | | This fixes llvm.org/PR25073. llvm-svn: 249519
* clang-format: Fix false ObjC block detection.Daniel Jasper2015-10-071-0/+2
| | | | | | | | | | | Before: inline A operator^(const A &lhs, const A &rhs) {} int i; After: inline A operator^(const A &lhs, const A &rhs) {} int i; llvm-svn: 249517
* clang-format: Understand array reference types.Daniel Jasper2015-10-071-0/+1
| | | | | | | | | | | | Before: void f(Type(&parameter)[10]) {} void f(Type (*parameter)[10]) {} After: void f(Type (&parameter)[10]) {} void f(Type (*parameter)[10]) {} llvm-svn: 249502
* clang-format: Fix false positive in pointer/reference detection.Daniel Jasper2015-10-071-0/+1
| | | | | | | | | | Before: return options != nullptr &&operator==(*options); After: return options != nullptr && operator==(*options); llvm-svn: 249501
* clang-format: Make IncludeCategories configurable in .clang-format file.Daniel Jasper2015-10-061-0/+12
| | | | | | | | | This was made much easier by introducing an IncludeCategory struct to replace the previously used std::pair. Also, cleaned up documentation and added examples. llvm-svn: 249392
* [clang-format] Add support of consecutive declarations alignmentDaniel Jasper2015-10-011-0/+184
| | | | | | | | | | | | | | | | | | | This allows clang-format to align identifiers in consecutive declarations. This is useful for increasing the readability of the code in the same way the alignment of assignations is. The code is a slightly modified version of the consecutive assignment alignment code. Currently only the identifiers are aligned, and there is no support of alignment of the pointer star or reference symbol. The patch also solve the issue of alignments not being possible due to the ColumnLimit for both the existing AlignConsecutiveAligments and the new AlignConsecutiveDeclarations. Patch by Beren Minor, thank you. Review: http://reviews.llvm.org/D12362 llvm-svn: 248999
* clang-format: Add a new brace style "custom" as well as flags toDaniel Jasper2015-09-291-1/+30
| | | | | | | | | | | | | | | control the individual braces. The existing choices for brace wrapping are now merely presets for the different flags that get expanded upon calling the reformat function. All presets have been chose to keep the existing formatting, so there shouldn't be any difference in formatting behavior. Also change the dump_format_style.py to properly document the nested structs that are used to keep these flags discoverable among all the configuration flags. llvm-svn: 248802
* clang-format: Extend #include sorting functionalityDaniel Jasper2015-09-291-7/+37
| | | | | | | | | Recognize the main module header as well as different #include categories. This should now mimic the behavior of llvm/utils/sort_includes.py as well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very closely. llvm-svn: 248782
* clang-format: [JS] Support pseudo-keywordsDaniel Jasper2015-09-281-0/+13
| | | | | | | | | JavaScript allows keywords to appear in IdenfierName positions, e.g. fields, or object literal members, but not as plain identifiers. Patch by Martin Probst. Thank you! llvm-svn: 248714
* clang-format: [JS] handle let (ES6)Daniel Jasper2015-09-281-0/+2
| | | | | | Patch by Martin Probst. Thank you! llvm-svn: 248713
* clang-format: Add initial #include sorting capabilities.Daniel Jasper2015-09-232-0/+109
| | | | | | | | | To implement this nicely, add a function that merges two sets of replacements that are meant to be done in sequence. This functionality will also be useful for other applications, e.g. formatting the result of clang-tidy fixes. llvm-svn: 248367
* clang-format: Fix alignConsecutiveAssignments.Daniel Jasper2015-09-221-0/+4
| | | | | | | | | | | | | It wasn't correctly handling this case: int oneTwoThree = 123; int oneTwo = 12; method(); Review: http://reviews.llvm.org/D12369 Patch by Beren Minor. Thank you! llvm-svn: 248254
* clang-format: Fix merging short case labels with comments.Daniel Jasper2015-09-211-0/+3
| | | | | | | | This fixes llvm.org/PR24877. Patch by Benjamin Daly, thank you! llvm-svn: 248145
* Remove accidental superfluous newline added in r247750.Nico Weber2015-09-151-1/+0
| | | | llvm-svn: 247752
* clang-format: In Java, `assert` is followed by an expression.Nico Weber2015-09-151-0/+5
| | | | | | Before: assert a&& b; Now: assert a && b; llvm-svn: 247750
* clang-format: Don't let a leading "template <..>" lead to wrapped initializers.Daniel Jasper2015-08-271-0/+7
| | | | | | | | | | | | | | | | | Before: Constructor() : initializer(0) {} template <typename T> Constructor() : initializer(0) {} After: Constructor() : initializer(0) {} template <typename T> Constructor() : initializer(0) {} llvm-svn: 246146
* clang-format: Add space before member function reference qualifiers.Daniel Jasper2015-08-251-27/+30
| | | | | | | | | | | | Before: SomeType MemberFunction(const Deleted &)&; After: SomeType MemberFunction(const Deleted &) &; Seems to be much more common. llvm-svn: 245934
* clang-format: Always allow break after leading annotations.Daniel Jasper2015-08-241-0/+2
| | | | | | | | | | | Before: DEPRECATED("Use NewClass::NewFunction instead.") int OldFunction( const string &parameter) {} Could not be formatted at all, as clang-format would both require and disallow the break before "int". llvm-svn: 245846
* clang-format: Make formatting of member function reference qualifiersDaniel Jasper2015-08-241-3/+6
| | | | | | | | | | | | | | more consistent. Before: SomeType MemberFunction(const Deleted &)&&; SomeType MemberFunction(const Deleted &) && { ... } After: SomeType MemberFunction(const Deleted &)&&; SomeType MemberFunction(const Deleted &)&& { ... } llvm-svn: 245843
OpenPOWER on IntegriCloud