Commit Graph

1324 Commits

Author SHA1 Message Date
Daniel Jasper 79dffb4128 clang-format: Be slightly more aggressive on single-line functions.
So that JS functions can also be merged into a single line.

Before:
  var func = function() {
    return 1;
  };

After:
  var func = function() { return 1; };

llvm-svn: 208176
2014-05-07 09:48:30 +00:00
Daniel Jasper 8acf822b6f clang-format: Fix corner cases for comments in if conditions.
Before:
  if ( // a
          x + 3) { ..

After:
  if ( // a
      x + 3) { ..

llvm-svn: 208175
2014-05-07 09:23:05 +00:00
Daniel Jasper 7a2d60e328 clang-format: Fix bad space before braced initializer.
Before:
  new int {1};

After:
  new int{1};

llvm-svn: 208168
2014-05-07 07:59:03 +00:00
Daniel Jasper 484033b188 clang-format: [JS] Keep space after closure style comments.
Before:
  var x = /** @type {foo} */ (bar);

After:
  var x = /** @type {foo} */(bar);

llvm-svn: 208093
2014-05-06 14:41:29 +00:00
Daniel Jasper 166c19bd37 clang-format: [JS] Keep space between 'return' and '['.
llvm-svn: 208090
2014-05-06 14:12:21 +00:00
Daniel Jasper 4a39c84c91 clang-format: [JS] Don't indent in goog.scope blocks.
Before:
  goog.scope(function() {
    var x = a.b;
    var y = c.d;
  });  // goog.scope

After:
  goog.scope(function() {
  var x = a.b;
  var y = c.d;
  });  // goog.scope

llvm-svn: 208088
2014-05-06 13:54:10 +00:00
Dinesh Dwivedi 2e92e66f66 Fixed one issue with casting
Before:
(void) SimplifyICmpOperands(Cond, LHS, RHS);

After:
(void)SimplifyICmpOperands(Cond, LHS, RHS);

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

llvm-svn: 208080
2014-05-06 11:46:49 +00:00
Daniel Jasper f10a28d705 clang-format: Understand functions with decltype return type.
Before:
  decltype(long_name_forcing_break)
      f() {}

After:
  decltype(long_name_forcing_break)
  f() {}

llvm-svn: 207965
2014-05-05 13:48:09 +00:00
Dinesh Dwivedi 76f98f8047 Added some heuristics to identify c style casting
Before:
void f() { my_int a = (my_int) * b; }
void f() { return P ? (my_int) * P : (my_int)0; }

After:
void f() { my_int a = (my_int)*b; }
void f() { return P ? (my_int)*P : (my_int)0; }

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

llvm-svn: 207964
2014-05-05 13:14:35 +00:00
Daniel Jasper 0e6c51c889 clang-format: Improve understanding of decltype.
Before:
  SomeFunction([](decltype(x), A * a) {});

After:
  SomeFunction([](decltype(x), A *a) {});

llvm-svn: 207961
2014-05-05 12:36:29 +00:00
Dinesh Dwivedi afe6fb6f05 Fix bug in clang-format while merging short function
Before:
    #ifdef _DEBUG
    int foo( int i = 0 )
    #else
    int foo( int i = 5 )
    #endif { return i; }

After:
    #ifdef _DEBUG
    int foo( int i = 0 )
    #else
    int foo( int i = 5 )
    #endif
    {
    	return i;
    }

llvm-svn: 207958
2014-05-05 11:36:35 +00:00
Daniel Jasper 9509f18836 clang-format: Fix import statements with ColumnLimit: 0
These used to interact badly with AlwaysBreakBeforeMultilineStrings.

llvm-svn: 207955
2014-05-05 08:08:07 +00:00
Alp Toker 0804343733 Eliminate ASTContext's DelayInitialization flag
Having various possible states of initialization following construction doesn't
add value here.

Also remove the unused size_reserve parameter.

llvm-svn: 207897
2014-05-03 03:46:04 +00:00
Dinesh Dwivedi ea3aca8b67 Fixes issue with Allman BreakBeforeBraces for Objective C @interface
Before:
        @interface BSApplicationController () {
    @private
      id _extraIvar;
    }
    @end

After:
    @interface BSApplicationController ()
    {
    @private
      id _extraIvar;
    }
    @end

llvm-svn: 207849
2014-05-02 17:01:46 +00:00
Alp Toker 9663780e35 Reformat code following Preprocessor constructor updates
Landing this separately to make the previous commits easy to follow at home.

llvm-svn: 207826
2014-05-02 03:43:38 +00:00
Alp Toker 1ae02f68be Factor TargetInfo pointer/DelayInitialization bool pair out of Preprocessor ctor
The Preprocessor::Initialize() function already offers a clear interface to
achieve this, further reducing the confusing number of states a newly
constructed preprocessor can have.

llvm-svn: 207825
2014-05-02 03:43:30 +00:00
Daniel Jasper 883ae9d9a3 clang-format: Don't bin-pack text-proto-formatted options.
Before:
  repeated double value = 1
      [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,
                              bbbbbbb: BBBB, bbbb: BBB}];

After:
  repeated double value = 1
      [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,
                              bbbbbbb: BBBB,
                              bbbb: BBB}];

