Commit Graph

1550 Commits

Author SHA1 Message Date
Daniel Jasper 9c2820c4e3 clang-format: [proto] Add required space before absolute references.
llvm-svn: 211488
2014-06-23 07:36:25 +00:00
Daniel Jasper 32ccb03871 clang-format: Fix corner case in pointer/reference detection.
llvm-svn: 211487
2014-06-23 07:36:18 +00:00
David Majnemer 65a407c2ce Lex: Use the correct types for MS integer suffixes
Something went wrong with r211426, it is an older version of this code
and should not have been committed.  It was reverted with r211434.

Original commit message:
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.

This fixes PR20008.

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

llvm-svn: 211441
2014-06-21 18:46:07 +00:00
Rafael Espindola d46e4a2303 Revert "Lex: Use the correct types for MS integer suffixes"
This reverts commit r211426.

This broke the arm bots. The crash can be reproduced on X86 by running.
./bin/clang -cc1  -fsyntax-only -verify -fms-extensions ~/llvm/clang/test/Lexer/ms-extensions.c -triple arm-linux

llvm-svn: 211434
2014-06-21 12:39:25 +00:00
David Majnemer 252cbe25cb Lex: Use the correct types for MS integer suffixes
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.

This fixes PR20008.

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

llvm-svn: 211426
2014-06-21 00:51:59 +00:00
Daniel Jasper 553d4878da clang-format: Introduce style with spaces on both sides of */&.
Patch by Janusz Sobczak (slightly extended).
This fixes llvm.org/19929.

llvm-svn: 211098
2014-06-17 12:40:34 +00:00
Rafael Espindola 71de0b61cb Update for llvm api change.
llvm-svn: 210921
2014-06-13 17:20:50 +00:00
Samuel Benzaquen 3ca0a7b404 Do not store duplicate parents when memoization data is available.
Summary:
Do not store duplicate parents when memoization data is available.
This does not solve the duplication problem, but ameliorates it.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 210902
2014-06-13 13:31:40 +00:00
Daniel Jasper 5217a8b84f clang-format: [JS] Understand named function literals.
Before:
  return {a: function SomeFunction(){// ...
                                     return 1;
  }
  }
  ;

After:
  return {
    a: function SomeFunction() {
      // ...
      return 1;
    }
  };

llvm-svn: 210887
2014-06-13 07:02:04 +00:00
Rafael Espindola 8e650d7bf0 Refer to error_code with the std prefix.
llvm-svn: 210817
2014-06-12 20:37:59 +00:00
Rafael Espindola c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Rafael Espindola 1f24317d87 Fix msvc unittest build.
Looks like msvc has an asymmetrical operator ==.

llvm-svn: 210768
2014-06-12 11:35:17 +00:00
Rafael Espindola d0136707a9 Give clang-format its own error category.
The posix errno values are probably to the best thing to use for
describing parse errors.

This should also fix the mingw build.

llvm-svn: 210739
2014-06-12 02:50:04 +00:00
Rafael Espindola 96b033006d Use std::error_code instead of llvm::error_code.
This is an update for a llvm api change.

llvm-svn: 210688
2014-06-11 19:05:55 +00:00
Daniel Jasper 4ac7de7199 clang-format: Fix pointer/reference detection after decltype.
Before:
  [](const decltype(*a) & value) {}

After:
  [](const decltype(*a)& value) {}

llvm-svn: 210643
2014-06-11 07:35:16 +00:00
Daniel Jasper 17062ff550 clang-format: [JS] Treat dict literals similar to objc method exprs.
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
2014-06-10 14:44:02 +00:00
Daniel Jasper ecaba17996 clang-format: Increase penalty for wrapping array subscript expressions
Before:
  aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0].aaaaaaa
                                    [0].aaaaaaaaaaaaaaaaaaaaaa();

After:
  aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0]
                                    .aaaaaaa[0]
                                    .aaaaaaaaaaaaaaaaaaaaaa();

