Commit Graph

722 Commits

Author SHA1 Message Date
Daniel Jasper df51f2e634 clang-format: Fix overloading "operator," definitions more thoroughly.
Before:
  aaaaaaaaaaaaaaaaaaaaaa operator,(aaaaaaaaaaaaaaaaaaaaa &
                                   aaaaaaaaaaaaaaaaaaaaaaaaaa) const;
After:
  aaaaaaaaaaaaaaaaaaaaaa operator,(
      aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaaaaaaaaaaaaaaaaaaa) const;

llvm-svn: 257330
2016-01-11 12:55:33 +00:00
Daniel Jasper 804a276fcf clang-format: Support definitions/declarations of operator,.
Before:
  bool operator, ();

After:
  bool operator,();

llvm-svn: 257256
2016-01-09 15:56:40 +00:00
Daniel Jasper f412e26d04 clang-format: [JS] Prefer wrapping before the TypeScript return type
over wrapping before parameters.

Before:
  function someFunc(
      args: string[]): {longReturnValue: string[]} {}

After:
  function someFunc(args: string[]):
      {longReturnValue: string[]} {}

llvm-svn: 257162
2016-01-08 10:51:24 +00:00
Daniel Jasper 54353dac75 clang-format: Support weird lambda macros.
Before:
  MACRO((AA & a) { return 1; });

After:
  MACRO((AA &a) { return 1; });

llvm-svn: 257062
2016-01-07 14:36:11 +00:00
Daniel Jasper 00492f96bf clang-format: Improve line wrapping behavior in call sequences.
r256750 has been leading to an undesired behavior:

  aaaaaaaaaa
      .aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

This change increases penalty for wrapping before member accesses that aren't
calls. Thus, this is again formatted as (as it has been before r256750):

  aaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 256830
2016-01-05 13:03:50 +00:00
Daniel Jasper 5e27146df7 clang-format: [JS] Support more ES6 default exports.
llvm-svn: 256759
2016-01-04 16:10:36 +00:00
Daniel Jasper b14f6675da clang-format: [JS] Support ES6 exports of array literals.
Before:
  export default[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
		 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb];
  export default[];

After:
  export default [
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  ];
  export default [];

llvm-svn: 256758
2016-01-04 15:51:56 +00:00
Daniel Jasper ebcb71fb87 clang-format: [JS] Improve empty array literal detection.
Previously, the [] in the following example were recognized as an array
subscript leading to weird indentation.

Before:
  var aaaa = aaaaa || // wrap
                          [];

After:
  var aaaa = aaaaa || // wrap
             [];

llvm-svn: 256753
2016-01-04 13:11:41 +00:00
Daniel Jasper 42011b2106 clang-format: Fix corner case in builder-type call formatting.
Before:
  return aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa,
						  aaaaaaaaaaaaaaaaa)
      .aaaa(aaaaaaaaaaaaaa);

After:
  return aaaaaaaaaaaaaaaa
      .aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)
      .aaaa(aaaaaaaaaaaaaa);

llvm-svn: 256750
2016-01-04 12:41:11 +00:00
Daniel Jasper 9c8a774c48 clang-format: Fix corner case for lambda assignments.
Before:
  std::function<std::string(const std::string &)> my_lambda = [](
      const string &s) { return s; };

After:
  std::function<std::string(const std::string &)> my_lambda =
      [](const string &s) { return s; };

llvm-svn: 256739
2016-01-04 07:29:40 +00:00
Daniel Jasper 06a269574c clang-format: Fix corner-case in ObjC method declaration formatting
Before:
  - (void)shortf:(GTMFoo *)theFoo
     longKeyword:(NSRect)theRect
   longerKeyword:(float)theInterval
           error:(NSError **)theError {
  }

After:
  - (void)shortf:(GTMFoo *)theFoo
        longKeyword:(NSRect)theRect
      longerKeyword:(float)theInterval
              error:(NSError **)theError {
  }

llvm-svn: 256738
2016-01-04 07:29:07 +00:00
Daniel Jasper ffbad0e8aa clang-format: [Proto] Basic support for options with <> for repeated fields.
llvm-svn: 256737
2016-01-04 07:28:12 +00:00
Daniel Jasper ccff4d1e60 clang-format: [Proto] Improve wrapping of message field attributes.
Before:
  optional AAA aaa = 1 [foo =
			    {
			      key: "a"  //
			    },
			bar = {
			  key: "a"  //
			}];

After:
  optional AAA aaa = 1 [
    foo = {
      key: "a"  //
    },
    bar = {
      key: "a"  //
    }
  ];

llvm-svn: 256736
2016-01-04 07:27:33 +00:00
Daniel Jasper e1afb9b8ee clang-format: Slightly row back on r256343 by increasing penalty for
breaking between array subscripts.

Before:
  if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa]
                                                     [aaaaaaaaaaaaa])
After:
  if (aaaaaaaaaaaaaaaaaaaaaaaa &&
      aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa][aaaaaaaaaaaaa])

llvm-svn: 256640
2015-12-30 12:23:00 +00:00
Daniel Jasper 779c66f3ca clang-format: [JS] Support TypeScript 1.6 user defined type guards.
Before:
  function foo(check: Object): check
  is{foo: string, bar: string, baz: string, foobar: string} {
    return 'bar' in check;
  }

After:
  function foo(check: Object):
      check is {foo: string, bar: string, baz: string, foobar: string} {
    return 'bar' in check;
  }

llvm-svn: 256631
2015-12-30 08:00:58 +00:00
Daniel Jasper a85c331e8f clang-format: Fix incorrect function type detection.
Before:
  int x = f (&h)();

After:
  int x = f(&h)();

llvm-svn: 256488
2015-12-28 07:44:25 +00:00
Daniel Jasper 362a1bfcff clang-format: Lower penalty for breaking between array subscripts.
Before:
  aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)][bbbbbbbbbbb(
      bbbbbbbbbbbb)]

