Commit Graph

1499 Commits

Author SHA1 Message Date
Daniel Jasper 168c8aa679 clang-format: Fix regression in formatting of braced initializers.
Before:
  Node n{1, Node{1000}, //
                2};

After:
  Node n{1, Node{1000}, //
         2};

llvm-svn: 216540
2014-08-27 11:53:26 +00:00
NAKAMURA Takumi fba9bb7b6e ClangCodeGenTests: Prune redundant libdeps.
llvm-svn: 216516
2014-08-27 01:50:11 +00:00
NAKAMURA Takumi a3f12d3850 [CMake] ClangCodeGenTests: Add Core. It's referenced by the test.
llvm-svn: 216515
2014-08-27 01:50:00 +00:00
NAKAMURA Takumi 2c002043e0 ClangCodeGenTests: Reorder libdeps.
llvm-svn: 216514
2014-08-27 01:49:49 +00:00
NAKAMURA Takumi fe02fb67af ClangCodeGenTests: Quick fix to USEDLIBS. clangCodeGen requires, at least, AST, Basic, Frontend, and Lex.
llvm-svn: 216509
2014-08-27 00:58:19 +00:00
Julien Lerouge 23ea50eee4 Fix missing component.
llvm-svn: 216506
2014-08-27 00:33:21 +00:00
Daniel Jasper 8f46365481 clang-format: Don't butcher __asm blocks.
Instead completely cop out of formatting them for now.

This fixes llvm.org/PR20618.

llvm-svn: 216501
2014-08-26 23:15:12 +00:00
Keno Fischer 7d4f2cebdf Attempt to address cmake buildbot failure
CMake gets confused by the fact that both LLVM and Clang now have
a CodeGen unittest. Rename the target to avoid that. The new test
was also missing ProfileData (thanks to Julien Lerouge for
pointing that out)

llvm-svn: 216499
2014-08-26 22:50:03 +00:00
Keno Fischer 84778b2a1c Don't segfault in EmitCXXGlobalInitFunc when main file is a membuf
Summary: When the main file is created from a membuffer, there is no file entry that can be retrieved. This uses "__GLOBAL_I_a" in that case which is what was always used before r208128.

Reviewers: majnemer, thakis

Reviewed By: thakis

Subscribers: yaron.keren, rsmith, cfe-commits

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

llvm-svn: 216495
2014-08-26 22:10:15 +00:00
Aaron Ballman d71a5c7277 Switching from std::vector to llvm::ArrayRef per post-commit review suggestion.
llvm-svn: 216463
2014-08-26 17:05:57 +00:00
Aaron Ballman cc7f4aa2a7 Some versions of MSVC do not support initializer list construction of vectors, so this fixes a broken build from r216385.
llvm-svn: 216457
2014-08-26 14:17:25 +00:00
Daniel Jasper ad981f888a clang-format: New option SpacesInSquareBrackets.
Before:
  int a[5];
  a[3] += 42;

After:
  int a[ 5 ];
  a[ 3 ] += 42;

Fixes LLVM bug #17887 (http://llvm.org/bugs/show_bug.cgi?id=17887).

Patch by Marek Kurdej, thank you!

llvm-svn: 216449
2014-08-26 11:41:14 +00:00
Daniel Jasper 610381ff07 clang-format: Improve handling of block comments in braced lists.
Before:
  std::vector<int> v = {
      1, 0 /* comment */
  };

After:
  std::vector<int> v = {1, 0 /* comment */};

llvm-svn: 216445
2014-08-26 09:37:52 +00:00
Will Dietz dff50cbe26 ASTVector: Fix return value of various insert() methods.
Error caught using -fsanitize=pointer-overflow.

Expand ASTVectorTest to verify basic behavior,
test fails without functionality in this patch.

llvm-svn: 216385
2014-08-25 16:09:51 +00:00
Manuel Klimek 3fe8a38110 Add hasAttr matcher for declarations.
Delete special-case CUDA attribute matchers.

Patch by Jacques Pienaar.

llvm-svn: 216379
2014-08-25 11:23:50 +00:00
Daniel Jasper 4b3ba214d0 clang-format: Understand sequenced casts.
This fixed llvm.org/PR20712.

Before:
  int i = (int)(int) -2;

After:
  int i = (int)(int)-2;

llvm-svn: 216378
2014-08-25 09:36:07 +00:00
Daniel Jasper 7189fb2cf9 clang-format: Improve formatting of nested builder-type calls.
Before:
  f(FirstToken->WhitespaceRange.getBegin().getLocWithOffset(
      First->LastNewlineOffset));

After:
  f(FirstToken->WhitespaceRange.getBegin()
        .getLocWithOffset(First->LastNewlineOffset));

llvm-svn: 216377
2014-08-25 08:48:17 +00:00
Rafael Espindola 91ac8dfa9d Create a std::unique_ptr earlier.
Thanks to David Blaikie for the suggestion.

llvm-svn: 215865
2014-08-17 23:27:13 +00:00
Rafael Espindola 04ab21d75d Convert a few ownership comments with std::unique_ptr.
llvm-svn: 215853
2014-08-17 22:12:58 +00:00
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