llvm-svn: 210529
2014-06-10 13:27:57 +00:00
Daniel Jasper 908180574e clang-format: Fix enum formatting with specific comment.
Before:
  enum Fruit {  //
    APPLE,
    PEAR };

After:
  enum Fruit {  //
    APPLE,
    PEAR
  };

llvm-svn: 210522
2014-06-10 10:42:26 +00:00
Daniel Jasper da18fd86c7 clang-format: Support variadic lambda captures.
Before:
  return [ i, args... ]{};

After:
  return [i, args...] {};

llvm-svn: 210514
2014-06-10 06:39:03 +00:00
Daniel Jasper 3251fff0e3 clang-format: Handle multiline strings inside ternary expressions.
With AlwaysSplitBeforeMultilineStrings, clang-format would not find any
valid solution.

llvm-svn: 210513
2014-06-10 06:27:23 +00:00
Richard Trieu ddd01cec0e Removing an "if (this == nullptr)" check from two print methods. The condition
will never be true in a well-defined context.  The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.

llvm-svn: 210498
2014-06-09 22:53:25 +00:00
Craig Topper 416fa34b87 [C++11] Use 'nullptr'. Unittests edition.
llvm-svn: 210423
2014-06-08 08:38:12 +00:00
Alp Toker 62438dab83 Fix RecursiveASTVisitor to visit types in ObjCPropertyDecl
Patch by Mathieu Baudet!

llvm-svn: 210339
2014-06-06 15:05:09 +00:00
Daniel Jasper 58cb2edd69 clang-format: Fix incorrect indentation.
Before (JavaScript example, but can extend to other languages):
  return {
    a: 'E',
    b: function() {
      return function() {
      f();  // This is wrong.
      };
    }
  };

After:
  return {
    a: 'E',
    b: function() {
      return function() {
        f();  // This is better.
      };
    }
  };

llvm-svn: 210334
2014-06-06 13:49:04 +00:00
Nikola Smiljanic 357af64d78 Add first set of tests for FriendDecl source range and location.
llvm-svn: 210306
2014-06-06 04:40:35 +00:00
Samuel Benzaquen f56a29924f Add hasLocalStorage/hasGlobalStorage matchers.
Summary:
Add hasLocalStorage/hasGlobalStorage matchers for VarDecl nodes.
Update the doc. Also add them to the dynamic registry.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 210278
2014-06-05 18:22:14 +00:00
Daniel Jasper a69ca9be12 clang-format: Leave empty lines within UnwrappedLines.
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
2014-06-04 12:40:57 +00:00
Alp Toker 1d257e1d0a Remove the last remaining llvm/Config/config.h includes
This corrects long-standing misuses of LLVM's internal config.h.

In most cases the public llvm-config.h header was intended and we can now
remove the old hacks thanks to LLVM r210144.

The config.h header is private, won't be installed and should no longer be
included by clang or other modules.

llvm-svn: 210145
2014-06-04 03:28:55 +00:00
Daniel Jasper 114a2bc9d2 clang-format: Refactor indentation behavior for multiple nested blocks.
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
2014-06-03 12:02:45 +00:00
Daniel Jasper 7d028298ce clang-format: Fix special case of binary operator detection.
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
2014-06-02 11:54:20 +00:00
Daniel Jasper 4afc6b3e16 clang-format: No space between ")" and braced init list.
Before:
  auto j = decltype(i) {};

After:
  auto j = decltype(i){};

This fixes llvm.org/PR19892.

llvm-svn: 210013
2014-06-02 10:57:55 +00:00
Daniel Jasper e18ff37e08 clang-format: Fix Allman brace breaking of enums.
Before:
  enum Side
  { LEFT,
    RIGHT };

After:
  enum Side
  {
    LEFT,
    RIGHT
  };

This fixes llvm.org/PR19911.

