Commit Graph

1499 Commits

Author SHA1 Message Date
Manuel Klimek 45bf56cdf9 Fix parsing of classes where the class name is an absolute nested name specifier.
llvm-svn: 214393
2014-07-31 07:19:30 +00:00
Daniel Jasper 71646ec206 clang-format: Understand 'typename' in placement new.
Before:
  new (aaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa();

After:
  new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
      typename aaaaaaaaaaaaaaaaaaaaaaaa();

llvm-svn: 214300
2014-07-30 12:14:10 +00:00
Daniel Jasper a382cbe4eb clang-format: [proto] Improve formatting of text-proto options.
Initial patch and tests by Kaushik Sridharan, thank you!

llvm-svn: 214084
2014-07-28 14:08:09 +00:00
Daniel Jasper 6ba1638f0b clang-format: Improve operator and template recognition.
Before:
  static_assert(is_convertible < A &&, B > ::value, "AAA");

After:
  static_assert(is_convertible<A &&, B>::value, "AAA");

llvm-svn: 214075
2014-07-28 13:19:58 +00:00
Daniel Jasper 8184d66f4b clang-format: Improve pointer/reference detection.
Before (with left pointer alignment):
  void f(int i = 0, SomeType* *temps = NULL);

After:
  void f(int i = 0, SomeType** temps = NULL);

llvm-svn: 214071
2014-07-28 12:24:21 +00:00
Daniel Jasper 2ac3fdfd4a clang-format: Fix unary operator recognition.
Before:
  int x = ~ * p;

After:
  int x = ~*p;

llvm-svn: 214070
2014-07-28 12:08:16 +00:00
Daniel Jasper 8b76d608b8 clang-format: Fix formatting of lock annotations in lambda definitions.
Before:
  SomeFunction([](int i)LOCKS_EXCLUDED(a) {});

After:
  SomeFunction([](int i) LOCKS_EXCLUDED(a) {});

llvm-svn: 214069
2014-07-28 12:08:06 +00:00
NAKAMURA Takumi 036f713f17 [CMake] LexTests: Prune redundant libdep(s).
llvm-svn: 213853
2014-07-24 11:44:03 +00:00
Daniel Jasper 3dfa09bbbc Prevent assert in ASTMatchFinder.
If nodes without memoization data (e.g. TypeLocs) are bound to specific
names, that effectively prevents memoization as those elements cannot be
compared effectively. If it is tried anyway, this can lead to an assert
as demonstrated in the new test.

In the long term, the better solution will be to enable DynTypedNodes
without memoization data. For now, simply skip memoization instead.

llvm-svn: 213751
2014-07-23 13:17:47 +00:00
Benjamin Kramer 7664558efc ASTMatchers: Bound node results are always const, make selectFirst's template argument implicitly const.
This avoids adding const to every user of selectFirst and also allows it to
match TypeLocs which BoundNodes doesn't use magic const removal specializations
for. No functionality change.

llvm-svn: 213737
2014-07-23 11:41:44 +00:00
Richard Smith a593419593 AST printer: fix double space before base class with no access specifier.
llvm-svn: 213719
2014-07-23 03:22:10 +00:00
Richard Smith a4bb292095 When pretty-printing a declaration of a pack, put the ellipsis before the name
being declared, not at the end. When pretty-printing a non-type template
parameter, put the name of the parameter in the middle of the type, not at the
end.

llvm-svn: 213718
2014-07-23 03:17:06 +00:00
David Blaikie 62a56f39b7 Revert "unique_ptr-ify ownership of ASTConsumers"
This reverts commit r213307.

Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.

llvm-svn: 213325
2014-07-17 22:34:12 +00:00
David Blaikie a51666a4d6 unique_ptr-ify ownership of ASTConsumers
(after fixing a bug in MultiplexConsumer I noticed the ownership of the
nested consumers was implemented with raw pointers - so this fixes
that... and follows the source back to its origin pushing unique_ptr
ownership up through there too)

llvm-svn: 213307
2014-07-17 20:40:36 +00:00
Daniel Jasper fc3861ac48 clang-format: Fix parsing of conditional expressions.
Before:
  aaaaaa = aaaaaaaaaaaa ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      : aaaaaaaaaaaaaaaaaaaaaa
      : aaaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
  aaaaaa = aaaaaaaaaaaa
               ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                            : aaaaaaaaaaaaaaaaaaaaaa
               : aaaaaaaaaaaaaaaaaaaaaaaaaaaa;

llvm-svn: 213258
2014-07-17 12:22:04 +00:00
Nikola Smiljanic 4fc91538e9 Fix FriendDecl source location and range for class templates and function declarations that don't start with 'friend' keyword. Add more unittests.
llvm-svn: 213220
2014-07-17 01:59:34 +00:00
Alp Toker 0621cb2e7d Make clang's rewrite engine a core feature
The rewrite facility's footprint is small so it's not worth going to these
lengths to support disabling at configure time, particularly since key compiler
features now depend on it.

Meanwhile the Objective-C rewriters have been moved under the
ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still
potentially worth excluding from lightweight builds.

Tests are now passing with any combination of feature flags. The flags
historically haven't been tested by LLVM's build servers so caveat emptor.

llvm-svn: 213171
2014-07-16 16:48:33 +00:00
Benjamin Kramer 73ef216c73 [ASTMatchers] Add a usingDirectiveDecl matcher.
This matches 'using namespace' declarations.

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

llvm-svn: 213152
2014-07-16 14:14:51 +00:00
Daniel Jasper fcfac10c8a clang-format: Improve heuristic around avoiding bad line breaks.
Now, this can be properly formatted:
  static_cast<A< //
      B> *>(     //
      );

Before, clang-format could end up, not formatting the code at all.

llvm-svn: 213055
2014-07-15 09:00:34 +00:00
Justin Bogner 73466400b2 VirtualFileSystem: Correctly generate the mapping for an empty VFS
In r209332 I accidentally broke generation of empty VFS maps. This
fixes the issue and adds a test.

llvm-svn: 213028
2014-07-15 01:24:35 +00:00
Benjamin Kramer 09514492cc [ASTMatchers] Make hasOverloadedOperatorName also match freestanding overloads.
Freestanding overloads are represented as FunctionDecls in the AST, make
the matcher also match them.

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

llvm-svn: 212940
2014-07-14 14:05:02 +00:00
Daniel Jasper 3064620d0d clang-format: Improve cast detection (fix false positive).
Before:
  fn(a)(b)+1;

After:
  fn(a)(b) + 1;

llvm-svn: 212935
2014-07-14 12:38:38 +00:00
Argyrios Kyrtzidis baa97663c2 [Driver] clang::driver::getARMCPUForMArch() moved to llvm::Triple::getARMCPUForArch().
Depends on llvm r212846.
Suggested by Eric Christopher.

llvm-svn: 212858
2014-07-11 23:47:48 +00:00
Argyrios Kyrtzidis 2e81dfc5cd [Driver/Unittests] Follow up for r212666, add unit test for the newly exposed getARMCPUForMArch() function.
llvm-svn: 212751
2014-07-10 18:38:38 +00:00
Daniel Jasper 85bcadcdc6 clang-format: Fix behavior around pointer-to-member invocations.
Before:
  (aaaaaaaaaa->*
   bbbbbbb)(aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa));

