Commit Graph

1480 Commits

Author SHA1 Message Date
Samuel Benzaquen 8e7f99647d Add isDeleted() matcher for FunctionDecl nodes.
Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 215714
2014-08-15 14:20:59 +00:00
Daniel Jasper ea79ea1627 clang-format: Prefer breaking after return type over template param
Before:
  typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa aaaaaaaaaa<
      aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bool *aaaaaaaaaaaaaaaaaa,
                                                   bool *aa) {}

After:
  typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa
  aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}

llvm-svn: 215693
2014-08-15 05:00:39 +00:00
Daniel Jasper 497d9fdcf8 clang-format: [proto] Understand text-format nesting without :
Before:
  option (MyProto.options) = {
    field_c : "OK" msg_field{field_d : 123}
  };

After:
  option (MyProto.options) = {
    field_c : "OK"
    msg_field{field_d : 123}
  };

(Note that the colon after "msg_field" is optional).

llvm-svn: 215692
2014-08-15 05:00:35 +00:00
Alexander Kornienko c6221a58ec Split a large unit-test, so that it doesn't exceed stack frame size in certain test environments
llvm-svn: 215639
2014-08-14 13:07:35 +00:00
Daniel Jasper db76479d73 clang-format: Fix AlwaysBreakAfterDefinitionReturnType in Stroutrup style
Before:
  template <class T>
  T *f(T &c)  // Problem here: no line break before f
  {
    return NULL;
  }

After:
  template <class T>
  T *
  f(T &c)
  {
    return NULL;
  }

Patch by Marek Kurdej, thank you!

llvm-svn: 215633
2014-08-14 11:36:03 +00:00
Daniel Jasper 1904e9b98d clang-format: Support chained dereferenced assignments.
Before:
  x = * a(x) = *a(y);

After:
  x = *a(x) = *a(y);

llvm-svn: 215632
2014-08-14 10:53:19 +00:00
Daniel Jasper 78b4533acf clang-format: Support breaking arguments of function type typedefs.
Before:
  typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(
      const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  typedef size_t (*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(
      const aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
          aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 215631
2014-08-14 10:52:56 +00:00
Benjamin Kramer 2f5db8b3db Header guard canonicalization, clang part.
Modifications made by clang-tidy with minor tweaks.

llvm-svn: 215557
2014-08-13 16:25:19 +00:00
Manuel Klimek 5f594f80f4 Fix crasher bug in clang-format.
llvm-svn: 215549
2014-08-13 14:00:41 +00:00
Daniel Jasper 839922e9d1 clang-format: Format long lists in columns if without bin-packing.
After (even with BinPacking = false):
  const Aaaaaa aaaaa = {
      aaaaa,  bbbbb,  ccccc,  ddddd,  eeeee,  ffffff, ggggg, hhhhhh,
      iiiiii, jjjjjj, kkkkkk, aaaaa,  bbbbb,  ccccc,  ddddd, eeeee,
      ffffff, ggggg,  hhhhhh, iiiiii, jjjjjj, kkkkkk,
  };

Before:
  <each element on its own line>

This fixes http://llvm.org/PR20623.

llvm-svn: 215529
2014-08-13 08:46:21 +00:00
Daniel Jasper 343643b979 clang-format: Understand #defines defining system includes.
Before:
  #define MY_IMPORT < a / b >

After:
  #define MY_IMPORT <a/b>

llvm-svn: 215527
2014-08-13 08:29:18 +00:00
Samuel Benzaquen 646f23b809 Support named values in the autocomplete feature.
Summary:
This includes:
 - Passing a Sema to completeExpression to allow for named values in the
   expression.
 - Passing a map of names to values to the parser.
 - Update the Sema interface to include completion for matchers.
 - Change the parser to use the Sema for completion, instead of going
   directly to Registry.

Reviewers: pcc

Subscribers: klimek, cfe-commits

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

llvm-svn: 215472
2014-08-12 21:11:37 +00:00
Daniel Jasper 598dd330e8 clang-format: Avoid bad line break.
Before:
  int
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(const
                                typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa);

After:
  int aaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      const typename aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa);

llvm-svn: 215442
2014-08-12 13:22:26 +00:00
David Blaikie 23430ccb04 unique_ptr-ify FileSystemStatCache::setNextStatCache
And in the process, discover that FileManager::removeStatCache had a
double-delete when removing an element from the middle of the list (at
the beginning or the end of the list, there was no problem) and add a
unit test to exercise the code path (which successfully crashed when run
(with modifications to match the old API) without this patch applied)

llvm-svn: 215388
2014-08-11 21:29:24 +00:00
Roman Kashitsyn a043cedf0a Fixes bug 20587 - Add K&R break before braces style
Summary:
http://llvm.org/bugs/show_bug.cgi?id=20587

Added K&R style. It could be enabled by the following option:

```
BreakBeforeBraces: KernighanRitchie
```

This style is like `Attach`, but break *only* before function
declarations.

As I can see, no additional logic required to support this style, any
style different from other styles automagically satisfies K&R.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 215354
2014-08-11 12:18:01 +00:00
David Blaikie 6beb6aa8f0 Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)
After post-commit review and community discussion, this seems like a
reasonable direction to continue, making ownership semantics explicit in
the source using the type system.

llvm-svn: 215323
2014-08-10 19:56:51 +00:00
Benjamin Kramer 12152ab92e Add missing header guards.
llvm-svn: 215202
2014-08-08 13:24:19 +00:00
Daniel Jasper a5621202c4 clang-format: Prefer not to put lambdas on a single line.
Before:
  string abc =
      SomeFunction(aaaaaaaaaaaaa, aaaaa,
                   []() { SomeOtherFunctioooooooooooooooooooooooooon(); });

After:
  string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {
    SomeOtherFunctioooooooooooooooooooooooooon();
  });