llvm-svn: 210011
2014-06-02 10:17:32 +00:00
Daniel Jasper e3f907fded clang-format: Fix trailing const (etc.) with Allman brace style.
Before:
  void someLongFunction(int someLongParameter)
      const
  {
  }

After:
  void someLongFunction(
      int someLongParameter) const
  {
  }

This fixes llvm.org/PR19912.

llvm-svn: 210010
2014-06-02 09:52:08 +00:00
Rafael Espindola 3ae0620a45 There is no std::errc:success, remove the llvm one.
llvm-svn: 209959
2014-05-31 03:20:52 +00:00
Rafael Espindola fd148d0b6f Use make_error_code in preparation for making errc an enum class.
llvm-svn: 209956
2014-05-31 02:23:01 +00:00
Richard Smith 46dd5bba44 Take PrintingPolicy::SuppressUnwrittenScope into account when printing the
qualified name of a NamedDecl. Patch by Volodymyr Sapsai!

llvm-svn: 209924
2014-05-30 22:16:51 +00:00
Daniel Jasper d39312ec84 clang-format: Don't break before a case's colon.
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
2014-05-28 10:09:11 +00:00
Daniel Jasper 335ff26631 clang-format: Format array and dict literals similar to blocks.
Especially, reduce the amount of indentation if it doesn't increase
readability.

Before:
  NSMutableDictionary* dictionary = [NSMutableDictionary
      dictionaryWithDictionary:@{
                                 aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa,
                                 bbbbbbbbbbbbbbbbbb : bbbbb,
                                 cccccccccccccccc : ccccccccccccccc
                               }];

After:
  NSMutableDictionary* dictionary =
      [NSMutableDictionary dictionaryWithDictionary:@{
        aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa,
        bbbbbbbbbbbbbbbbbb : bbbbb,
        cccccccccccccccc : ccccccccccccccc
      }];

llvm-svn: 209720
2014-05-28 09:11:53 +00:00
Manuel Klimek a2c2a4faa0 Make equalsNode work with pointers to subtypes.
llvm-svn: 209652
2014-05-27 12:31:10 +00:00
Manuel Klimek 909b5c94c0 Adds child traversal matchers for IfStmt's then and else branches.
llvm-svn: 209649
2014-05-27 10:04:12 +00:00
Manuel Klimek 2af0a91cc4 Allow hasBody on CXXForRangeStmt nodes and update the docs.
llvm-svn: 209647
2014-05-27 07:45:18 +00:00
Daniel Jasper ba1b6bb667 clang-format: Keep '{' of dict literals on the same line in Allman style
Before:
  void f()
  {
    [object
        someMethod:@
        { @"a" : @"b" }];
  }

After:
  void f()
  {
    [object someMethod:@{ @"a" : @"b" }];
  }

This fixes llvm.org/PR19854.

llvm-svn: 209615
2014-05-26 07:24:34 +00:00
Manuel Klimek 8651081bbe Add the hasRangeInit() matcher for range-based for loop.
llvm-svn: 209533
2014-05-23 17:49:03 +00:00
Daniel Jasper 565ed5ed08 clang-format: Don't use Allman brace breaking for ObjC blocks.
It just seems wrong. This fixes llvm.org/PR19736.

llvm-svn: 209440
2014-05-22 13:53:55 +00:00
Daniel Jasper bd630737bd clang-format: Fix corner case in AllowShortBlocksOnASingleLine.
Before:
  template <int> struct A4 { A4() { }
  };

After:
  template <int i> struct A4 {
    A4() {}
  };

This fixes llvm.org/PR19813 (at least the part that isn't working as
intended).

llvm-svn: 209438
2014-05-22 13:25:26 +00:00
Daniel Jasper 91b032ab55 clang-format: Fix braced list detection.
Before:
  static_assert(std::is_integral<int> {} + 0, "");
  int a = std::is_integral<int> {}
  + 0;

After:
  static_assert(std::is_integral<int>{} + 0, "");
  int a = std::is_integral<int>{} + 0;

