Commit Graph

1394 Commits

Author SHA1 Message Date
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