Commit Graph

1679 Commits

Author SHA1 Message Date
Samuel Benzaquen d93fcc1b28 Fix segfault in hasDeclContext for nodes that have no decl context.
Summary:
Some declarations do not have a declaration context, like TranslationUnitDecl.
Fix hasDeclContext() to not segfault on these nodes.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 220719
2014-10-27 20:58:44 +00:00
Daniel Jasper e068ac77a2 clang-format: Don't break after very short return types.
Before:
  void
  SomeFunction(int parameter);

After:
  void SomeFunction(
      int parameter);

(Unless AlwaysBreakAfterDefinitionReturnType after type is set).

llvm-svn: 220686
2014-10-27 17:13:59 +00:00
Daniel Jasper 5634619389 clang-format: Fix bad merging of lines in nested blocks.
Before:
  SomeFunction([]() {
  #define A a
    return 43; });

After:
  SomeFunction([]() {
  #define A a
    return 43;
  });

llvm-svn: 220684
2014-10-27 16:31:46 +00:00
Daniel Jasper ce2fdb0a0a clang-format: [Proto] Change formatting text-formatted options.
Before:
  optional Type type = 1 [(mutate_options) = {vital : true
                                              abc : false}];

After:
  optional Type type = 1 [(mutate_options) = {
    vital : true
    abc : false
  }];

llvm-svn: 220679
2014-10-27 13:25:59 +00:00
Benjamin Kramer a885796d5f Make VFS and FileManager match the current MemoryBuffer API.
This eliminates converting back and forth between the 3 formats and
gives us a more homogeneous interface.

llvm-svn: 220657
2014-10-26 22:44:13 +00:00
Olivier Goffart df6d7b1564 Fix initializing TypeOfTypeLoc
This fixes a crash in the RecursiveASTVisitor on such code
 __typeof__(struct F*) var[invalid];

The UnderlyingTInfo of a TypeOfTypeLoc was left uninitialized when
created from ASTContext::getTrivialTypeSourceInfo
This lead to a crash in RecursiveASTVisitor when trying to access it.

llvm-svn: 220562
2014-10-24 13:52:55 +00:00
Daniel Jasper f322eb5c45 clang-format: Fix incorrect space after "<".
Before:
  bool a = 2 <::SomeFunction();

After:
  bool a = 2 < ::SomeFunction();

llvm-svn: 220505
2014-10-23 20:22:22 +00:00
Samuel Benzaquen 43dcf2172a Add support for profiling the matchers used.
Summary:
Add support for profiling the matchers used.
This will be connected with clang-tidy to generate a report to determine
and debug slow checks.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 220418
2014-10-22 20:31:05 +00:00
Reid Kleckner 2633341b4a Try to fix link errors in mingw cmake -DBUILD_SHARED_LIBS=ON
llvm-svn: 220417
2014-10-22 20:20:35 +00:00
Reid Kleckner 89bd8d62f3 Reland r219810 "Fix late template parsing leak with incremental processing"
Original message:
Add a second late template parser callback meant to cleanup any
resources allocated by late template parsing.  Call it from the
Sema::ActOnEndOfTranslationUnit method after all pending template
instantiations have been completed.  Teach Parser::ParseTopLevelDecl to
install the cleanup callback when incremental processing is enabled so
that Parser::TemplateIds can be freed.

Patch by Brad King!

llvm-svn: 220400
2014-10-22 17:50:19 +00:00
Daniel Jasper 76284683f1 clang-format: Use AllowShortBlocksOnASingleLine for ObjC blocks, too.
llvm-svn: 220375
2014-10-22 09:12:44 +00:00
Daniel Jasper b52c69e567 clang-format: Fix broken test.
llvm-svn: 220374
2014-10-22 09:01:12 +00:00
Daniel Jasper e8a4939b77 clang-format: Fix incorrect trailing return arrow detection.
Before:
  auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa -> f()) {}