llvm-svn: 209431
2014-05-22 12:46:38 +00:00
Daniel Jasper 438059e509 clang-format: Fix incorrect braced init identification.
Before:
  int foo(int i) {
    return fo1 {}
    (i);
  }
  int foo(int i) {
    return fo1 {}
    (i);
  }

After:
  int foo(int i) { return fo1{}(i); }
  int foo(int i) { return fo1{}(i); }

This fixes llvm.org/PR19812.

llvm-svn: 209428
2014-05-22 12:11:13 +00:00
Daniel Jasper 49802ef93b clang-format: [JS] Understand line breaks in concatenated strings.
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
2014-05-22 09:10:04 +00:00
Daniel Jasper 3948516a03 clang-format: Correctly identify multiplications in braces init lists.
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
2014-05-22 09:00:33 +00:00
Daniel Jasper 5f3ea477cf clang-format: Correctly calculate line lenghts for nest blocks.
If simple (one-statement) blocks can be inlined, the length needs to be
calculated correctly.

Before (in JavaScript but this also affects lambdas, etc.):
  var x = {
    valueOf: function() { return 1; }
  };

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

llvm-svn: 209410
2014-05-22 08:36:53 +00:00
Justin Bogner 44fa45034b VirtualFileSystem: Fix a few directory traversal bugs in VFSWriter
There are a couple of issues with writing VFS maps that are awkward to
fix within the current mutually recursive approach. Instead, replace
the algorithm with an iterative version that uses an explicit stack of
directories.

Includes tests for cases the old approach was tripping on.

llvm-svn: 209332
2014-05-21 22:46:51 +00:00
Daniel Jasper 2a958321c8 clang-format: Fix corner case working around one-per-line dict literals.
Before:
  var object_literal_with_long_name = {
    a: 'aaaaaaaaaaaaaaaaaa', b: 'bbbbbbbbbbbbbbbbbb'
  };

After:
  var object_literal_with_long_name = {
    a: 'aaaaaaaaaaaaaaaaaa',
    b: 'bbbbbbbbbbbbbbbbbb'
  };

llvm-svn: 209296
2014-05-21 13:26:58 +00:00
Daniel Jasper 5ebb2f3625 clang-format: Fix incorrect macro call detection.
In:
  struct A {
    A()
        noexcept(....) {}
  };

'A()' is not a macro call.
This fixes llvm.org/PR19814.

llvm-svn: 209294
2014-05-21 13:08:17 +00:00
Daniel Jasper b16b969d7c clang-format: [JS] Support different function literal style.
Before:
  goog.array.forEach(array, function() {
                              doSomething();
                              doSomething();
                            },
                     this);

After:
  goog.array.forEach(array, function() {
    doSomething();
    doSomething();
  }, this);

llvm-svn: 209291
2014-05-21 12:51:23 +00:00
Alp Toker b671e34c36 SourceManager: Use setMainFileID() consistently
Eliminate createMainFileID() / createMainFileIDForMemBuffer() utility
functions. These didn't add much convenience and conflated two distinct
operations.

This change makes things easier to follow by providing a consistent interface
and getting rid of a bunch of cast-to-voids.

llvm-svn: 209266
2014-05-21 01:12:41 +00:00
Justin Bogner 5719614b77 libclang: Give each VirtualFileOverlay unit test its own name
llvm-svn: 209257
2014-05-20 23:52:11 +00:00
Justin Bogner 1c078f2b1f VirtualFileSystem: Fix false positives in YAMLVFSWriter::containedIn
Checking if a path starts with another path isn't sufficient for
determining if one is contained within the heirarchy of the other.
We need to ensure that the substring ends at a directory boundary.