After:
  aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)]
                           [bbbbbbbbbbb(bbbbbbbbbbbb)]

llvm-svn: 256343
2015-12-23 18:01:43 +00:00
Daniel Jasper 95516cd380 clang-format: Fix incorrect pointer detection.
Before:
  return * this += 1;

After:
  return *this += 1;

llvm-svn: 256342
2015-12-23 18:01:29 +00:00
Zachary Turner 448592eeac Support AlwaysBreakAfterReturnType
This changes the behavior of AlwaysBreakAfterDeclarationReturnType
so that it supports breaking after declarations, definitions, or
both.

Differential Revision: http://reviews.llvm.org/D10370
Reviewed By: Daniel Jasper

llvm-svn: 256046
2015-12-18 22:20:15 +00:00
Daniel Jasper f901a57cda clang-format: Make wrapping after "./->" cheaper, even if the element
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
2015-12-07 19:50:48 +00:00
Daniel Jasper 8e8b4fb678 clang-format: Re-add code path deleted in r253873 and add missing test.
llvm-svn: 253900
2015-11-23 19:11:45 +00:00
Daniel Jasper 569369ce28 clang-format: Signficantly refactor the cast detection.
No functional changes intended.

llvm-svn: 253873
2015-11-23 15:55:55 +00:00
Daniel Jasper 9bb3001d53 clang-format: Fix incorrect cast detection.
Before:
  bool b = f(g<int>)&&c;

After:
  bool b = f(g<int>) && c;

llvm-svn: 253872
2015-11-23 15:55:50 +00:00
Daniel Jasper 71e574543f clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"
work properly.

llvm-svn: 253674
2015-11-20 16:44:28 +00:00
Daniel Jasper f95b1f4546 clang-format: [JS] Properly add a space after "in" in for loops.
llvm-svn: 253672
2015-11-20 16:18:42 +00:00
Daniel Jasper 7fa524b4b8 clang-format: Don't use incorrect space in macro calls with operators.
Before:
  MACRO(> );

After:
  MACRO(>);

Not overly important, but easy and good for symmetry reasons :-).

llvm-svn: 253669
2015-11-20 15:26:50 +00:00
Daniel Jasper d8d9839ae6 clang-format: [Proto] Support extending message.
Before:
  extend.foo.Bar {
  }

After:
  extend .foo.Bar {
  }

llvm-svn: 253667
2015-11-20 14:32:54 +00:00
Richard Smith e301ba2b48 Add support for GCC's '__auto_type' extension, per the GCC manual:
https://gcc.gnu.org/onlinedocs/gcc/Typeof.html

Differences from the GCC extension:
 * __auto_type is also permitted in C++ (but only in places where
   it could appear in C), allowing its use in headers that might
   be shared across C and C++, or used from C++98
 * __auto_type can be combined with a declarator, as with C++ auto
   (for instance, "__auto_type *p")
 * multiple variables can be declared in a single __auto_type
   declaration, with the C++ semantics (the deduced type must be
   the same in each case)

This patch also adds a missing restriction on applying typeof to
a bit-field, which GCC has historically rejected in C (due to
lack of clarity as to whether the operand should be promoted).
The same restriction also applies to __auto_type in C (in both
GCC and Clang).

This also fixes PR25449.

Patch by Nicholas Allegra!

llvm-svn: 252690
2015-11-11 02:02:15 +00:00
Daniel Jasper b488a74f99 clang-format: [JS] Add goog.setTestOnly to the list of stuff that
is import-statement-like and shouldn't be wrapped.

llvm-svn: 251643
2015-10-29 19:05:20 +00:00
Daniel Jasper 6501f7e8fd clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.
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
2015-10-27 12:38:37 +00:00
Daniel Jasper 74331d4c43 clang-format: Fix false positive in cast detection.
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
2015-10-26 12:08:47 +00:00
Nico Weber 2cd92f1cc7 clang-format/java: Break after annotations on fields in Chromium style.
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
2015-10-15 16:03:01 +00:00
Daniel Jasper 4d72449de6 clang-format: Fixed typecast getting put on a separate line from the
key in Obj-C dictionary literals

This fixes: https://llvm.org/PR22647

Patch by Kent Sutherland. Thank you.

llvm-svn: 250010
2015-10-12 03:19:07 +00:00
Daniel Jasper 9cb1ac28b9 clang-format: Fixed missing space between Obj-C for/in and a typecast.
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
2015-10-07 15:09:08 +00:00
Daniel Jasper 4bc013e18c clang-format: Understand array reference types.
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
2015-10-07 01:41:22 +00:00
Daniel Jasper 0ea4d799e3 clang-format: Fix false positive in pointer/reference detection.
Before:
  return options != nullptr &&operator==(*options);

After:
  return options != nullptr && operator==(*options);

llvm-svn: 249501
2015-10-07 01:41:14 +00:00
Daniel Jasper c1bc38ed4f clang-format: Add a new brace style "custom" as well as flags to
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
2015-09-29 14:57:55 +00:00
Daniel Jasper ba52fcb7d5 clang-format: [JS] Support pseudo-keywords
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
2015-09-28 14:29:45 +00:00
Daniel Jasper 9f642f7d7a clang-format: [JS] handle let (ES6)
Patch by Martin Probst. Thank you!

llvm-svn: 248713
2015-09-28 14:28:08 +00:00
Nico Weber 4f11349028 clang-format: In Java, `assert` is followed by an expression.
Before: assert a&& b;
Now:    assert a && b;
llvm-svn: 247750
2015-09-15 23:48:17 +00:00
Daniel Jasper af642c6927 clang-format: Add space before member function reference qualifiers.
Before:
  SomeType MemberFunction(const Deleted &)&;

After:
  SomeType MemberFunction(const Deleted &) &;

Seems to be much more common.