llvm-svn: 207538
2014-04-29 15:54:14 +00:00
Daniel Jasper 35995679c6 clang-format: Allow single-line function in WebKit style.
Before:
  void f() {
      return; }

After:
  void f() { return; }

llvm-svn: 207527
2014-04-29 14:05:20 +00:00
Daniel Jasper 942d971c84 clang-format: Improve binary operator detection.
Before:
  *(int *)(p &~3UL) = 0;

After:
  *(int *)(p & ~3UL) = 0;

This fixes llvm.org/PR19464.

llvm-svn: 207405
2014-04-28 09:19:28 +00:00
Daniel Jasper 031e2409f9 clang-format: Fixes spaces in case statements.
This fixes llvm.org/PR19482.

Before:
  switch (a) {
    case(B) :
      return;
  }

After:
  switch (a) {
    case (B):
      return;
  }

llvm-svn: 207402
2014-04-28 07:48:36 +00:00
Daniel Jasper 437c3f5188 clang-format: Don't wrap after @interface.
This fixes llvm.org/PR19450.

Before:
  @interface
  BookmarkHomeHandsetViewController ()<BookmarkAllCollectionViewDelegate,
                                       BookmarkFolderCollectionViewDelegate,
                                       BookmarkMenuViewControllerDelegate,
                                       BookmarkSearchViewControllerDelegate> {
  }

After:
  @interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {
  }

llvm-svn: 207400
2014-04-28 07:34:48 +00:00
Daniel Jasper 66935020c4 clang-format: Fix bug when aligning trailing /**/-comments in macros.
Previously this could lead to a column limit violation with the
required escaped newlines.

llvm-svn: 207351
2014-04-27 10:03:19 +00:00
David Blaikie 103a2de0b4 Push unique_ptr ownership of ASTUnits further back into their factories.
llvm-svn: 207237
2014-04-25 17:01:33 +00:00
David Blaikie 39808ff901 Improve ownership of ASTUnits in libTooling by using std::unique_ptr.
llvm-svn: 207229
2014-04-25 14:49:37 +00:00
Kostya Serebryany d0f841ce4a fix a test-only leak found by lsan, PR19521
llvm-svn: 207223
2014-04-25 12:58:42 +00:00
Nico Weber 655af097a1 Fix a tiny test-only leak, found by LSan.
llvm-svn: 207137
2014-04-24 19:04:10 +00:00
Nico Weber dbd07fadae Fix two leaks found by LSan (one is test-only).
The result of llvm::MemoryBuffer::getMemBuffer() needs to be freed. Don't
pass "don't free" flag to overrideFileContents() to fix.

llvm-svn: 207075
2014-04-24 04:58:41 +00:00
Nico Weber 4fcf0c7b29 Fix two test-only leaks found by LSan.
The result of getBufferForFile() must be freed.
(Should we change functions that expect the caller to assume ownership so
that they return unique_ptrs instead? Then the type system makes sure we get
this right.)

llvm-svn: 207074
2014-04-24 04:26:18 +00:00
Nico Weber 52fbbb16a1 Fix four more test-only leaks found by LSan.
Tool::run() doesn't take ownership of the passed action.

