summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Fix unary operator detection in corner case.Daniel Jasper2014-08-291-2/+1
| | | | | | | | | | Before: decltype(* ::std::declval<const T &>()) void F(); After: decltype(*::std::declval<const T &>()) void F(); llvm-svn: 216724
* clang-format: Fix regression in formatting of braced initializers.Daniel Jasper2014-08-271-1/+3
| | | | | | | | | | | | Before: Node n{1, Node{1000}, // 2}; After: Node n{1, Node{1000}, // 2}; llvm-svn: 216540
* clang-format: New option SpacesInSquareBrackets.Daniel Jasper2014-08-261-4/+9
| | | | | | | | | | | | | | | | Before: int a[5]; a[3] += 42; After: int a[ 5 ]; a[ 3 ] += 42; Fixes LLVM bug #17887 (http://llvm.org/bugs/show_bug.cgi?id=17887). Patch by Marek Kurdej, thank you! llvm-svn: 216449
* clang-format: Improve handling of block comments in braced lists.Daniel Jasper2014-08-261-11/+11
| | | | | | | | | | | | Before: std::vector<int> v = { 1, 0 /* comment */ }; After: std::vector<int> v = {1, 0 /* comment */}; llvm-svn: 216445
* clang-format: Understand sequenced casts.Daniel Jasper2014-08-251-2/+3
| | | | | | | | | | | | This fixed llvm.org/PR20712. Before: int i = (int)(int) -2; After: int i = (int)(int)-2; llvm-svn: 216378
* clang-format: Prefer breaking after return type over template paramDaniel Jasper2014-08-151-0/+2
| | | | | | | | | | | | | | Before: typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa aaaaaaaaaa< aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bool *aaaaaaaaaaaaaaaaaa, bool *aa) {} After: typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( bool *aaaaaaaaaaaaaaaaaa, bool *aa) {} llvm-svn: 215693
* clang-format: [proto] Understand text-format nesting without :Daniel Jasper2014-08-151-4/+6
| | | | | | | | | | | | | | | | | Before: option (MyProto.options) = { field_c : "OK" msg_field{field_d : 123} }; After: option (MyProto.options) = { field_c : "OK" msg_field{field_d : 123} }; (Note that the colon after "msg_field" is optional). llvm-svn: 215692
* clang-format: Fix AlwaysBreakAfterDefinitionReturnType in Stroutrup styleDaniel Jasper2014-08-141-1/+3
| | | | | | | | | | | | | | | | | | | | | Before: template <class T> T *f(T &c) // Problem here: no line break before f { return NULL; } After: template <class T> T * f(T &c) { return NULL; } Patch by Marek Kurdej, thank you! llvm-svn: 215633
* clang-format: Support chained dereferenced assignments.Daniel Jasper2014-08-141-1/+2
| | | | | | | | | | Before: x = * a(x) = *a(y); After: x = *a(x) = *a(y); llvm-svn: 215632
* clang-format: Support breaking arguments of function type typedefs.Daniel Jasper2014-08-141-3/+4
| | | | | | | | | | | | | Before: typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)( const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)( const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 215631
* Fix crasher bug in clang-format.Manuel Klimek2014-08-131-1/+4
| | | | llvm-svn: 215549
* clang-format: Understand #defines defining system includes.Daniel Jasper2014-08-131-2/+12
| | | | | | | | | | Before: #define MY_IMPORT < a / b > After: #define MY_IMPORT <a/b> llvm-svn: 215527
* clang-format: Avoid bad line break.Daniel Jasper2014-08-121-2/+3
| | | | | | | | | | | | | Before: int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa); After: int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa( const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa); llvm-svn: 215442
* clang-format: Prefer not to put lambdas on a single line.Daniel Jasper2014-08-081-0/+2
| | | | | | | | | | | | | | Before: string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() { SomeOtherFunctioooooooooooooooooooooooooon(); }); After: string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() { SomeOtherFunctioooooooooooooooooooooooooon(); }); llvm-svn: 215197
* clang-format: Correct SBPO_Always-behavior after function-like keywordsDaniel Jasper2014-08-061-1/+1
| | | | | | | | | | | | | | | | | Before: auto f (int x) -> decltype(x) { return sizeof(x); } int g () noexcept(someCall ()); static_assert(sizeof(char) == 1, "Your compiler is broken"); After: auto f (int x) -> decltype (x) { return sizeof (x); } int g () noexcept (someCall ()); static_assert (sizeof (char) == 1, "Your compiler is broken"); This fixes llvm.org/PR20559. Patch by Roman Kashitsyn, thank you! llvm-svn: 214969
* [PR19983] SBPO_Always not covering all the cases.Chad Rosier2014-08-051-1/+1
| | | | | | | Patch by "Roman Kashitsyn" <romankashicin@gmail.com>. Phabricator revision: http://reviews.llvm.org/D4788 llvm-svn: 214904
* clang-format: Add option to always break after a function's return type.Daniel Jasper2014-08-051-0/+5
| | | | | | | | | | This is required for GNU coding style, among others. Also update the configuration documentation. Modified from an original patch by Jarkko Hietaniemi, thank you! llvm-svn: 214858
* clang-format: Add a space in ObjC protocols.Daniel Jasper2014-08-011-4/+5
| | | | | | | | | | Before: @interface Foo (HackStuff)<MyProtocol> After: @interface Foo (HackStuff) <MyProtocol> llvm-svn: 214508
* clang-format: Understand 'typename' in placement new.Daniel Jasper2014-07-301-1/+2
| | | | | | | | | | | | Before: new (aaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); After: new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 214300
* clang-format: [proto] Improve formatting of text-proto options.Daniel Jasper2014-07-281-2/+4
| | | | | | Initial patch and tests by Kaushik Sridharan, thank you! llvm-svn: 214084
* clang-format: Improve operator and template recognition.Daniel Jasper2014-07-281-7/+3
| | | | | | | | | | Before: static_assert(is_convertible < A &&, B > ::value, "AAA"); After: static_assert(is_convertible<A &&, B>::value, "AAA"); llvm-svn: 214075
* clang-format: Improve pointer/reference detection.Daniel Jasper2014-07-281-1/+2
| | | | | | | | | | Before (with left pointer alignment): void f(int i = 0, SomeType* *temps = NULL); After: void f(int i = 0, SomeType** temps = NULL); llvm-svn: 214071
* clang-format: Fix unary operator recognition.Daniel Jasper2014-07-281-1/+1
| | | | | | | | | | Before: int x = ~ * p; After: int x = ~*p; llvm-svn: 214070
* clang-format: Fix formatting of lock annotations in lambda definitions.Daniel Jasper2014-07-281-0/+4
| | | | | | | | | | Before: SomeFunction([](int i)LOCKS_EXCLUDED(a) {}); After: SomeFunction([](int i) LOCKS_EXCLUDED(a) {}); llvm-svn: 214069
* Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ↵David Blaikie2014-07-191-2/+1
| | | | | | | | | | | ".reset()" It's also possible to just write "= nullptr", but there's some question of whether that's as readable, so I leave it up to authors to pick which they prefer for now. If we want to discuss standardizing on one or the other, we can do that at some point in the future. llvm-svn: 213439
* clang-format: Fix parsing of conditional expressions.Daniel Jasper2014-07-171-1/+1
| | | | | | | | | | | | | | | Before: aaaaaa = aaaaaaaaaaaa ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: aaaaaa = aaaaaaaaaaaa ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 213258
* clang-format: Improve cast detection (fix false positive).Daniel Jasper2014-07-141-0/+2
| | | | | | | | | | Before: fn(a)(b)+1; After: fn(a)(b) + 1; llvm-svn: 212935
* clang-format: Fix behavior around pointer-to-member invocations.Daniel Jasper2014-07-091-3/+4
| | | | | | | | | | | | Before: (aaaaaaaaaa->* bbbbbbb)(aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)); After: (aaaaaaaaaa->*bbbbbbb)( aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)); llvm-svn: 212617
* clang-format: Revamp function declaration/definition indentation.Daniel Jasper2014-07-091-4/+43
| | | | | | | | | | | | | | Key changes: - Correctly (well ...) distinguish function declarations and variable declarations with ()-initialization. - Don't indent when breaking function declarations/definitions after the return type. - Indent variable declarations and typedefs when breaking after the type. This fixes llvm.org/PR17999. llvm-svn: 212591
* clang-format: Support member function reference qualifiers.Daniel Jasper2014-06-301-1/+1
| | | | | | | | | | | | | Before: string // break operator()() & {} After: string // break operator()() & {} llvm-svn: 212041
* clang-format: Improve expression heuristics.Daniel Jasper2014-06-301-0/+2
| | | | | | | | | | | | | Upon encountering a binary operator inside parentheses, assume that the parentheses contain an expression. Before: MACRO('0' <= c&& c <= '9'); After: MACRO('0' <= c && c <= '9'); llvm-svn: 212040
* clang-format: Understand that breaking before lambdas is fine.Daniel Jasper2014-06-241-1/+1
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([]( const aaaaaaaaaa &a) { return a; }); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( [](const aaaaaaaaaa &a) { return a; }); llvm-svn: 211575
* clang-format: [proto] Add required space before absolute references.Daniel Jasper2014-06-231-0/+4
| | | | llvm-svn: 211488
* clang-format: Fix corner case in pointer/reference detection.Daniel Jasper2014-06-231-0/+2
| | | | llvm-svn: 211487
* clang-format: Introduce style with spaces on both sides of */&.Daniel Jasper2014-06-171-3/+3
| | | | | | | Patch by Janusz Sobczak (slightly extended). This fixes llvm.org/19929. llvm-svn: 211098
* clang-format: Fix pointer/reference detection after decltype.Daniel Jasper2014-06-111-1/+2
| | | | | | | | | | Before: [](const decltype(*a) & value) {} After: [](const decltype(*a)& value) {} llvm-svn: 210643
* clang-format: [JS] Treat dict literals similar to objc method exprs.Daniel Jasper2014-06-101-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } } After: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } }; llvm-svn: 210537
* clang-format: Increase penalty for wrapping array subscript expressionsDaniel Jasper2014-06-101-1/+1
| | | | | | | | | | | | | Before: aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0].aaaaaaa [0].aaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0] .aaaaaaa[0] .aaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 210529
* [C++11] Use 'nullptr'.Craig Topper2014-06-091-3/+4
| | | | llvm-svn: 210448
* clang-format: Leave empty lines within UnwrappedLines.Daniel Jasper2014-06-041-0/+2
| | | | | | | | These are commonly used to structure things like enums or long braced lists. There doesn't seem to be a good reason to have the behavior in such structures be different from the behavior between statements. llvm-svn: 210183
* clang-format: Refactor indentation behavior for multiple nested blocks.Daniel Jasper2014-06-031-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a few oddities when formatting multiple nested JavaScript blocks, e.g.: Before: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); After: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); llvm-svn: 210097
* clang-format: Fix special case of binary operator detection.Daniel Jasper2014-06-021-0/+6
| | | | | | | | | | | | | | | | | There is a pattern where evaluation order is used as control flow. This patch special-cases a commonly occuring version of this pattern. Before: Aaaaa *aaa = nullptr; // ... aaa &&aaa->f(); After: Aaaaa *aaa = nullptr; // ... aaa && aaa->f(); llvm-svn: 210017
* clang-format: No space between ")" and braced init list.Daniel Jasper2014-06-021-1/+2
| | | | | | | | | | | | Before: auto j = decltype(i) {}; After: auto j = decltype(i){}; This fixes llvm.org/PR19892. llvm-svn: 210013
* clang-format: Fix Allman brace breaking of enums.Daniel Jasper2014-06-021-4/+9
| | | | | | | | | | | | | | | | | | Before: enum Side { LEFT, RIGHT }; After: enum Side { LEFT, RIGHT }; This fixes llvm.org/PR19911. llvm-svn: 210011
* clang-format: Fix trailing const (etc.) with Allman brace style.Daniel Jasper2014-06-021-2/+2
| | | | | | | | | | | | | | | | | | Before: void someLongFunction(int someLongParameter) const { } After: void someLongFunction( int someLongParameter) const { } This fixes llvm.org/PR19912. llvm-svn: 210010
* clang-format: Don't break before a case's colon.Daniel Jasper2014-05-281-4/+5
| | | | | | | | | | | | | | | | | | Before (with just the right line length: switch (a) { case some_namespace::some_constant : return; } After: switch (a) { case some_namespace:: some_constant: return; } llvm-svn: 209725
* clang-format: Keep '{' of dict literals on the same line in Allman styleDaniel Jasper2014-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | Before: void f() { [object someMethod:@ { @"a" : @"b" }]; } After: void f() { [object someMethod:@{ @"a" : @"b" }]; } This fixes llvm.org/PR19854. llvm-svn: 209615
* clang-format: Don't use Allman brace breaking for ObjC blocks.Daniel Jasper2014-05-221-1/+2
| | | | | | It just seems wrong. This fixes llvm.org/PR19736. llvm-svn: 209440
* clang-format: [JS] Understand line breaks in concatenated strings.Daniel Jasper2014-05-221-0/+7
| | | | | | | | | | | | | | Before: var literal = 'hello ' + 'world'; After: var literal = 'hello ' + 'world'; There is no reason to concatenated two string literals with a '+' unless the line break is intended. llvm-svn: 209413
* clang-format: Correctly identify multiplications in braces init lists.Daniel Jasper2014-05-221-0/+2
| | | | | | | | | | | | | Before: int i{a *b}; After: int i{a * b}; Also fix unrelated issue where braced init lists were counted as blocks and prevented single-line functions. llvm-svn: 209412
OpenPOWER on IntegriCloud