llvm-svn: 245934
2015-08-25 13:40:51 +00:00
Daniel Jasper 788ffd71c6 clang-format: Always allow break after leading annotations.
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
2015-08-24 15:10:01 +00:00
Daniel Jasper 5d7f06fa60 clang-format: Make formatting of member function reference qualifiers
more consistent.

Before:
  SomeType MemberFunction(const Deleted &)&&;
  SomeType MemberFunction(const Deleted &) && { ... }

After:
  SomeType MemberFunction(const Deleted &)&&;
  SomeType MemberFunction(const Deleted &)&& { ... }

llvm-svn: 245843
2015-08-24 14:28:08 +00:00
Daniel Jasper 100ffc632a clang-format: Be more conservative about specially indenting blocks in C++.
This is a bit of a step back of what we did in r222531, as there are
some corner cases in C++, where this kind of formatting is really bad.

Example:
Before:
  virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() {
    return true;
  }, aaaaa aaaaaaaaa);

After:
  virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant =
                               [&]() { return true; },
                           aaaaa aaaaaaaaa);

The block formatting logic in JavaScript will probably go some other changes,
too, and we'll potentially be able to make the rules more consistent again. For
now, this seems to be the best approach for C++.

llvm-svn: 245694
2015-08-21 11:44:57 +00:00
Daniel Jasper d788457da5 clang-format: Don't remove space between #elif and parentheses.
Before:
  #elif(AAAA && BBBB)

After:
  #elif (AAAA && BBBB)

llvm-svn: 245043
2015-08-14 12:44:06 +00:00
Daniel Jasper 033181bcd2 clang-format: Inside decltype(), there is an expression.
Before:
  decltype(a* b) F();

After:
  decltype(a * b) F();

llvm-svn: 244891
2015-08-13 13:43:51 +00:00
Daniel Jasper a804d1ec80 clang-format: Make SpaceBeforeParens work with overloaded operators.
Patch by Jon Chesterfield, thank you!

llvm-svn: 244660
2015-08-11 20:32:24 +00:00
Manuel Klimek 9e32199861 Do not force linebreaks when MaxEmptyLinesToKeep is 0.
Previously we would format
 call(

     p);
as
 call(
     p);
with MaxEmptyLinesToKeep == 0.

Now we format it as:
  call(p);

llvm-svn: 243429
2015-07-28 15:50:24 +00:00
Daniel Jasper bcad06640b clang-format: Fix unary operator detection in for loops.
Before:
  for (;; * a = b) {}

After:
  for (;; *a = b) {}

llvm-svn: 242849
2015-07-21 22:51:00 +00:00
Birunthan Mohanathas 525579d41c clang-format: Fix return type breaking with overloaded operator functions
Differential Revision: http://reviews.llvm.org/D11177

llvm-svn: 242316
2015-07-15 19:11:58 +00:00
Birunthan Mohanathas 67d81c8a77 clang-format: Print token type name instead of number in -debug output
Differential Revision: http://reviews.llvm.org/D11125

llvm-svn: 242039
2015-07-13 16:19:34 +00:00
Birunthan Mohanathas 305fa9c2bf clang-format: Add Mozilla brace breaking style
Differential Revision: http://reviews.llvm.org/D10883

llvm-svn: 241986
2015-07-12 03:13:54 +00:00
Daniel Jasper b9a52814bf clang-format: [JS] Assign proper penalties when breaking a type annotation
Before:
  class Test {
    aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa:
                         aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {}
  }

After:
  class Test {
    aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa):
        aaaaaaaaaaaaaaaaaaaaaa {}
  }