After:
  auto doSomething(Aaaaaa* aaaaaa) -> decltype(aaaaaa->f()) {}

llvm-svn: 220373
2014-10-22 08:42:58 +00:00
Daniel Jasper c0126864a0 clang-format: [Java] Understand string literal concatenation.
Before:
  String someString = "abc" + "cde";

After:
  String someString = "abc"
                      + "cde";

llvm-svn: 220287
2014-10-21 11:34:53 +00:00
Daniel Jasper d78c422378 clang-format: [Java] Fix formatting of multiple annotations.
Before:
  @SuppressWarnings(value = "unchecked")
  @Author(name = "abc") public void doSomething() {
  }

After:
  @SuppressWarnings(value = "unchecked")
  @Author(name = "abc")
  public void doSomething() {
  }

llvm-svn: 220286
2014-10-21 11:17:56 +00:00
Daniel Jasper 5ffcb7fe90 clang-format: [Java] Fix space in generic method calls.
Before:
  A.<B>doSomething();

After:
  A.<B>doSomething();

llvm-svn: 220285
2014-10-21 11:13:31 +00:00
Daniel Jasper fd68191db4 clang-format: [Java] Improve annotation handling.
Before:
@SuppressWarnings(
    value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") public static int iiiiiiiiiiiiiiiiiiiiiiii;

After:
  @SuppressWarnings(value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
  public static int iiiiiiiiiiiiiiiiiiiiiiii;

llvm-svn: 220284
2014-10-21 10:58:14 +00:00
Daniel Jasper c7d024ac53 clang-format: [Java] Make annotation formatting more consistent.
Before:
  DoSomething(new A() {
    @Override public String toString() {
    }
  });

After:
  DoSomething(new A() {
    @Override
    public String toString() {
    }
  });

llvm-svn: 220282
2014-10-21 10:02:03 +00:00
Daniel Jasper 16b107e9f0 clang-format: [Java] Improve generic support.
Before:
  Iterable< ? > a;
  Iterable< ? extends SomeObject > a;

After:
  Iterable<?> a;
  Iterable<? extends SomeObject> a;

llvm-svn: 220281
2014-10-21 09:57:09 +00:00
Daniel Jasper 4bf9d470cb clang-format: [Java] Support extending inner classes.
Before:
  class A extends B
  .C {}

After:
  class A extends B.C {}

llvm-svn: 220280
2014-10-21 09:31:29 +00:00
Daniel Jasper f1f0c35632 clang-format: [Java] Support annotations with parameters.
Before:
  @SuppressWarnings
  (value = "unchecked") public void doSomething() { .. }

After:
  @SuppressWarnings(value = "unchecked")
  public void doSomething() { .. }

llvm-svn: 220279
2014-10-21 09:25:39 +00:00
Daniel Jasper fab69ff095 clang-format: [Java] Wrap after each function annotation.
Before:
  @Override public String toString() { .. }

After:
  @Override
  public String toString() { .. }

llvm-svn: 220274
2014-10-21 08:24:18 +00:00
Daniel Jasper f1f267b447 clang-format: [ObjC] Fix spacing in block variable parameters.
Before:
  { void (^block)(Object * x); }

After:
  { void (^block)(Object *x); }

llvm-svn: 220270
2014-10-21 07:57:50 +00:00
Daniel Jasper 38efc13191 clang-format: Fix space in direct destructor calls.
Before:
  void F(int& i) { i. ~int(); }

After:
  void F(int& i) { i.~int(); }

Also, some cleanups.

llvm-svn: 220269
2014-10-21 07:51:54 +00:00
Daniel Jasper 8835a32078 clang-format: Fix overloaded operator edge case.
Before:
  template <class F>
  void Call(F f) {
    f.template operator() <int>();
  }

After:
  template <class F>
  void Call(F f) {
    f.template operator()<int>();
  }

llvm-svn: 220202
2014-10-20 13:56:30 +00:00
Daniel Jasper 7858079246 clang-format: [ObjC] Fix using selector names as macro arguments.
Before:
  [self aaaaa:MACRO(a, b :, c :)];

After:
  [self aaaaa:MACRO(a, b:, c:)];

llvm-svn: 220197
2014-10-20 12:01:45 +00:00
Daniel Jasper 86296e36d7 clang-format: Fix indentation of struct definitions with array init.
Before:
  struct {
    int x;
    int y;
  } points[] = {
        {1, 2}, {2, 3},
  };

After:
  struct {
    int x;
    int y;
  } points[] = {
      {1, 2}, {2, 3},
  };

llvm-svn: 220195
2014-10-20 11:12:51 +00:00
Daniel Jasper da07a72928 clang-format: Prefer breaking before trailing return arrows.
Before:
  auto SomeFunction(
      A aaaaaaaaaaaaaaaaaaaaa) const -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {}

After:
  auto SomeFunction(A aaaaaaaaaaaaaaaaaaaaa) const
      -> decltype(f(aaaaaaaaaaaaaaaaaaaaa)) {}

llvm-svn: 220043
2014-10-17 14:37:40 +00:00
Daniel Jasper f26c755d42 clang-format: [Java] Don't break immediately after "throws".
Before:
  public void doSooooooooooooooooooooooooooomething() throws
      LooooooooooooooooooooooooooooongException {}

After:
  public void doSooooooooooooooooooooooooooomething()
      throws LooooooooooooooooooooooooooooongException {}

llvm-svn: 220041
2014-10-17 13:36:14 +00:00
Daniel Jasper 1a31bab301 clang-format: Fix behavior with comments before conditional expressions
Before:
  SomeFunction(aaaaaaaaaaaaaaaaa,
               // comment.
                   ccccccccccccccccc ? aaaaaaaaaaaaaaaaaaaa
                                     : bbbbbbbbbbbbbbbbbbbb);

After:
  SomeFunction(aaaaaaaaaaaaaaaaa,
               // comment.
               ccccccccccccccccc ? aaaaaaaaaaaaaaaaaaaa : bbbbbbbbbbbbbbbbbbbb);

llvm-svn: 219921
2014-10-16 09:10:11 +00:00
Daniel Jasper ea772b4df2 clang-format: [ObjC] Fix method expression detection.
Before:
  return (a)[foo bar : baz];

After:
  return (a)[foo bar:baz];

llvm-svn: 219919
2014-10-16 08:38:51 +00:00
Alexey Samsonov d1127d2d1f Avoid having "using namespace" for both "clang" and "llvm" namespaces.
This is fragile, as there are classes with the same name in both
namespaces (e.g. llvm::Module and clang::Module).

llvm-svn: 219855
2014-10-15 22:00:40 +00:00
Reid Kleckner 8178dd362f Revert "Fix late template parsing leak with incremental processing"
This reverts commit r219810.

The test suite appears broken.

llvm-svn: 219813
2014-10-15 17:22:56 +00:00
Reid Kleckner 001fe64333 Fix late template parsing leak with incremental processing
Add a second late template parser callback meant to cleanup any
resources allocated by late template parsing.  Call it from the
Sema::ActOnEndOfTranslationUnit method after all pending template
instantiations have been completed.  Teach Parser::ParseTopLevelDecl to
install the cleanup callback when incremental processing is enabled so
that Parser::TemplateIds can be freed.

Patch by Brad King!

llvm-svn: 219810
2014-10-15 17:08:33 +00:00
Samuel Benzaquen 2009960ea3 Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives.
Summary:
Change r219118 fixed the bug for anyOf and eachOf, but it is still
present for unless.
The variadic wrapper doesn't have enough information to know how to
restrict the type. Different operators handle restrict failures in
different ways.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 219622
2014-10-13 17:38:12 +00:00
Daniel Jasper ec8e838baa clang-format: [ObjC] Wrap ObjC method declarations before annotations.
Before:
  - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x
                                              y:(id<yyyyyyyyyyyyyyyyyyyy>)
                                                    y NS_DESIGNATED_INITIALIZER;
After:
  - (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x
                                              y:(id<yyyyyyyyyyyyyyyyyyyy>)y
      NS_DESIGNATED_INITIALIZER;

llvm-svn: 219564
2014-10-11 08:24:56 +00:00
Samuel Benzaquen b63c251894 Fix completion logic to allow for heterogeneous argument types in matcher overloads.
Summary:
There was an assumption that there were no matchers that were overloaded
on matchers and other types of arguments.
This assumption was broken recently with the addition of new matcher
overloads.

Fixes http://llvm.org/PR21226

Reviewers: pcc

Subscribers: klimek, cfe-commits

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

llvm-svn: 219450
2014-10-09 22:08:52 +00:00
Samuel Benzaquen 96039d727b Special case 0 and 1 matcher in makeAllOfComposite().
Summary:
Remove unnecessary wrapping for the 0 and 1 matcher cases of
makeAllOfComposite(). We don't need a variadic wrapper for those cases.
Refactor TrueMatcher to take advandage of the new conversions between
DynTypedMatcher and Matcher<T>. Also, make it a singleton.
This change improves our clang-tidy related benchmarks by ~12%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 219431
2014-10-09 19:28:18 +00:00
Manuel Klimek 20c1c890b3 Separated RecursiveASTVisitorTest into multiple files.
Patch by Marek Kurdej.

llvm-svn: 219410
2014-10-09 15:02:06 +00:00
Manuel Klimek 7735e40a87 Implement various matchers around template argument handling.
llvm-svn: 219408
2014-10-09 13:06:22 +00:00
Daniel Jasper 18210d7d2f clang-format: Add option to control call argument bin-packing separately
This is desirable for the Chromium style guide:
http://www.chromium.org/developers/coding-style

llvm-svn: 219400
2014-10-09 09:52:05 +00:00
Daniel Jasper 4281c5ae01 clang-format: Fix bug with comments between non-trival parameters.
Before:
  SomeFunction(a, a,
               // comment
                      b + x);

After:
  SomeFunction(a, a,
               // comment
               b + x);

llvm-svn: 219209
2014-10-07 14:45:34 +00:00
Daniel Jasper a45eb4c000 clang-format: If in doubt, assume '+' is a binary operator.
Before:
  #define LENGTH(x, y) (x) - (y)+1

After:
  #define LENGTH(x, y) (x) - (y) + 1

llvm-svn: 219119
2014-10-06 13:16:43 +00:00
Samuel Benzaquen a117002d93 Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives.
Summary:
DynTypedMatcher::constructVariadic() where the restrict kind of the
different matchers are not related causes the matcher to have a "None"
restrict kind. This causes false negatives for anyOf and eachOf.
Change the logic to get a common ancestor if there is one.
Also added regression tests that fail without the fix.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 219118
2014-10-06 13:14:30 +00:00
Fariborz Jahanian 5afc869f96 Adds 'override' to overriding methods. NFC.
These were uncoveredby my yet undelivered patch.

llvm-svn: 218774
2014-10-01 16:56:40 +00:00
Samuel Benzaquen f28d997083 Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.
Summary:
This change introduces DynMatcherInterface and changes the internal
representation of DynTypedMatcher and Matcher<T> to use a generic
interface instead.
It removes unnecessary indirections and virtual function calls when
converting matchers by implicit and dynamic casts.
DynTypedMatcher now remembers the stricter type in the chain of casts
and checks it before calling into DynMatcherInterface.
This change improves our clang-tidy related benchmark by ~14%.
Also, it opens the door for more optimizations of this kind that are
coming in future changes.

As a side effect of removing these template instantiations, it also
speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the
number of
symbols generated by ~30%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 218769
2014-10-01 15:08:07 +00:00
Daniel Jasper 67f8ad258f clang-format: [JS] Support AllowShortFunctionsOnASingleLine.
Specifically, this also counts for stuff like (with style "inline"):
  var x = function() {
    return 1;
  };

llvm-svn: 218689
2014-09-30 17:57:06 +00:00
NAKAMURA Takumi 13f0aeb6ee Revert r218616, "Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts."
MSC17, aka VS2012, cannot compile it.

  clang/include/clang/ASTMatchers/ASTMatchersInternal.h(387) : error C4519: default template arguments are only allowed on a class template

  clang/include/clang/ASTMatchers/ASTMatchersInternal.h(443) : see reference to class template instantiation 'clang::ast_matchers::internal::Matcher<T>' being compiled

llvm-svn: 218648
2014-09-29 23:56:21 +00:00
Samuel Benzaquen ee110341fb Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.
Summary:
This change introduces DynMatcherInterface and changes the internal
representation of DynTypedMatcher and Matcher<T> to use a generic
interface instead.
It removes unnecessary indirections and virtual function calls when
converting matchers by implicit and dynamic casts.
DynTypedMatcher now remembers the stricter type in the chain of casts
and checks it before calling into DynMatcherInterface.
This change improves our clang-tidy related benchmark by ~14%.
Also, it opens the door for more optimizations of this kind that are
coming in future changes.

As a side effect of removing these template instantiations, it also
speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of
symbols generated by ~30%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 218616
2014-09-29 18:43:20 +00:00
Daniel Jasper 91881d99f7 clang-format: Fix GCC warning about implicit bool pointer conversion.
Introduced in r217880.

llvm-svn: 218597
2014-09-29 08:07:46 +00:00
Daniel Jasper 1779d438bc clang-format: [JS] Improve formatting of function literals in chains
Before:
  getSomeLongPromise(.....)
      .then(
           function(value) {
             body();
             body();
           })
      .thenCatch(function(error) {
    body();
    body();
  });

After:
  getSomeLongPromise(.....)
      .then(function(value) {
        body();
        body();
      })
      .thenCatch(function(error) {
        body();
        body();
      });

llvm-svn: 218595
2014-09-29 07:54:54 +00:00
Nico Weber 7533b4dada clang-format: Don't let -style=Chromium imply c++03 template formatting.
Chromium's now using some c++11 language features, so it's now fine that
clang-format produces vector<vector<int>>.

llvm-svn: 218392
2014-09-24 17:17:32 +00:00
Daniel Jasper 3549ea1a73 clang-format: [JS] add space before operator 'in'.
Before:
  return ('aaa')in bbbb;

After:
  return ('aaa') in bbbb;

llvm-svn: 218119
2014-09-19 10:48:15 +00:00
Daniel Jasper 540dbe29bc clang-format: Prevent column layout if elements aren't uniform enough.
This patch only considers the difference between the length of the
shortest and longest element, but we might want to look at other
features (token count, etc.) in future.

Before:
  std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{
      aaaaaaa,      aaaaaaaaaa,
      aaaaa,        aaaaaaaaaaaaaaa,
      aaa,          aaaaaaaaaa,
      a,            aaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa,
      aaaaaaa,      a};

After:
  std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{
      aaaaaaa, aaaaaaaaaa, aaaaa, aaaaaaaaaaaaaaa, aaa, aaaaaaaaaa, a,
      aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa, aaaaaaa, a};

llvm-svn: 218111
2014-09-19 08:28:43 +00:00
Daniel Jasper a41aa536dc clang-format: Undo r216377.
It has proven to not be a food idea in many case.

llvm-svn: 218107
2014-09-19 08:01:25 +00:00
Daniel Jasper b23e20b7f5 clang-format: Allow unbroken ::: in inline assembly.
Before:
  asm volatile("nop" :: : "memory");

After:
  asm volatile("nop" ::: "memory");

Patch by Eugene Toder. Thank you.

llvm-svn: 217883
2014-09-16 16:36:57 +00:00
Daniel Jasper 0085300a24 clang-format: Restructure and add missing tests.
Patch by Jean-Philippe Dufraigne, Thank you!

llvm-svn: 217880
2014-09-16 16:22:30 +00:00
Daniel Jasper c58c70e2f3 clang-format: Basic support for Java.
llvm-svn: 217759
2014-09-15 11:21:46 +00:00
Daniel Jasper ac043c900c clang-format: Add option to break before non-assignment operators.
This will allow:
  int aaaaaaaaaaaaaa =
      bbbbbbbbbbbbbb
      + ccccccccccccccc;

llvm-svn: 217757
2014-09-15 11:11:00 +00:00
Daniel Jasper d6f17d83a3 clang-format: Improve line breaks at function calls.
Before:
  EXPECT_CALL(SomeObject, SomeFunction(Parameter)).Times(2).WillRepeatedly(
      Return(SomeValue));

After:
  EXPECT_CALL(SomeObject, SomeFunction(Parameter))
      .Times(2)
      .WillRepeatedly(Return(SomeValue));

llvm-svn: 217687
2014-09-12 16:35:28 +00:00
Roman Kashitsyn 650ecb53ca Fix bug 20892 - clang-format does not handle C-style comments
Summary:
http://llvm.org/bugs/show_bug.cgi?id=20892

Add support of C-style formatting enabling/disabling directives. Now the following two styles are supported:

  // clang-format on
  /* clang-format on */

The flexibility in comments (support of extra spaces and/or slashes, etc.) is deliberately avoided to simplify search in large code bases.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, curdeius, klimek

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

llvm-svn: 217588
2014-09-11 14:47:20 +00:00
Daniel Jasper b87899b567 clang-format: Add option to allow short case labels on a single line.
On a single line:
  switch (a) {
  case 1: x = 1; return;
  case 2: x = 2; return;
  default: break;
  }

Not on a single line:
  switch (a) {
  case 1:
    x = 1;
    return;
  case 2:
    x = 2;
    return;
  default:
    break;
  }

This partly addresses llvm.org/PR16535. In the long run, we probably want to
lay these out in columns.

llvm-svn: 217501
2014-09-10 13:11:45 +00:00
Benjamin Kramer a2406fa9e5 Revert over-eager unique_ptr conversion.
This test wants to observe PPCallbacks after they have been moved into the
preprocessor. That doesn't work if the pointer has been moved away.

llvm-svn: 217481
2014-09-10 09:35:49 +00:00
Craig Topper b8a7053055 Unique_ptrify PPCallbacks ownership.
Unique_ptr creation stil needs to be moved earlier at some of the call sites.

llvm-svn: 217474
2014-09-10 04:53:53 +00:00
Daniel Jasper 23376259c0 clang-format: [JS] Support regex literals with trailing escaped slash.
Before:
  var regex = / a\//; int i;

After:
  var regex = /a\//;
  int i;

This required pushing the Lexer into its wrapper class and generating a
new one in this specific case. Otherwise, the sequence get lexed as a
//-comment. This is hacky, but I don't know a better way (short of
supporting regex literals in the Lexer).

Pushing the Lexer down seems to make all the call sites simpler.

llvm-svn: 217444
2014-09-09 14:37:39 +00:00
Benjamin Kramer efffbee024 Tooling: Ignore file names in tooling::deduplicate.
This was horribly broken due to how the sort predicate works. We would
report a conflict for files with a replacement in the same position but
different names if the length differed. Just ignore paths as this is often
what the user wants. Files can occur with different names (due to symlinks
or relative paths) and we don't ever want to do the same edit in one file
twice.

llvm-svn: 217439
2014-09-09 13:53:29 +00:00
Daniel Jasper 90ebc98e3d clang-format: [JS] Format embedded function literals more efficently.
Before:
  return {
    a: a,
    link:
        function() {
          f();  //
        },
    link:
        function() {
          f();  //
        }
  };

After:
  return {
    a: a,
    link: function() {
      f();  //
    },
    link: function() {
      f();  //
    }
  };

llvm-svn: 217238
2014-09-05 09:27:38 +00:00
Daniel Jasper 3a038de3c8 clang-format: [JS] JavaScript does not have the */&/&& madness.
Before:
  e&& e.SomeFunction();

After:
  e && e.SomeFunction();

Yeah, this might be useful for C++, too, but it is not such a frequent
pattern there (plus the fix is much harder).

llvm-svn: 217237
2014-09-05 08:53:45 +00:00
Daniel Jasper 3f69ba1075 clang-format: [JS] Better support for empty function literals.
Before:
  SomeFunction(function(){});

After:
  SomeFunction(function() {});

llvm-svn: 217236
2014-09-05 08:42:27 +00:00
Daniel Jasper 97bfb7b1ba clang-format: [JS] Fix indentation in dict literals.
Before:
  return {
    'finish':
        //
        a
        };

After:
  return {
    'finish':
        //
        a
  };

llvm-svn: 217235
2014-09-05 08:29:31 +00:00
Daniel Jasper 4db69bd542 clang-format: [JS] Support alternative operator names as identifiers.
Before:
  not. and . or . not_eq = 1;

After:
  not.and.or.not_eq = 1;

llvm-svn: 217179
2014-09-04 18:23:42 +00:00
Daniel Jasper 8f2e94c8ab clang-format: [JS] Supprot "catch" as function name.
Before:
  someObject.catch ();

After:
  someObject.catch();

llvm-svn: 217158
2014-09-04 15:03:34 +00:00
Daniel Jasper 94e11d02d8 clang-format: [JS] Support comments in dict literals.
Before:
  var stuff = {
    // comment for update
    update : false,
             // comment for update
    modules : false,
              // comment for update
    tasks : false
  };

After:
  var stuff = {
    // comment for update
    update : false,
    // comment for update
    modules : false,
    // comment for update
    tasks : false
  };

llvm-svn: 217157
2014-09-04 14:58:30 +00:00
Manuel Klimek 94ad0bf10d Add matcher for linkage specification
Patch by Jacques Pienaar.

llvm-svn: 217135
2014-09-04 08:51:06 +00:00
Benjamin Kramer 7ab8476c15 ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a template instantiation.
This is hoisted from clang-tidy where it's used everywhere. The implementation
is not particularly efficient right now, but there is no easy fix for that.

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

llvm-svn: 217029
2014-09-03 12:08:14 +00:00
Daniel Jasper db986eb6bb clang-format: Add an option 'SpaceAfterCStyleCast'.
This permits to add a space after closing parenthesis of a C-style cast.
Defaults to false to preserve old behavior.

Fixes llvm.org/PR19982.

Before:
  (int)i;

After:
  (int) i;

Patch by Marek Kurdej.

llvm-svn: 217022
2014-09-03 07:37:29 +00:00
Daniel Jasper 73e171f76d clang-format: Fix unary operator detection in corner case.
Before:
  decltype(* ::std::declval<const T &>()) void F();

After:
  decltype(*::std::declval<const T &>()) void F();

llvm-svn: 216724
2014-08-29 12:54:38 +00:00
David Blaikie 50a5f97e82 unique_ptrify SourceManager::createFileID
llvm-svn: 216715
2014-08-29 07:59:55 +00:00
David Blaikie 49cc3181a2 Overload SourceManager::overrideFileContents so that unconditionally passing ownership is explicitly done using unique_ptr.
Only those callers who are dynamically passing ownership should need the
3 argument form. Those accepting the default ("do pass ownership")
should do so explicitly with a unique_ptr now.

llvm-svn: 216614
2014-08-27 20:54:45 +00:00
Rafael Espindola d87f8d76e0 Update for LLVM api change.
llvm-svn: 216585
2014-08-27 20:03:29 +00:00
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
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