0e61784ae5 
								
							 
						 
						
							
							
								
								clang-format: Add special case to reduce indentaiton in streams.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-16 12:26:54 +00:00  
				
					
						
							
							
								 
						
							
								64a42b8dd2 
								
							 
						 
						
							
							
								
								Fix assertion when breaking string literals with tab characters.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-15 14:52:43 +00:00  
				
					
						
							
							
								 
						
							
								20fd3c6ff7 
								
							 
						 
						
							
							
								
								clang-format: Basic support for C++1y.  
							
							... 
							
							
							
							Before:
  int bi{1 '000' 000};
After:
  int bi{1'000'000};
This fixes llvm.org/PR19342.
llvm-svn: 206263 
							
						 
						
							2014-04-15 08:49:21 +00:00  
				
					
						
							
							
								 
						
							
								866468ae4d 
								
							 
						 
						
							
							
								
								clang-format: Fix regression caused by r206165.  
							
							... 
							
							
							
							llvm-svn: 206173 
							
						 
						
							2014-04-14 13:15:29 +00:00  
				
					
						
							
							
								 
						
							
								72ab43b28b 
								
							 
						 
						
							
							
								
								clang-format: Fix incorrect &&-detection in macros.  
							
							... 
							
							
							
							Before:
  #define A(a, b) (a &&b)
After:
  #define A(a, b) (a && b)
This fixes llvm.org/PR19343.
llvm-svn: 206165 
							
						 
						
							2014-04-14 12:50:02 +00:00  
				
					
						
							
							
								 
						
							
								db8804b32b 
								
							 
						 
						
							
							
								
								clang-format: Improve array literal formatting fix in r206161.  
							
							... 
							
							
							
							Instead of choosing based on the number of elements, simply respect the
user's choice of where to wrap array literals.
llvm-svn: 206162 
							
						 
						
							2014-04-14 12:11:07 +00:00  
				
					
						
							
							
								 
						
							
								af4fee2636 
								
							 
						 
						
							
							
								
								clang-format: With ColumnLimit=0, keep short array literals on a line.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-14 12:05:05 +00:00  
				
					
						
							
							
								 
						
							
								c0d606a584 
								
							 
						 
						
							
							
								
								clang-format: Don't allow hanging indentation for operators on new lines  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-14 11:08:45 +00:00  
				
					
						
							
							
								 
						
							
								68b03049e0 
								
							 
						 
						
							
							
								
								Format code around VCS conflict markers.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-14 09:14:11 +00:00  
				
					
						
							
							
								 
						
							
								35ec2b244a 
								
							 
						 
						
							
							
								
								clang-format: Improve formatting of annotated variables.  
							
							... 
							
							
							
							Before:
  bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
      aaaaaaaaaaaa) = aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
After:
  bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(aaaaaaaaaaaa) =
      aaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
llvm-svn: 206155 
							
						 
						
							2014-04-14 08:15:20 +00:00  
				
					
						
							
							
								 
						
							
								f9fc215f82 
								
							 
						 
						
							
							
								
								clang-format: Treat a trailing comment like a trailing comma in braced lists.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-09 13:18:49 +00:00  
				
					
						
							
							
								 
						
							
								21397a3232 
								
							 
						 
						
							
							
								
								clang-format: Fix bug where clang-format would break the code.  
							
							... 
							
							
							
							Before, it would turn:
  SomeFunction([]() { // Cool function..
    return 43;
  });