llvm-svn: 209250
2014-05-20 22:12:58 +00:00
Daniel Jasper 069e5f4858 clang-format: [JS] Understand top-level function literals properly.
llvm-svn: 209205
2014-05-20 11:14:57 +00:00
Richard Smith 1be902c02f [modules] Fix ODR violation: there's another clang::TypeLocVisitor elsewhere.
llvm-svn: 209169
2014-05-19 22:34:38 +00:00
Daniel Jasper 7f0c517168 clang-format: Don't force line breaks in ObjC calls with ColumnLimit 0.
Before:
  [self.x a:b c:d];

Got reformatted toi (with ColumnLimit set to 0):
  [self.x a:b
          c:d];

llvm-svn: 209114
2014-05-19 08:06:34 +00:00
Daniel Jasper 0dd5291e69 clang-format: [JS] Support ES6 destructuring assignments.
Before:
  var[a, b, c] = [1, 2, 3];

After:
  var [a, b, c] = [1, 2, 3];

llvm-svn: 209113
2014-05-19 07:37:07 +00:00
Daniel Jasper 78214397a3 clang-format: [JS] Support for EC6 arrow functions.
Before:
  var b = a.map((x) = > x + 1);

After:
  var b = a.map((x) => x + 1);

llvm-svn: 209112
2014-05-19 07:27:02 +00:00
Joey Gouly 0d9a2b2205 [ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.
llvm-svn: 209006
2014-05-16 19:31:08 +00:00
Alp Toker 6ac2cd01d2 Rename SourceManager::createFileIDForMemBuffer()
It makes more sense to just overload createFileID().

Gardening only.

llvm-svn: 209002
2014-05-16 17:23:01 +00:00
Ben Langmuir 5bf828dd34 Switch another write_escaped to yaml::escape
I missed one in r206443.

llvm-svn: 208941
2014-05-16 01:38:59 +00:00
Daniel Jasper 17605d3961 clang-format: Add option to allow short blocks on a single line.
With AllowShortBlocksOnASingleLine, clang-format allows:
  if (a) { return; }

Based on patch by Gonzalo BG, thank you!

llvm-svn: 208765
2014-05-14 09:33:35 +00:00
Daniel Jasper 0a1e5ace26 clang-format: Don't break in the middle of ">>".
Before:
  zzzzzzzzzz = bbbbbbbbbbbbbbbbb >
               > aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  zzzzzzzzzz
      = bbbbbbbbbbbbbbbbb
        >> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);

This fixes llvm.org/PR19731.

llvm-svn: 208672
2014-05-13 08:01:47 +00:00
Daniel Jasper fb4333b093 clang-format: [JS] Basic support for escape sequences in regex literals.
Before:
  var regex = /\\/ g; // This isn't even recognized as regex.

After:
  var regex = /\\/g; // It now is.

llvm-svn: 208539
2014-05-12 11:29:50 +00:00
Benjamin Kramer f3ca269839 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

llvm-svn: 208470
2014-05-10 16:31:55 +00:00
Daniel Jasper 8951908218 clang-format: [JS] Fix spacing in dict literals.
Before:
  someVariable = {'a':[{}]};

After:
  someVariable = {'a': [{}]};

llvm-svn: 208403
2014-05-09 10:26:08 +00:00
Daniel Jasper 04a71a45ff clang-format: Initial support for try-catch.
Most of this patch was created by Alexander Rojas in
http://reviews.llvm.org/D2555
Thank you!

Synced and addressed review comments.

llvm-svn: 208302
2014-05-08 11:58:24 +00:00
Daniel Jasper c03e16a7bc clang-format: [JS] support closures in container literals.
Before:
  return {body: {setAttribute: function(key, val) {this[key] = val;
  }
  , getAttribute : function(key) { return this[key]; }
  , style : {
  direction:
    ''
  }
  }
  }
  ;

After:
  return {
    body: {
      setAttribute: function(key, val) { this[key] = val; },
      getAttribute: function(key) { return this[key]; },
      style: {direction: ''}
    }
  };