After:
  (aaaaaaaaaa->*bbbbbbb)(
      aaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa));

llvm-svn: 212617
2014-07-09 13:07:57 +00:00
Daniel Jasper c75e1effed clang-format: Add new option to indent wrapped function declarations.
Though not completely identical, make former
IndentFunctionDeclarationAfterType change this flag for backwards
compatibility (it is somewhat close in meaning and better the err'ing on
an unknown config flag).

llvm-svn: 212597
2014-07-09 08:42:42 +00:00
Daniel Jasper 4355e7f0ef clang-format: Revamp function declaration/definition indentation.
Key changes:
- Correctly (well ...) distinguish function declarations and variable
  declarations with ()-initialization.
- Don't indent when breaking function declarations/definitions after the
  return type.
- Indent variable declarations and typedefs when breaking after the
  type.

This fixes llvm.org/PR17999.

llvm-svn: 212591
2014-07-09 07:50:33 +00:00
Benjamin Kramer 46741758c1 Update unit test for signature change.
llvm-svn: 212545
2014-07-08 16:07:39 +00:00
Ben Langmuir e218cd77b4 Use temporary module cache in test
llvm-svn: 212467
2014-07-07 17:34:37 +00:00
Alp Toker 80758084f7 Use non-intrusive refcounting for TargetOptions
llvm-svn: 212388
2014-07-06 05:26:44 +00:00
Alp Toker f994cef836 Track IntrusiveRefCntPtr::get() changes from LLVM r212366
llvm-svn: 212369
2014-07-05 03:08:06 +00:00
Ben Langmuir 33c8090a2f Consider module depedencies when checking a preamble in libclang
Add module dependencies (header files, module map files) to the list of
files to check when deciding whether to rebuild a preamble. That fixes
using preambles with module imports so long as they are in
non-overridden files.

My intent is to use to unify the existing dependency collectors to the
new “DependencyCollectory” interface from this commit, starting with the
DependencyFileGenerator.

llvm-svn: 212060
2014-06-30 20:04:14 +00:00
Daniel Jasper 2520fe9662 clang-format: Support member function reference qualifiers.
Before:
  string // break
      operator()() &
  {}

After:
  string // break
  operator()() & {}