llvm-svn: 207071
2014-04-24 03:48:09 +00:00
Nico Weber 7c3ccb032e Fix 3 test-only leaks found by LSan.
llvm-svn: 207068
2014-04-24 03:30:22 +00:00
John Thompson 2d94bbb0c0 Quick fix for layering that broke shared library build.
llvm-svn: 207011
2014-04-23 19:04:32 +00:00
John Thompson 2255f2ce90 Initial implementation of -modules-earch-all option, for searching for symbols in non-imported modules.
llvm-svn: 206977
2014-04-23 12:57:01 +00:00
Chandler Carruth 1034666777 [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE
definition below all of the header #include lines, clang edition.

If you want more details about this, you can see some of the commits to
Debug.h in LLVM recently. This is just the clang section of a cleanup
I've done for all uses of DEBUG_TYPE in LLVM.

llvm-svn: 206849
2014-04-22 03:17:02 +00:00
Alexander Kornienko 67d9c8c87e Fix alignment of trailing block comments.
Summary:
This patch ensures that the lines of the block comments retain relative
column offsets. In order to do this WhitespaceManager::Changes representing
continuation of block comments keep a pointer on the change representing the
whitespace change before the block comment, and a relative column offset to this
change, so that the correct column can be reconstructed at the end of alignment
process.

Fixes http://llvm.org/PR19325

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 206472
2014-04-17 16:12:46 +00:00
Daniel Jasper ae8e0d8da9 clang-format: Respect BinPackParameters in Cpp11BracedListStyle.
With BinPackParameters=false and Cpp11BracedListStyle=true (i.e. mostly
for Chromium):

Before:
  const Aaaaaa aaaaa = {aaaaa, bbbbb,  ccccc,  ddddd,  eeeee, ffffff,
                        ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk};

After:
  const Aaaaaa aaaaa = {aaaaa,
                        bbbbb,
                        ccccc,
                        ddddd,
                        eeeee,
                        ffffff,
                        ggggg,
                        hhhhhh,
                        iiiiii,
                        jjjjjj,
                        kkkkkk};

This fixes llvm.org/PR19359. I am not sure we'll want this in all cases
in the long run, but I'll guess we'll get feedback on that.

llvm-svn: 206458
2014-04-17 11:32:02 +00:00
Ben Langmuir a56071c5fb When writing YAML in libclang, use yaml::escape instead of write_escaped
The YAMLParser has its own escaped string representation, and does not
handle octal escape sequences. When writing the virtual file system to a
YAML file, use yaml::escape().

llvm-svn: 206443
2014-04-17 03:31:02 +00:00
Daniel Jasper 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
Alexander Kornienko 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
Daniel Jasper 783bac6bba clang-format: Understand proto text format without commas.
Also removed spaces before colons as they don't seem to be used
frequently.

Before:
optional int32 b = 2
    [(foo_options) = {aaaaaaaaaaaaaaaaaaa : 123 bbbbbbbbbbbbbbbbbbbbbbbb :
                          "baz"}];

After:
optional int32 b = 2 [(foo_options) = {aaaaaaaaaaaaaaaaaaa: 123,
                                       bbbbbbbbbbbbbbbbbbbbbbbb:"baz"}];

llvm-svn: 206269
2014-04-15 09:54:30 +00:00
Daniel Jasper 9d3adc06c6 x
llvm-svn: 206268
2014-04-15 09:54:24 +00:00
Daniel Jasper 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
Samuel Benzaquen f434c4fa3f Add support for named values in the parser.
Summary: Add support for named values in the parser.

Reviewers: pcc

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D3276

llvm-svn: 206176
2014-04-14 13:51:21 +00:00
Daniel Jasper 866468ae4d clang-format: Fix regression caused by r206165.
llvm-svn: 206173
2014-04-14 13:15:29 +00:00
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Manuel Klimek 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
Daniel Jasper 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
Daniel Jasper 220c0d1f5e clang-format: Fix false positive in braced list detection in protos.
llvm-svn: 205954
2014-04-10 07:27:12 +00:00