llvm-svn: 208292
2014-05-08 09:25:39 +00:00
Daniel Jasper ea2d042f89 clang-format: Fix binary operator detection before lambdas.
Before:
  bool foo = true&& [] { return false; }();

After:
  bool foo = true && [] { return false; }();

llvm-svn: 208288
2014-05-08 08:50:10 +00:00
Daniel Jasper f7405c129e clang-format: [JS] Support regex literals after 'return'.
llvm-svn: 208285
2014-05-08 07:45:18 +00:00
Daniel Jasper f9ae312fc0 clang-format: [JS] Initial support for regex literals.
llvm-svn: 208281
2014-05-08 07:01:45 +00:00
Nikola Smiljanic e08a91ecd2 Enable alternative tokens by default for clang-format.
Patch by Bobby Moretti.

llvm-svn: 208269
2014-05-08 00:05:13 +00:00
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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper b77105d2ce clang-format: Fix incorrect multi-block-parameter computation.
llvm-svn: 205763
2014-04-08 14:04:31 +00:00
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Samuel Benzaquen 5548eadb1c Revert "Add support for named values in the parser."
This was submitted before it was ready.

This reverts commit 62060a01e095cf35eb9ca42a333752d12714f35c.

llvm-svn: 205533
2014-04-03 12:50:47 +00:00
Daniel Jasper 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
Daniel Jasper 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
Samuel Benzaquen f10662923a Add matcher for ExprWithCleanups.
Summary: Add matcher for ExprWithCleanups.

Reviewers: klimek

CC: cfe-commits, klimek

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

llvm-svn: 205420
2014-04-02 13:12:14 +00:00
Samuel Benzaquen 2019cea863 Add support for named values in the parser.
Summary:
Add support for named values in the parser.
This allows injection of arbitrary constants using a custom Sema object.
Completions are not supported right now.

Will be used by clang_query to support the 'let' command.
Usage example:
  clang_query> let unique_ptr recordDecl(hasName("unique_ptr"))
  clang_query> match varDecl(hasType(unique_ptr))

Reviewers: klimek, pcc

CC: cfe-commits, klimek

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

llvm-svn: 205419
2014-04-02 13:11:45 +00:00
David Blaikie abe1a398e3 Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda at ... )')
For namespaces, this is consistent with mangling and GCC's debug info
behavior. For structs, GCC uses <anonymous struct> but we prefer
consistency between all anonymous entities but don't want to confuse
them with template arguments, etc, so we'll just go with parens in all
cases.

llvm-svn: 205398
2014-04-02 05:58:29 +00:00
Aaron Ballman 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 395193c7a0 clang-format: Recognize more ObjC blocks with parameters/return type.
llvm-svn: 204990
2014-03-28 07:48:59 +00:00
Saleem Abdulrasool 377066a5f5 Use the new Windows environment for target detection
This follows the LLVM change to canonicalise the Windows target triple
spellings.  Rather than treating each Windows environment as a single entity,
the environments are now modelled properly as an environment.  This is a
mechanical change to convert the triple use to reflect that change.

llvm-svn: 204978
2014-03-27 22:50:18 +00:00
Manuel Klimek 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
Daniel Jasper 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
Manuel Klimek 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
Daniel Jasper c13ee34378 clang-format: Correctly identify ObjC Block with return type.
llvm-svn: 204905
2014-03-27 09:43:54 +00:00
Manuel Klimek ce68f7714a Fixes a bug in DynTypedNode.
Two DynTypedNodes can be equal if they do not have the same node type,
because DynTypedNodes for the same underlying object might have been
created from different types (for example, Decl vs VarDecl).

llvm-svn: 204722
2014-03-25 14:39:26 +00:00
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 01b35482e5 clang-format: Don't remove empty lines at the start of namespaces.
llvm-svn: 204462
2014-03-21 13:03:33 +00:00
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 28df0a356e clang-format: Fix for r204456.
llvm-svn: 204457
2014-03-21 12:15:40 +00:00
Daniel Jasper 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
Argyrios Kyrtzidis a9ab4d46bb [libclang] Introduce clang_VirtualFileOverlay_setCaseSensitivity that exposes the VFS option
to set the case-sensitivity for lookups.