llvm-svn: 215197
2014-08-08 12:00:13 +00:00
NAKAMURA Takumi fb8654a881 [CMake] Upate libdeps in FrontendTests corresponding to r215145.
llvm-svn: 215177
2014-08-08 01:26:23 +00:00
Benjamin Kramer 88d99e4f42 Flip the order the preprocessor and frontendaction are informed of the end of a file.
This allows using EndOfMainFile from a PPCallback to access data from the
action. The pattern of PPCallback referencing an action is common in clang-tidy.

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

llvm-svn: 215145
2014-08-07 20:51:16 +00:00
Daniel Jasper 78b1949950 clang-format: Correct SBPO_Always-behavior after function-like keywords
Before:
  auto f (int x) -> decltype(x) { return sizeof(x); }
  int g () noexcept(someCall ());
  static_assert(sizeof(char) == 1, "Your compiler is broken");

After:
  auto f (int x) -> decltype (x) { return sizeof (x); }
  int g () noexcept (someCall ());
  static_assert (sizeof (char) == 1, "Your compiler is broken");

This fixes llvm.org/PR20559.
Patch by Roman Kashitsyn, thank you!

llvm-svn: 214969
2014-08-06 14:15:41 +00:00
Daniel Jasper 4718944399 clang-format: Add special comments to disable formatting.
With this patch:
  int ThisWillBeFormatted;
  // clang-format off
  int   ThisWontBeFormatted;
  // clang-format on
  int Formatted;

This is for regions where a significantly nicer code layout can be found
knowing the content of the code.

This fixes llvm.org/PR20463.

llvm-svn: 214966
2014-08-06 13:40:26 +00:00
Daniel Jasper 316ab38ed8 clang-format: Fix indentation in multi-line placement new.
Before:
  auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
      typename aaaaaaaaaaaaaaaaaaaaaaaa();

After:
  auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
          typename aaaaaaaaaaaaaaaaaaaaaaaa();

llvm-svn: 214964
2014-08-06 13:14:58 +00:00
Chad Rosier 0a84f17882 [PR19983] SBPO_Always not covering all the cases.
Patch by "Roman Kashitsyn" <romankashicin@gmail.com>.
Phabricator revision: http://reviews.llvm.org/D4788

llvm-svn: 214904
2014-08-05 17:58:54 +00:00
NAKAMURA Takumi 360927923f ASTMatchersTests/matchesConditionallyWithCuda: Add -fno-ms-extensions, and get rid of initializer list.
I am not sure whether -xcuda might imply -fno-ms-extensions.

llvm-svn: 214876
2014-08-05 15:54:43 +00:00
Daniel Jasper ca4ea1ce59 clang-format: Add option to always break after a function's return type.
This is required for GNU coding style, among others.

Also update the configuration documentation.

Modified from an original patch by Jarkko Hietaniemi, thank you!

llvm-svn: 214858
2014-08-05 12:16:31 +00:00
Daniel Jasper d9670878d4 clang-format: Break before 'else' in Stroustrup style.
Seems to be the desired thing to do according to:
  http://www.stroustrup.com/Programming/PPP-style-rev3.pdf

Patch by Jarkko Hietaniemi, thank you!

llvm-svn: 214857
2014-08-05 12:06:20 +00:00
Manuel Klimek d52a3b8897 Adds AST matchers for matching CUDA declarations.
Patch by Jacques Pienaar.

llvm-svn: 214852
2014-08-05 09:45:53 +00:00
Daniel Jasper 65df5aa918 clang-format: Understand parameter pack initialization.
Before:
  Constructor(A... a) : a_(X<A> { std::forward<A>(a) }...) {}

After:
  Constructor(A... a) : a_(X<A>{std::forward<A>(a)}...) {}

llvm-svn: 214720
2014-08-04 14:51:02 +00:00
Daniel Jasper dcf37fbec5 clang-format: Add a space in ObjC protocols.
Before:
  @interface Foo (HackStuff)<MyProtocol>

After:
  @interface Foo (HackStuff) <MyProtocol>

llvm-svn: 214508
2014-08-01 13:03:05 +00:00
Fariborz Jahanian a1db7df243 Obective-C. Patch to fix the incorrect ObjcMessageExpr argument source ranges,
when arguments are structures or classes. PR16392.
patch by Karlis Senko

llvm-svn: 214409
2014-07-31 17:39:50 +00:00
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