llvm-svn: 241908
2015-07-10 13:39:26 +00:00
Daniel Jasper 3bacc4df8e clang-format: Break after "for (" less eagerly.
Before:
  for (
      auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
      aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb;
      ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) {

After:
  for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaa(
           aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
       aaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbbbbbbb;
       ++aaaaaaaaaaaaaaaaaaaaaaaaaaa) {

llvm-svn: 241601
2015-07-07 16:09:39 +00:00
Daniel Jasper b9edcfb018 clang-format: Don't wrap before the ] of a lambda introducer.
Before:
  return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([=
  ](int iiiiiiiiiiii) {
    return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa;
  });

After:
  return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([=](
      int iiiiiiiiiiii) {
    return aaaaaaaaaaaaaaaaaaaaaaa != aaaaaaaaaaaaaaaaaaaaaaa;
  });

llvm-svn: 241583
2015-07-07 13:50:50 +00:00
Daniel Jasper a5fa4d1d7e clang-format: Fix __attribute__ being treated as decl name.
__attribute__ was treated as the name of a function definition, with the
tokens in parentheses being the parameter list. This formats incorrectly
with AlwaysBreakAfterDefinitionReturnType. Fix it by treating
__attribute__ like decltype.

Patch by Strager Neds, thank you.

llvm-svn: 241439
2015-07-06 11:30:34 +00:00
Daniel Jasper 5a3de1d0e1 clang-format: [JS] Allow line breaks after TypeScript type colons.
llvm-svn: 241339
2015-07-03 10:37:23 +00:00
Daniel Jasper 043ac05010 clang-format: [Java/JS] Properly support instanceof and its precedence.
llvm-svn: 241337
2015-07-03 10:12:53 +00:00
Daniel Jasper 3992e2c742 clang-format: Support member function reference qualifiers with
trailing return types.

Before:
  template <typename T>
      auto x() & -> int {}

After:
  template <typename T>
  auto x() & -> int {}

llvm-svn: 241188
2015-07-01 21:02:24 +00:00
Birunthan Mohanathas a0388a8af2 clang-format: Add option to break after definition return type for top-level functions only
Differential Revision: http://reviews.llvm.org/D10774

llvm-svn: 240959
2015-06-29 15:30:42 +00:00
Daniel Jasper 23d3bcfe5b clang-format: [Proto] Don't treat "operator" as keyword.
Before:
  optional string operator= 1;

After:
  optional string operator = 1;

llvm-svn: 240624
2015-06-25 08:38:46 +00:00
Eric Christopher 2c4555ad1b Fix "the the" in comments/documentation/etc.
llvm-svn: 240110
2015-06-19 01:52:53 +00:00
Daniel Marjamaki e59f8d7f1d [clang] Refactoring of conditions so they use isOneOf() instead of multiple is().
llvm-svn: 240008
2015-06-18 10:59:26 +00:00
Daniel Jasper e6fcf7d372 clang-format: clang-format (NFC)
llvm-svn: 239903
2015-06-17 13:08:06 +00:00
Daniel Jasper 9f4ec15270 clang-format: [JS] Don't put top-level typescript enums on a single line.
This makes this consistent with non-typescript enums.

Also shuffle the language-dependent stuff in mustBreakBefore to a
single location.

Patch initiated by Martin Probst.

llvm-svn: 239894
2015-06-17 09:44:07 +00:00
Daniel Jasper e285b8dd2e clang-format: NFC. Add a function to test whether an annotated line
starts with a given sequence of tokens. Only the one-token version is
used yet, but other usages are coming up momentarily.

llvm-svn: 239892
2015-06-17 09:43:56 +00:00
Daniel Jasper 60ba32d453 clang-format: Always add space before lambda-{
Before:
  int c = []() -> int *{ return 2; }();

After:
  int c = []() -> int * { return 2; }();

Based on patch by James Dennett (http://reviews.llvm.org/D10410), thank you!

llvm-svn: 239600
2015-06-12 09:59:16 +00:00
Daniel Jasper 554e49fe84 clang-format: Understand C-style case in case label.
Before:
  case (my_int) ONE:

After:
  case (my_int)ONE:

This fixed llvm.org/PR23760

llvm-svn: 239597
2015-06-12 07:15:33 +00:00
Daniel Jasper 56691b8cb9 clang-format: [JS] Ensure that formatting actually takes place in tests.
And fix formatting issue discovered by that :-).

llvm-svn: 239530
2015-06-11 13:29:20 +00:00
Daniel Jasper 11ca263994 clang-format: [JS] Only special case top level object literal
assignments as enums.

Top level object literals are treated as enums, and their k/v pairs are put on
separate lines:

  X.Y = {
    A: 1,
    B: 2
  };

However assignments within blocks should not be affected:

  function x() {
    y = {a:1, b:2};
  }

This change fixes the second case. Patch by Martin Probst.

llvm-svn: 239462
2015-06-10 09:21:09 +00:00
Daniel Jasper c83d76991c clang-format: [JS] Hotfix for runtime issue with deeply nested JS code.
I have not succeeded in writing a proper test case for this yet and we
also need to solve the underlying fundamental problem of trying too
many combinations with nested blocks (basically this somewhat works
around our Dijkstra algorithm). Preventing this linebreak is good
anyways as usually the penalties never make us choose it (that's why I
can't create a test) and it also looks ugly.

Also cleaned up state comparison code that I discovered while hunting
this down.

llvm-svn: 239398
2015-06-09 11:39:22 +00:00
Daniel Jasper 6f2b88a398 clang-format: More eagerly wrap trailing return types.
Before:
  template <typename T>
  auto aaaaaaaaaaaaaaaaaaaaaa(T t) -> decltype(eaaaaaaaaaaaaaaa<T>(t.a)
                                                   .aaaaaaaa());

After:
  template <typename T>
  auto aaaaaaaaaaaaaaaaaaaaaa(T t)
      -> decltype(eaaaaaaaaaaaaaaa<T>(t.a).aaaaaaaa());

Also add a test case for a difficult template parsing case I stumbled accross.
Needs fixing.

llvm-svn: 239149
2015-06-05 13:18:09 +00:00
Daniel Jasper 3b0f304517 clang-format: [JS] Let fat arrows have 'Assignment' precedence.
This is a more correct representation than using "Equality" introduced
in r238942 which was a quick fix to solve an actual regression.

According to the typescript spec, arrows behave like "low-precedence"
assignments.

Before:
  var a = a.aaaaaaa((a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) &&
                    aaaaaaaaaaaaaaaaaaaaa(bbbbbbb));
After:
  var a = a.aaaaaaa((a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) &&
                              aaaaaaaaaaaaaaaaaaaaa(bbbbbbb));

llvm-svn: 239137
2015-06-05 08:25:37 +00:00
Daniel Jasper 3c306e895e clang-format: [JS] Let fat arrows have 'Equality' precedence.
This fixes a regression in literal formatting:

Before:
  aaaaaaaaaaaaa = {
    aaaaaaaaaaaaaaaaaaaaaaaaaaaa: (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                                   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =>
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
  };

After:
  var aaaaaaaaaaaaaaaaaaaa = {
    aaaaaaaaaaaaaaaaaaaaaaaaaaaa:
        (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =>
                aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
  };

Also apply no-else-after-return policy.

llvm-svn: 238942
2015-06-03 17:08:40 +00:00
Daniel Jasper 9970df1f79 clang-format: [JS] More aggressively keep array literals on one line.
Before:
  var aaaaa: List<SomeThing> = [
    new SomeThingAAAAAAAAAAAA(),
    new SomeThingBBBBBBBBB()
  ];

After:
  var aaaaa: List<SomeThing> =
      [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()];

llvm-svn: 238909
2015-06-03 08:57:36 +00:00
Daniel Jasper 81dbb564a1 clang-format: [JS] Fix bug in type colon detection.
Before, this couldn't be formatted at all:
  class X {
    subs = {
      'b': {
        'c': 1,
      },
    };
  }

llvm-svn: 238907
2015-06-03 08:43:18 +00:00
Daniel Jasper e497beddb5 clang-format: [JS] Always add space after fat arrow.
Before:
  return () =>[];

After:
  return () => [];

llvm-svn: 238875
2015-06-02 22:06:07 +00:00
Daniel Jasper d492b5ec03 clang-format: [JS] Array literal detection fix #4.
llvm-svn: 238873
2015-06-02 21:57:51 +00:00
Daniel Jasper 40432cee93 clang-format: [JS] Array literal detection fix #3.
llvm-svn: 238839
2015-06-02 15:04:29 +00:00
Daniel Jasper 4284e3623c clang-format: [JS] Fix another regression when detecting array literals.
llvm-svn: 238835
2015-06-02 14:20:08 +00:00
Daniel Jasper 5ce80de4de clang-format: [JS] Fix regression of detecting array literals.
llvm-svn: 238832
2015-06-02 13:56:43 +00:00
Daniel Jasper 1699eca119 clang-format: [JS] Making arrow function wrapping more consistent.
Before:
  someFunction(() =>
               {
                 doSomething();  // break
               })
      .doSomethingElse(  // break
          );

After:
  someFunction(() => {
    doSomething();  // break
  })
      .doSomethingElse(  // break
          );

This is still bad, but at least it is consistent with what we do for other
function literals. Added corresponding tests.

llvm-svn: 238736
2015-06-01 09:56:32 +00:00
Daniel Jasper cd8d4ff985 clang-format: [JS] Fix line breaks in computed property names.
Before:
  let foo = {
    [someLongKeyHere]: 1,
    someOtherLongKeyHere: 2, [keyLongEnoughToWrap]: 3,
    lastLongKey: 4
  };

After:
  let foo = {
    [someLongKeyHere]: 1,
    someOtherLongKeyHere: 2,
    [keyLongEnoughToWrap]: 3,
    lastLongKey: 4
  };

llvm-svn: 238671
2015-05-31 08:40:37 +00:00
Daniel Jasper 8c42d445e3 clang-format: [JS] Support ES6 computed property names.
Before:
  var x = {
        [a]: 1,
    b: 2
  };

After:
  var x = {
    [a]: 1,
    b: 2
  };

llvm-svn: 238544
2015-05-29 06:19:49 +00:00
Daniel Jasper f841d3a6c1 clang-format: Lower binding strengths created by the [] created by ObjC
method expressions and array literals. They should not bind stronger
than regular parentheses or the braces of braced lists.

Specific test case in JavaScript:
Before:
  var aaaaa: List<
      SomeThing> = [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()];

After:
  var aaaaa: List<SomeThing> = [
    new SomeThingAAAAAAAAAAAA(),
    new SomeThingBBBBBBBBB()
  ];

llvm-svn: 238400
2015-05-28 07:21:50 +00:00
Daniel Jasper 3273930d9a clang-format: Fix false positive in function annotation detection.
llvm-svn: 238285
2015-05-27 04:55:47 +00:00
Daniel Jasper 0805199185 clang-format: [JS] Support ES6 spread operator.
Specifically, don't add a space before it.

Before:
  someFunction(... a);
  var x = [1, 2, ... a];

After:
  someFunction(...a);
  var x = [1, 2, ...a];

llvm-svn: 238183
2015-05-26 07:18:56 +00:00
Anders Waldenborg b09075a240 clang-format: Add space in function pointers with SpaceBeforeParens=Always
"void (*my_function)(void)" should become "void (*my_function) (void)" when
SpaceBeforeParens is set to 'Always'

Differential Revision: http://reviews.llvm.org/D9835

llvm-svn: 237704
2015-05-19 16:54:26 +00:00
Daniel Jasper 9310166a63 clang-format: Improve *-detection.
Before:
  S << a *(10);

After:
  S << a * (10);

This fixes llvm.org/PR16500.

llvm-svn: 237690
2015-05-19 12:29:27 +00:00
Daniel Jasper d6e09e85f9 clang-format: Improve for-loop formatting.
Before:
  for (SmallVectorImpl<TemplateIdAnnotationn *>::iterator I =
           Container.begin(),
                                                          E = Container.end();
       I != E; ++I)

After:
  for (SmallVectorImpl<TemplateIdAnnotationn *>::iterator
           I = Container.begin(),
           E = Container.end();
       I != E; ++I)

This fixes llvm.org/PR23544.

llvm-svn: 237688
2015-05-19 11:51:39 +00:00
Daniel Jasper fa3f8fbed8 clang-format: Support #include_next
Before:
  #include_next < test.h >

After:
  #include_next <test.h>

This fixes llvm.org/PR23500

llvm-svn: 237686
2015-05-19 11:22:29 +00:00
Daniel Jasper f5e5ee6d69 clang-format: Correctly detect casts to qualified types.
Before:
  ns::E f() { return (ns::E) - 1; }

After:
  ns::E f() { return (ns::E)-1; }

This fixes llvm.org/PR23503.

llvm-svn: 237684
2015-05-19 11:18:39 +00:00
Daniel Jasper ed41f774fc clang-format: Fix regression caused by r237244.
Before:
  [call aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.
          aaaaaaaa];

After:
  [call aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa
          .aaaaaaaa];

This merely papers over the fact that we aren't parsing ObjC method calls
correctly. Also, the indentation is weird.

llvm-svn: 237681
2015-05-19 11:06:33 +00:00
Daniel Jasper 47bbda0939 clang-format: Improve detection of macros annotating functions.
Before:
  ASSERT("aaaaaaaaaaaaaaa")
      << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

After:
  ASSERT("aaaaaaaaaaaaaaa") << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                            << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

Also cleanup implementation a bit and only mark closing parenthesis of
these annotations.

llvm-svn: 237567
2015-05-18 13:47:23 +00:00
Daniel Jasper f090f031bc clang-format: Support function annotations in macros.
Before:
  DEPRECATED("Use NewClass::NewFunction instead.") string
      OldFunction(const string &parameter) {}

After:
  DEPRECATED("Use NewClass::NewFunction instead.")
  string OldFunction(const string &parameter) {}

llvm-svn: 237562
2015-05-18 09:47:22 +00:00
Daniel Jasper 2fd16632bc clang-format: Improve line wrapping around << operators.
Generally, clang-format tries to keep label-value pairs on a single
line for stream operators. However, we should not do that if there is
just a single such pair, as that doesn't help much.

Before:
  llvm::errs() << "aaaaaaaaaaaa: " << aaaaaaa(aaaaaaaaa,
                                              aaaaaaaaa);

After:
  llvm::errs() << "aaaaaaaaaaaa: "
               << aaaaaaa(aaaaaaaaa, aaaaaaaaa);

Also remove old test case that was testing actual behavior any more.

llvm-svn: 237535
2015-05-17 07:27:09 +00:00
Daniel Jasper 3ca283ada3 clang-format: Slightly change format decisions around macro annotations.
Before:
  bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      GUARDED_BY(aaaaaaaaaaaa) = aaaaaaaaaaaaaaaaaaaaaaaaa;

After:
  bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) =
      aaaaaaaaaaaaaaaaaaaaaaaaa;

llvm-svn: 237430
2015-05-15 09:58:11 +00:00
Daniel Jasper cdb58b2e45 clang-format: Add missing space before ObjC selector.
Before:
  [self aaaaa:(1 + 2)bbbbb:3];

After:
  [self aaaaa:(1 + 2) bbbbb:3];

llvm-svn: 237424
2015-05-15 09:05:31 +00:00
Daniel Jasper 3a26a8db5d clang-format: Fix incorrect */& classification.
Before:
  void f() { f(new a(), c *d); }

After:
  void f() { f(new a(), c * d); }

llvm-svn: 237249
2015-05-13 12:54:30 +00:00
Daniel Jasper a7b142603d clang-format: [ObjC] Further improve wrapping of methods calls without inputs.
Before:
  [aaaaaaaaaaaaaaaaaaaaaaa
      .aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa] aaaaaaaaaaaaaaaaaaaaaa];

After:
  [aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa]
      aaaaaaaaaaaaaaaaaaaaaa];

llvm-svn: 237244
2015-05-13 10:23:03 +00:00
Daniel Jasper 0ad2814c89 clang-format: Prefer formatting local lambdas like functions.
Before:
  auto my_lambda =
      [](const string &some_parameter) { return some_parameter.size(); };

After:
  auto my_lambda = [](const string &some_parameter) {
    return some_parameter.size();
  };

llvm-svn: 237235
2015-05-13 08:47:16 +00:00
Daniel Jasper 99b5a4648c clang-format: Fix */& detection for lambdas in macros.
Before:
  #define MACRO() [](A * a) { return 1; }

After:
  #define MACRO() [](A *a) { return 1; }

llvm-svn: 237109
2015-05-12 10:20:32 +00:00
Daniel Jasper 015c7a91f1 clang-format: Support aligning ObjC string literals.
Before:
  NSString s = @"aaaa"
      @"bbbb";

After:
  NSString s = @"aaaa"
               @"bbbb";

llvm-svn: 237000
2015-05-11 15:15:48 +00:00
Daniel Jasper c6366077ed clang-format: Preserve line break before } in __asm { ... }.
Some compilers ignore everything after a semicolon in such inline asm
blocks and thus, the closing brace must not be moved to the previous
line.

llvm-svn: 236946
2015-05-10 08:42:04 +00:00
Daniel Jasper 7325aee167 clang-format: [JS] Avoid bad line-warp around "function".
Before:
  someLooooooooongFunction(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function(
                                              aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {
        // code
      });

After:
  someLooooooooongFunction(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {
        // code
      });

llvm-svn: 236813
2015-05-08 08:38:52 +00:00
Daniel Jasper 9c95013e8f clang-format: Improve r236597, Properly indent method calls without inputs.
Before:
  [aaaaaaaaaaaa(aaaaaa)
          aaaaaaaaaaaaaaaaaaaa];

After:
  [aaaaaaaaaaaa(aaaaaa)
      aaaaaaaaaaaaaaaaaaaa];

llvm-svn: 236730
2015-05-07 14:19:59 +00:00
Daniel Jasper 1fe0d5ca59 clang-format: Merge labels and subsequent semicolons.
E.g.:

  default:;

This can be used to get around restrictions as to what can follow a
label. It fixes llvm.org/PR19648.

llvm-svn: 236604
2015-05-06 15:19:47 +00:00
Daniel Jasper 112b50e6b6 clang-format: Allow ternary expressions inside template parameters if
the template parameters aren't inside an expression context.

This fixes llvm.org/PR23270.

llvm-svn: 236603
2015-05-06 14:53:50 +00:00
Daniel Jasper e92bf6f141 clang-format: Consider operator precedence as penalty when breaking
before operators.

This fixes llvm.org/23382.

llvm-svn: 236602
2015-05-06 14:23:38 +00:00
Daniel Jasper 62c78f5474 clang-format: Prevent assertion discovered by fuzzer.
llvm-svn: 236578
2015-05-06 08:58:57 +00:00
Daniel Jasper 4d9ec17f1e clang-format: Prevent exponential runtime in token annotator.
llvm-svn: 236577
2015-05-06 08:38:24 +00:00
Daniel Jasper 9326f91922 clang-format: [JS] support optional methods.
Optional methods use ? tokens like this:

  interface X { y?(): z; }

It seems easiest to detect and disambiguate these from ternary
expressions by checking if the code is in a declaration context. Turns
out that that didn't quite work properly for interfaces in Java and JS,
and for JS file root contexts.

Patch by Martin Probst, thank you.

llvm-svn: 236488
2015-05-05 08:40:32 +00:00
Daniel Jasper 66cb8c503f clang-format: NFC: Delete FormatToken::IsForEachMacro. Use a TokenType instead.
llvm-svn: 236415
2015-05-04 09:22:29 +00:00
Daniel Jasper de7ca75ca0 clang-format: Force aligning different brackets relative to each other.
Before:
  void SomeFunction(vector< // break
      int> v);

After:
  void SomeFunction(vector< // break
                        int> v);

llvm-svn: 236412
2015-05-04 07:39:00 +00:00
Daniel Jasper d22190632c clang-format: [JS] Fix templated parameter default values.
Parameters can have templated types and default values (= ...), which is
another location in which a template closer should be followed by
whitespace.

Patch by Martin Probst, thank you.

llvm-svn: 236382
2015-05-02 07:54:58 +00:00
Daniel Jasper 0faa9136fa clang-format: Properly detect variable declarations with ObjC.
Before:
  LoooooooooooooooooooooooooooooooooooooooongType
  LoooooooooooooooooooooooooooooooooooooongVariable([A a]);

After:
  LoooooooooooooooooooooooooooooooooooooooongType
      LoooooooooooooooooooooooooooooooooooooongVariable([A a]);

llvm-svn: 235599
2015-04-23 13:58:40 +00:00
Daniel Jasper caf84fe21e clang-format: Allow splitting "= default" and "= delete".
Otherwise, this can violate the column limit.

llvm-svn: 235592
2015-04-23 12:59:09 +00:00
Daniel Jasper 532a031422 clang-format: Don't add unwanted space when creating new arrays.
Before:
  char** newargv = new char* [argc];

After:
  char** newargv = new char*[argc];

llvm-svn: 235583
2015-04-23 10:23:53 +00:00
Daniel Jasper 1b998815a0 clang-format: [Proto] Don't linewrap top-level options.
They are very similar to import statements.

llvm-svn: 235582
2015-04-23 09:54:10 +00:00
Daniel Jasper ee4a8a140a clang-format: Fix for #pragma option formatting.
Adapted patch from Sergey Razmetov. Thank you.

llvm-svn: 235492
2015-04-22 09:45:42 +00:00
Daniel Jasper e4ab49e8d3 clang-format: Fix incorrect multi-var declstmt detection.
This is now obvious as the pointer alignment behavior was changed.

Before (even with pointer alignment "Left"):
  MACRO Constructor(const int &i) : a(a), b(b) {}

After:
  MACRO Constructor(const int& i) : a(a), b(b) {}

llvm-svn: 235301
2015-04-20 12:54:29 +00:00
Daniel Jasper 20e15563ff clang-format: Undo r214508. It was essentially always removing the
space where we already had the flag ObjCSpaceBeforeProtocolList to
control it. I don't know what I was thinking.

llvm-svn: 235076
2015-04-16 07:02:19 +00:00
Daniel Jasper 2b1865c251 clang-format: Determine "in" as a keyword in ObjC for loops more precisely
Before:
  for (int i = 0; i < in [a]; ++i) ..

After:
  for (int i = 0; i < in[a]; ++i) ..

Also do some related cleanups.

llvm-svn: 234980
2015-04-15 07:26:18 +00:00
Daniel Jasper d9309774a6 clang-format: [JS] Support index signature types.
Patch by Martin Probst.

llvm-svn: 234754
2015-04-13 15:03:30 +00:00
Daniel Jasper a74f5072e1 clang-format: [JS] support optionality markers in JS types.
Patch by Martin Probst. Thank you.

llvm-svn: 234753
2015-04-13 15:01:40 +00:00
Daniel Jasper 739ec534d2 clang-format: [JS] Understand object literals with only methods.
Before:
  let theObject = {someMethodName() {
    doTheThing();
    doTheOtherThing();
  },
                   someOtherMethodName() {
                     doSomething();
                     doSomethingElse();
                   }};

After:
  let theObject = {
    someMethodName() {
      doTheThing();
      doTheOtherThing();
    },
    someOtherMethodName() {
      doSomething();
      doSomethingElse();
    }
  };

llvm-svn: 234091
2015-04-04 07:56:55 +00:00
Daniel Jasper 05cd92922d clang-format: Force line break in trailing calls after multline exprs.
Before:
  aaaaaaaa(aaaaaaaaaa,
           bbbbbbbbbb).a();

After:
  aaaaaaaa(aaaaaaaaaa,
           bbbbbbbbbb)
      .a();

llvm-svn: 233304
2015-03-26 18:46:28 +00:00
Daniel Jasper 414c9c6fb0 clang-format: Fix another bug in wrapping around "*".
Before:
  void aaaaa(
      aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} // even violation the column limit

After:
  void aaaaa(aaaaaaaaaaaa*
                 aaaaaaaaaaaaaa) {}

llvm-svn: 232717
2015-03-19 09:40:16 +00:00
Daniel Jasper 1130981907 clang-format: Fix bad wrapping after "*" introduced in r232044.
Before:
  void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa*
                                              const aaaaaaaaaaaa) {}

After:
  void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}

llvm-svn: 232635
2015-03-18 14:20:13 +00:00
Daniel Jasper bc46b939e6 clang-format: [JS] support cast syntax and type arguments.
Casts in TS syntax (foo = <type>bar;) should not be followed by
whitespace.

Patch by Martin Probst. Thank you.

llvm-svn: 232321
2015-03-15 13:59:51 +00:00
Daniel Jasper 60948b12bb clang-format: [JS] more precisely detect enums.
The current enum detection is overly aggressive. As NestingLevel only
applies per line (?) it classifies many if not most object literals as
enum declarations and adds superfluous line breaks into them. This
change narrows the heuristic by requiring an assignment just before the
open brace and requiring the line to start with an identifier.

Patch by Martin Probst. Thank you.

llvm-svn: 232320
2015-03-15 13:55:54 +00:00
Daniel Jasper b754a747be clang-format: When putting */& next to types, also wrap before them.
Before:
  LoooooooooooongType *
      loooooooooooongVariable;

After:
  LoooooooooooongType
      *loooooooooooongVariable;

llvm-svn: 232044
2015-03-12 15:04:53 +00:00
Daniel Jasper dc4f725673 clang-format: Fix incorrect && recognition.
Before:
  if (a &&(b = c)) ..

After:
  if (a && (b = c)) ..

llvm-svn: 231920
2015-03-11 12:59:49 +00:00
Benjamin Kramer 28b45ce151 Make constant static variables const so they can go into a read-only section
NFC.

llvm-svn: 231597
2015-03-08 16:06:46 +00:00
Daniel Jasper e662316994 clang-format: Prefer wrapping a lambda's body over the lambda's return type.
Before:
  aaaaaaaaaaaaaaaaaaaaaa(
      [](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa)
          -> aaaaaaaaaaaaaaaaaaaaa { return aaaaaaaaaaaaaaaaa; });

After:
  aaaaaaaaaaaaaaaaaaaaaa(
      [](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaaaaaaa {
        return aaaaaaaaaaaaaaaaa;
      });

llvm-svn: 230942
2015-03-02 10:35:13 +00:00
Daniel Jasper bea1ab46d9 clang-format: Always align */& in multi-var DeclStmts.
Seems like the most consistent thing to do and in multi-var DeclStmts,
it is especially important to point out that the */& bind to the
identifier.

llvm-svn: 230903
2015-03-01 18:55:26 +00:00
Daniel Jasper 308062bd0d clang-format: Make trailing commas in array inits force one per line.
Before:
  NSArray *array = @[ @"a", @"a", ];

After:
  NSArray *array = @[
    @"a",
    @"a",
  ];

llvm-svn: 230741
2015-02-27 08:41:05 +00:00
Daniel Jasper beaa322c36 clang-format: Fix space of arrays of pointers to templated types.
Before:
  vector<int>(*foo_)[6];

After:
  vector<int> (*foo_)[6];

llvm-svn: 230625
2015-02-26 11:30:50 +00:00
Daniel Jasper a42de763ac clang-format: Allow breaking after "else if(" as a last resort.
This isn't generally nice, but better than violating the column limit.

llvm-svn: 230620
2015-02-26 09:49:08 +00:00
Daniel Jasper 1c22048834 clang-format: Fix spacing for function with ref-qualification ..
.. when using SpacesInCStyleCastParentheses != SpacesInParentheses.

Before:
  FormatStyle Spaces = getLLVMStyle();
  Deleted &operator=(const Deleted &)& = default;

  Spaces.SpacesInParentheses = true;
  Deleted(const Deleted &)& = default;

  Spaces.SpacesInCStyleCastParentheses = true;
  Spaces.SpacesInParentheses= false;
  Deleted( const Deleted & )& = default;

After:
  FormatStyle Spaces = getLLVMStyle();
  Deleted &operator=(const Deleted &)& = default;;

  Spaces.SpacesInParentheses= true;
  Deleted( const Deleted & )& = default;

  Spaces.SpacesInCStyleCastParentheses = true;
  Spaces.SpacesInParentheses= false;
  Deleted(const Deleted &)& = default;

Patch by Jean-Philippe Dufraigne. Thank you!

llvm-svn: 230473
2015-02-25 10:30:06 +00:00
Daniel Jasper fca735cd58 clang-format: [js] Support ES6 module exports.
Patch by Martin Probst, thank you!

llvm-svn: 229865
2015-02-19 16:14:18 +00:00
Daniel Jasper 354aa51587 clang-format: [js] Support ES6 module imports.
Patch by Martin Probst.

llvm-svn: 229863
2015-02-19 16:07:32 +00:00
Jacques Pienaar fc27511223 clang-format: Space and triple angle braces.
Committing patch http://reviews.llvm.org/D6800.

llvm-svn: 229783
2015-02-18 23:48:37 +00:00
Daniel Jasper 3c42dba2dc clang-format: [JS] support AtScript style annotations for JS.
Based on Java annotation support and style.

Patch by Martin Probst.

llvm-svn: 229703
2015-02-18 17:17:15 +00:00
Daniel Jasper b10bdff337 clang-format: [JS] Support type annotations.
This patch adds support for type annotations that follow TypeScript's,
Flow's, and AtScript's syntax style.

Patch by Martin Probst, thank you.
Review: http://reviews.llvm.org/D7721

llvm-svn: 229700
2015-02-18 17:09:53 +00:00
Daniel Jasper 699631298e clang-format: Don't force a break after "endl" if everything fits on one line.
llvm-svn: 229486
2015-02-17 10:05:15 +00:00
Nico Weber fac2371be3 clang-format: Add support for SEH __try / __except / __finally blocks.
This lets clang-format format

    __try {
    } __except(0) {
    }

and

    __try {
    } __finally {
    }

correctly. __try and __finally are keywords if `LangOpts.MicrosoftExt` is set,
so this turns this on.  This also enables a few other keywords, but it
shouldn't overly perturb regular clang-format operation.  __except is a
context-sensitive keyword, so `AdditionalKeywords` needs to be passed around to
a few more places.

Fixes PR22321.

llvm-svn: 228148
2015-02-04 15:26:27 +00:00
Daniel Jasper 7509216a41 clang-format: Fix incorrect classification of "*".
Before:
  *a = b *c;

After:
  *a = b * c;

llvm-svn: 226923
2015-01-23 19:04:49 +00:00
Daniel Jasper d1debfc2bb clang-format: Fix bad memory access.
llvm-svn: 226680
2015-01-21 18:04:02 +00:00
Daniel Jasper 9b79efb51f clang-format: Fix crasher on weird comments.
Crashing input:
  /\
  / comment

llvm-svn: 226454
2015-01-19 11:49:32 +00:00