rdar://16374696

llvm-svn: 204303
2014-03-20 04:51:48 +00:00
Alexander Kornienko 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
Manuel Klimek 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
Daniel Jasper 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
NAKAMURA Takumi 7ebbda83a2 ASTTests//EvaluateAsRValueTest.cpp: Appease *-win32 target to add -fno-delayed-template-parsing.
llvm-svn: 203991
2014-03-15 00:36:51 +00:00
James Dennett 622831b739 Change a raw string literal back to C++98 style to fix freeBSD9.2 builtbot
llvm-svn: 203961
2014-03-14 20:08:11 +00:00
James Dennett 0492ef0e0b Fix a crash (assertion failure) in EvaluateAsRValue.
Summary:
Gracefully fail to evaluate a constant expression if its type is
unknown, rather than failing an assertion trying to access the type.

Reviewers: klimek

Reviewed By: klimek

CC: chandlerc, cfe-commits

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

llvm-svn: 203950
2014-03-14 17:44:10 +00:00
Daniel Jasper 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
Hans Wennborg 501eadb429 Check for LLVM_ON_WIN32 instead of _WIN32.
This is a follow-up to r203624 to address Anton's comment.

llvm-svn: 203668
2014-03-12 16:07:46 +00:00
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
Daniel Jasper 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
David Blaikie 0e18ed2eba Fix use of uninitialized variable in ExternalASTSourceTest.cpp (introduced in 203525)
llvm-svn: 203545
2014-03-11 06:49:26 +00:00
Richard Smith 023d2ca451 Add a unittest for the ExternalASTSource.
llvm-svn: 203525
2014-03-11 01:18:47 +00:00
Samuel Benzaquen a083935d0a Add loc() to the dynamic registry.
Summary:
Add loc() to the dynamic registry.
Other fixes:
 - Fix the polymorphic variant value to accept an exact match, even if
   there are other possible conversions.
 - Fix specifiesTypeLoc() to not crash on an empty
   NestedNameSpecifierLoc.

Reviewers: klimek

CC: cfe-commits, klimek

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

llvm-svn: 203467
2014-03-10 15:40:23 +00:00
Daniel Jasper 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
Alexander Kornienko 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
Daniel Jasper 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
Richard Smith 664b32b814 Revert accidentally-committed file.
llvm-svn: 203318
2014-03-08 00:04:19 +00:00
Richard Smith 9bca298f6d Module [extern_c] attribute: inherit to submodules, don't write 'extern "C"'
blocks when building in C mode, and serialize and deserialize the attribute.

llvm-svn: 203317
2014-03-08 00:03:56 +00:00
Ahmed Charles b89843299a Replace OwningPtr with std::unique_ptr.
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.

llvm-svn: 203279
2014-03-07 20:03:18 +00:00
Ahmed Charles d72a5f103d Replace OwningPtr::isValid() with conversion to bool.
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203277
2014-03-07 19:51:06 +00:00
Ahmed Charles 9a16beb8bc Change OwningPtr::take() to OwningPtr::release().
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203275
2014-03-07 19:33:25 +00:00
Alexander Kornienko 86b2dfdc3b Fix operator<< recognition (PR19064).
llvm-svn: 203123
2014-03-06 15:13:08 +00:00
Ben Langmuir 9385323747 Attempt to re-enable the VFS unittests on Windows
Using a //net/ path to hopefully avoid problems with non-absolute paths
on Windows.

llvm-svn: 203010
2014-03-05 21:32:20 +00:00
NAKAMURA Takumi 6a927ecb7a Disable BasicTests/VFS on win32 for now. Investigating.
Failing Tests (5):
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.CaseInsensitive
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.MappedFiles
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.MultiComponentPath
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.TrailingSlashes
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.UseExternalName