Into this:
  SomeFunction([]() { // Cool function.. return 43; });
llvm-svn: 205849 
							
						 
						
							2014-04-09 12:21:48 +00:00  
				
					
						
							
							
								 
						
							
								3ae6f5a47b 
								
							 
						 
						
							
							
								
								clang-format: Improve format of calls with several lambdas.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-09 12:08:39 +00:00  
				
					
						
							
							
								 
						
							
								f9a0906b98 
								
							 
						 
						
							
							
								
								clang-format: Allow breaking between trailing annotations in more cases.  
							
							... 
							
							
							
							Before:
  void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(
      aaaaaaaaaaaaaaa);
After:
  void aaaaaaaaaaaaaa(aaaaaaaa aaa) override
      AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa);
llvm-svn: 205846 
							
						 
						
							2014-04-09 10:29:11 +00:00  
				
					
						
							
							
								 
						
							
								b48d3afcd5 
								
							 
						 
						
							
							
								
								clang-format: Keep more trailing annotations on the same line.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-09 10:01:49 +00:00  
				
					
						
							
							
								 
						
							
								b175d57edc 
								
							 
						 
						
							
							
								
								clang-format: Recognize lists ending in trailing commas correctly.  
							
							... 
							
							
							
							Previously, this did not look through trailing comments leading to a few
formatting oddities.
llvm-svn: 205843 
							
						 
						
							2014-04-09 09:53:23 +00:00  
				
					
						
							
							
								 
						
							
								b77105d2ce 
								
							 
						 
						
							
							
								
								clang-format: Fix incorrect multi-block-parameter computation.  
							
							... 
							
							
							
							llvm-svn: 205763 
							
						 
						
							2014-04-08 14:04:31 +00:00  
				
					
						
							
							
								 
						
							
								139d4a3875 
								
							 
						 
						
							
							
								
								clang-format: Correctly understand arrays of pointers.  
							
							... 
							
							
							
							Before:
  A<int * []> a;
After:
  A<int *[]> a;
This fixes llvm.org/PR19360.
llvm-svn: 205761 
							
						 
						
							2014-04-08 13:07:41 +00:00  
				
					
						
							
							
								 
						
							
								d74cf40386 
								
							 
						 
						
							
							
								
								clang-format: Extend AllowShortFunctions.. to only merge inline functions.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-08 12:46:38 +00:00  
				
					
						
							
							
								 
						
							
								922349cdba 
								
							 
						 
						
							
							
								
								clang-format: Don't merge simple blocks in case statements.  
							
							... 
							
							
							
							Before:
  switch (a) {
  case 1: { return 'a'; }
  }
After:
  switch (a) {
  case 1: {
    return 'a';
  }
  }
llvm-svn: 205611 
							
						 
						
							2014-04-04 06:46:23 +00:00  
				
					
						
							
							
								 
						
							
								5c33265c9e 
								
							 
						 
						
							
							
								
								clang-format: Prefer an additional line-break over hanging indent.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-04-03 12:00:33 +00:00  
				
					
						
							
							
								 
						
							
								cc7bf7fda1 
								
							 
						 
						
							
							
								
								clang-format: Understand that "auto" is a type.  
							
							... 
							
							
							
							Before:
  MACRO(auto * a);
After:
  MACRO(auto *a);
llvm-svn: 205517 
							
						 
						
							2014-04-03 09:00:49 +00:00  
				
					
						
							
							
								 
						
							
								2b9036d54d 
								
							 
						 
						
							
							
								
								Fixing the MSVC 2012 build bot, which cannot do initializer lists yet. Amends r205307.  
							
							... 
							
							
							
							llvm-svn: 205325 
							
						 
						
							2014-04-01 16:30:35 +00:00  
				
					
						
							
							
								 
						
							
								e1e4319ab7 
								
							 
						 
						
							
							
								
								clang-format: Support configurable list of foreach-macros.  
							
							... 
							
							
							
							This fixes llvm.org/PR17242.
Patch by Brian Green, thank you!
llvm-svn: 205307 
							
						 
						
							2014-04-01 12:55:11 +00:00  
				
					
						
							
							
								 
						
							
								03b1bc7a2a 
								
							 
						 
						
							
							
								
								clang-format: Fix aligning of comments and escaped newlines in macros.  
							
							... 
							
							
							
							Before:
  #define A      \
    int i;   /*a*/ \
    int jjj; /*b*/
After:
  #define A        \
    int i;   /*a*/ \
    int jjj; /*b*/
llvm-svn: 205011 
							
						 
						
							2014-03-28 15:06:01 +00:00  
				
					
						
							
							
								 
						
							
								395193c7a0 
								
							 
						 
						
							
							
								
								clang-format: Recognize more ObjC blocks with parameters/return type.  
							
							... 
							
							
							
							llvm-svn: 204990 
							
						 
						
							2014-03-28 07:48:59 +00:00  
				
					
						
							
							
								 
						
							
								1f9d80ac66 
								
							 
						 
						
							
							
								
								Improve handling of bool expressions in template arguments.  
							
							... 
							
							
							
							Now correctly formats:
  foo<true && false>();
llvm-svn: 204950 
							
						 
						
							2014-03-27 19:00:52 +00:00  
				
					
						
							
							
								 
						
							
								5d2587daa2 
								
							 
						 
						
							
							
								
								clang-format: Avoid line-breaks that increase the current column.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-03-27 16:14:13 +00:00  
				
					
						
							
							
								 
						
							
								f81e5c0e50 
								
							 
						 
						
							
							
								
								Fix bool expression special case.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-03-27 11:17:36 +00:00  
				
					
						
							
							
								 
						
							
								c13ee34378 
								
							 
						 
						
							
							
								
								clang-format: Correctly identify ObjC Block with return type.  
							
							... 
							
							
							
							llvm-svn: 204905 
							
						 
						
							2014-03-27 09:43:54 +00:00  
				
					
						
							
							
								 
						
							
								a65e887587 
								
							 
						 
						
							
							
								
								clang-format: Fix incorrect &/* detection.  
							
							... 
							
							
							
							Before:
  STATIC_ASSERT((a &b) == 0);
After:
  STATIC_ASSERT((a & b) == 0);
llvm-svn: 204709 
							
						 
						
							2014-03-25 10:52:45 +00:00  
				
					
						
							
							
								 
						
							
								a26fc5c9db 
								
							 
						 
						
							
							
								
								clang-format: Add flag for removing empty lines at the start of blocks.  
							
							... 
							
							
							
							This unbreaks polly-formatting-tests and we can make a decision for
LLVM style independently.
llvm-svn: 204467 
							
						 
						
							2014-03-21 13:43:14 +00:00  
				
					
						
							
							
								 
						
							
								01b35482e5 
								
							 
						 
						
							
							
								
								clang-format: Don't remove empty lines at the start of namespaces.  
							
							... 
							
							
							
							llvm-svn: 204462 
							
						 
						
							2014-03-21 13:03:33 +00:00  
				
					
						
							
							
								 
						
							
								11164bdaf5 
								
							 
						 
						
							
							
								
								clang-format: Remove empty lines at the beginning of blocks.  
							
							... 
							
							
							
							They very rarely aid readability.
Formatting:
  void f() {
    if (a) {
      f();
    }
  }
Now leads to:
  void f() {
    if (a) {
      f();
    }
  }
llvm-svn: 204460 
							
						 
						
							2014-03-21 12:58:53 +00:00  
				
					
						
							
							
								 
						
							
								a125d53a7b 
								
							 
						 
						
							
							
								
								clang-format: Let a trailing comma in braced lists enforce linebreaks.  
							
							... 
							
							
							
							Before:
  vector<int> x{1, 2, 3, 4, };
After:
  vector<int> x{
      1, 2, 3, 4,
  };
This fixes llvm.org/PR18519.
llvm-svn: 204458 
							
						 
						
							2014-03-21 12:38:57 +00:00  
				
					
						
							
							
								 
						
							
								28df0a356e 
								
							 
						 
						
							
							
								
								clang-format: Fix for r204456.  
							
							... 
							
							
							
							llvm-svn: 204457 
							
						 
						
							2014-03-21 12:15:40 +00:00  
				
					
						
							
							
								 
						
							
								14e58e5290 
								
							 
						 
						
							
							
								
								clang-format: Preserve meaning of trailing comments on parameters.  
							
							... 
							
							
							
							Formatting:
  SomeFunction(a,
            b, // comment
            c);
Before:
  SomeFunction(a, b, // comment
               c);
After:
  SomeFunction(a,
               b, // comment
               c);
llvm-svn: 204456 
							
						 
						
							2014-03-21 11:58:45 +00:00  
				
					
						
							
							
								 
						
							
								ce08126733 
								
							 
						 
						
							
							
								
								clang-format: Detect function-like macros only when upper case is used.  
							
							... 
							
							
							
							Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D3110 
llvm-svn: 204156 
							
						 
						
							2014-03-18 14:35:20 +00:00  
				
					
						
							
							
								 
						
							
								819788da83 
								
							 
						 
						
							
							
								
								Fix crasher bug.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-03-18 11:22:45 +00:00  
				
					
						
							
							
								 
						
							
								1fd6f1f8d6 
								
							 
						 
						
							
							
								
								clang-format: Indent from dict literal labels.  
							
							... 
							
							
							
							Before:
  @{
    NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
    regularFont,
  };
After:
  @{
    NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
        regularFont,
  };
llvm-svn: 204041 
							
						 
						
							2014-03-17 14:32:47 +00:00  
				
					
						
							
							
								 
						
							
								ac7e34e778 
								
							 
						 
						
							
							
								
								clang-format: Prevent ObjC code from confusing the braced-init detection  
							
							... 
							
							
							
							This was leading to bad formatting, e.g.:
Before:
  f(^{
      @autoreleasepool {
        if (a) {
          g();
  }
  }
  });
After:
  f(^{
      @autoreleasepool {
        if (a) {
          g();
        }
      }
  });
llvm-svn: 203777 
							
						 
						
							2014-03-13 10:11:17 +00:00  
				
					
						
							
							
								 
						
							
								da353cd5f1 
								
							 
						 
						
							
							
								
								clang-format: Fix crasher.  
							
							... 
							
							
							
							Caused by unknown tokens (e.g. "\n") not properly updating the state.
Example:
  const char* c = STRINGIFY(
  \na : b);
llvm-svn: 203645 
							
						 
						
							2014-03-12 08:24:47 +00:00  
				
					
						
							
							
								 
						
							
								8f59ae537c 
								
							 
						 
						
							
							
								
								clang-format: Avoid unnecessary break before lambda return type.  
							
							... 
							
							
							
							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 
							
						 
						
							2014-03-11 11:03:26 +00:00  
				
					
						
							
							
								 
						
							
								a58dd5db29 
								
							 
						 
						
							
							
								
								clang-format: Fix another false positive in the lambda detection.  
							
							... 
							
							
							
							Before:
  int i = (*b)[a] -> f();
After:
  int i = (*b)[a]->f();
llvm-svn: 203557 
							
						 
						
							2014-03-11 10:03:33 +00:00  
				
					
						
							
							
								 
						
							
								d3c7ab975f 
								
							 
						 
						
							
							
								
								clang-format: Fix incorrect lambda recognition exposed by r203452.  
							
							... 
							
							
							
							Before:
  int i = a[a][a] -> f();
After:
  int i = a[a][a]->f();
llvm-svn: 203556 
							
						 
						
							2014-03-11 09:59:36 +00:00  
				
					
						
							
							
								 
						
							
								c580af96fa 
								
							 
						 
						
							
							
								
								clang-format: Detect weird macro lambda usage.  
							
							... 
							
							
							
							Before:
  void f() {
    MACRO((const AA & a) { return 1; });
  }
After:
  void f() {
    MACRO((const AA &a) { return 1; });
  }
llvm-svn: 203551 
							
						 
						
							2014-03-11 09:29:46 +00:00  
				
					
						
							
							
								 
						
							
								84a12e18d3 
								
							 
						 
						
							
							
								
								clang-format: Add spaces between lambdas and comments.  
							
							... 
							
							
							
							Before:
  void f() {
    bar([]() {}// Does not respect SpacesBeforeTrailingComments
        );
  }
After:
  void f() {
    bar([]() {} // Does not respect SpacesBeforeTrailingComments
        );
  }
This fixes llvm.org/PR19017.
llvm-svn: 203466 
							
						 
						
							2014-03-10 15:06:25 +00:00  
				
					
						
							
							
								 
						
							
								4504f93901 
								
							 
						 
						
							
							
								
								Preserve hanging indent when breaking line comments.  
							
							... 
							
							
							
							Summary:
If we need to break the second line here:
// something: aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa aaaaa aaaaaa aaaaa aaaaa aaaaa
with the patch it will be turned to
// something: aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa
instead of
// something: aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa aaaaa aaaaaa aaaaa aaaaa
// aaaaa
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2988 
llvm-svn: 203458 
							
						 
						
							2014-03-10 13:14:56 +00:00  
				
					
						
							
							
								 
						
							
								81a20787db 
								
							 
						 
						
							
							
								
								clang-format: Add spaces around trailing/lambda return types.  
							
							... 
							
							
							
							Before:
  int c = []()->int { return 2; }();
After:
  int c = []() -> int { return 2; }();
llvm-svn: 203452 
							
						 
						
							2014-03-10 10:02:02 +00:00  
				
					
						
							
							
								 
						
							
								86b2dfdc3b 
								
							 
						 
						
							
							
								
								Fix operator<< recognition (PR19064).  
							
							... 
							
							
							
							llvm-svn: 203123 
							
						 
						
							2014-03-06 15:13:08 +00:00