llvm-svn: 212041
2014-06-30 13:54:27 +00:00
Daniel Jasper 91beebd04a clang-format: Improve expression heuristics.
Upon encountering a binary operator inside parentheses, assume that the
parentheses contain an expression.

Before:
  MACRO('0' <= c&& c <= '9');

After:
  MACRO('0' <= c && c <= '9');

llvm-svn: 212040
2014-06-30 13:44:47 +00:00
Daniel Jasper ad9eb0d79d clang-format: [JS] support free-standing functions again.
This worked initially but was broken by r210887.

Before:
  function outer1(a, b) {
    function inner1(a, b) { return a; } inner1(a, b);
  } function outer2(a, b) { function inner2(a, b) { return a; } inner2(a, b); }

After:
  function outer1(a, b) {
    function inner1(a, b) { return a; }
    inner1(a, b);
  }
  function outer2(a, b) {
    function inner2(a, b) { return a; }
    inner2(a, b);
  }

Thanks to Adam Strzelecki for working on this.

llvm-svn: 212038
2014-06-30 13:24:54 +00:00
Alexander Kornienko 9e41b5cc12 Add a matcher for SubstNonTypeTemplateParmExpr.
Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: klimek, aemerson, cfe-commits

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

llvm-svn: 212001
2014-06-29 22:18:53 +00:00
NAKAMURA Takumi 6189422f08 LibclangTest.cpp: s/uint/unsigned/. I think 'uint' is not a standard type.
llvm-svn: 211997
2014-06-29 11:07:48 +00:00
Craig Topper 00bbdcf9b3 Remove llvm:: from uses of ArrayRef.
llvm-svn: 211987
2014-06-28 23:22:23 +00:00
David Blaikie 66cc07b4f7 Remove 'const' from MemoryBuffers used through the SourceManager
This removes a const_cast added in r211884 that occurred due to an
inconsistency in how MemoryBuffers are handled between some parts of
clang and LLVM.

MemoryBuffers are immutable and the general convention in the LLVM
project is to omit const from immutable types as it's simply
redundant/verbose (see llvm::Type, for example). While this change
doesn't remove "const" from /every/ MemoryBuffer, it at least makes this
chain of ownership/usage consistent.

llvm-svn: 211915
2014-06-27 17:40:03 +00:00
Ben Langmuir f3050d2461 Add reparse test for libclang
Adapted from a reproducer by Dan Schmidt, thanks!

llvm-svn: 211910
2014-06-27 17:04:26 +00:00
Alp Toker 0843bff137 Make test from r211758 portable
It turns out the -fblocks option is determined by the default tooling target
and not implied by the other two flags.

llvm-svn: 211761
2014-06-26 02:07:06 +00:00
Alp Toker e3ad531afb RAV: visit copy expressions of captured variables in blocks (ObjC++11)
Patch by Mathieu Baudet.

llvm-svn: 211758
2014-06-26 01:42:24 +00:00
Ben Langmuir 7c9f6c86c9 Add vfs::recursive_directory_iterator
For now, this is only used by its unit tests.  It is similar to the API
in llvm::sys::fs::recursive_directory_iterator, but without some of the
more complex features like requesting that the iterator not recurse into
the next directory, for example.

llvm-svn: 211732
2014-06-25 20:25:40 +00:00
NAKAMURA Takumi 4669bd49a2 VirtualFileSystemTest.cpp: Get rid of initializer list on std::vector, to appease msc17.
llvm-svn: 211662
2014-06-25 04:34:10 +00:00
NAKAMURA Takumi d3235e0529 Reformat.
llvm-svn: 211661
2014-06-25 04:34:00 +00:00
Ben Langmuir efb8b6019e Fix test issues from r211623 and remove test-only API
1) missing iterator bits needed by libstdc++4.7
Using find_if was convenient, but since operator++ wasn't a good
interface anyway, I just replaced with a range-based for loop and
removed operator++ from the directory_iterator class.

2) stop relying on order of iterating real files

llvm-svn: 211633
2014-06-24 21:08:13 +00:00
Ben Langmuir c6326a46ea Disable the bits of r211623 that broke the bots
Part of my test seems to rely on iterator bits that I didn't implement,
at least in the gcc bots. Disabling while I investigate.

llvm-svn: 211625
2014-06-24 20:00:30 +00:00
Ben Langmuir 740812bb9a Add directory_iterator for (non-recursive) iteration of VFS directories
The API is based on sys::fs::directory_iterator, but it allows iterating
over overlays and the yaml-based VFS.  For now, it isn't used by
anything (except its tests).

llvm-svn: 211623
2014-06-24 19:37:16 +00:00
Daniel Jasper a2fb50f9b3 clang-format: Understand that breaking before lambdas is fine.
Before:
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa([](
      const aaaaaaaaaa &a) { return a; });

After:
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      [](const aaaaaaaaaa &a) { return a; });

llvm-svn: 211575
2014-06-24 09:15:49 +00:00
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