llvm-svn: 202952
2014-03-05 09:10:04 +00:00
David Majnemer 197e2103a2 Speculatively fix MSVC buildbots
llvm-svn: 202938
2014-03-05 06:32:38 +00:00
Chandler Carruth 757fcd6d1f [cleanup] Re-sort includes with llvm/utils/sort_includes.py and fix
a missing include from CLog.h.

CLog.h referenced most of the core libclang types but never directly
included Index.h that provides them. Previously it got lucky and other
headers were always included first but with the sorting it ended up
first in one case and stopped compiling. Adding the Index.h include
fixes it right up.

llvm-svn: 202810
2014-03-04 10:05:20 +00:00
Dmitri Gribenko 5ea34fcc8d Decl printing: add tests for typedefs
Patch by Konrad Kleine.

llvm-svn: 202709
2014-03-03 13:21:00 +00:00
Peter Collingbourne f93725459a MSVC 2012 doesn't support std::initializer_list at all, so don't rely on
that std::vector constructor.

llvm-svn: 202684
2014-03-03 08:13:06 +00:00
Peter Collingbourne 2bbb029599 MSVC cannot understand temporaries formed from initializer lists.
llvm-svn: 202682
2014-03-03 07:49:35 +00:00
Argyrios Kyrtzidis d502a10c5e [libclang] Introduce APIs that assist in constructing a simple module.map file for a user framework.
rdar://16092858

llvm-svn: 202681
2014-03-03 07:41:45 +00:00
Argyrios Kyrtzidis 74c96c0c75 [libclang] Change clang_VirtualFileOverlay_writeToBuffer to return a malloc'ed buffer.
Returning CXString is not appropriate if we want to switch to a non-string format buffer.

llvm-svn: 202675
2014-03-03 06:38:52 +00:00
Peter Collingbourne c0423b349b Disable all dependency output options when using the Tooling library.
It isn't appropriate for a tool to be stomping over the dependency files,
especially if the actual build uses a compiler other than Clang or the tool
cannot find all the headers for some reason (which would cause the existing
dependency file to be deleted).

If a tool actually needs to care about dependency files we can think about
adding a mechanism for getting to this information.

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

llvm-svn: 202669
2014-03-02 23:37:26 +00:00
Chandler Carruth f8b7266d57 [C++11] Switch the clang-format LLVM style to use C++11 style braced
init list formatting. This suggestion has now gone into the LLVM coding
standards, and is particularly relevant now that we're using C++11.

Updated a really ridiculous number of tests to reflect this change.

llvm-svn: 202637
2014-03-02 12:37:31 +00:00
Craig Topper a798a9db93 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202625
2014-03-02 09:32:10 +00:00
Ben Langmuir d066d4c849 Reapply fixed "Honour 'use-external-names' in FileManager"
Was r202442

There were two issues with the original patch that have now been fixed.
1. We were memset'ing over a FileEntry in a test case. After adding a
   std::string to FileEntry, this still happened to not break for me.
2. I didn't pass the FileManager into the new compiler instance in
   compileModule. This was hidden in some cases by the fact I didn't
   clear the module cache in the test.

Also, I changed the copy constructor for FileEntry, which was memcpy'ing
in a (now) unsafe way.

llvm-svn: 202539
2014-02-28 21:16:07 +00:00
Ben Langmuir 1b8d44f59b Revert "Honour 'use-external-names' in FileManager"
Revert r202442, which broke the buildbots.

llvm-svn: 202443
2014-02-27 23:48:03 +00:00
Ben Langmuir 09e0d5c1bb Honour 'use-external-names' in FileManager
Pass through the externally-visible names that we got from the VFS down
to FileManager, and test that this is the name showing up in __FILE__,
diagnostics, and debug information.

llvm-svn: 202442
2014-02-27 23:27:54 +00:00