Commit Graph

1324 Commits

Author SHA1 Message Date
Daniel Jasper f9fc215f82 clang-format: Treat a trailing comment like a trailing comma in braced lists.
Before:
  static StructInitInfo module = {MODULE_BUILTIN, /* type */
                                  "streams" /* name */
  };

After:
  static StructInitInfo module = {
      MODULE_BUILTIN, /* type */
      "streams"       /* name */
  };

This fixes llvm.org/PR19378.

llvm-svn: 205851
2014-04-09 13:18:49 +00:00
Daniel Jasper 21397a3232 clang-format: Fix bug where clang-format would break the code.
Before, it would turn:
  SomeFunction([]() { // Cool function..
    return 43;
  });

Into this:
  SomeFunction([]() { // Cool function.. return 43; });

llvm-svn: 205849
2014-04-09 12:21:48 +00:00
Daniel Jasper 3ae6f5a47b clang-format: Improve format of calls with several lambdas.
Before:
  SomeFunction([]() {
                 int i = 42;
                 return i;
               },
               []() {
    int j = 43;
    return j;
  });

After:
  SomeFunction([]() {
                 int i = 42;
                 return i;
               },
               []() {
                 int j = 43;
                 return j;
               });

llvm-svn: 205848
2014-04-09 12:08:39 +00:00
Daniel Jasper f9a0906b98 clang-format: Allow breaking between trailing annotations in more cases.
Before:
  void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(
      aaaaaaaaaaaaaaa);

After:
  void aaaaaaaaaaaaaa(aaaaaaaa aaa) override
      AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa);

llvm-svn: 205846
2014-04-09 10:29:11 +00:00
Daniel Jasper b48d3afcd5 clang-format: Keep more trailing annotations on the same line.
More precisely keep all short annotations (<10 characters) on the same
line if possible. Previously, clang-format would only prefer to do so
for "const", "override" and "final". However, it seems to be generally
preferable, especially because some codebases have to wrap those in
macros for backwards compatibility.

Before:
  void someLongFunction(int someLongParameter)
      OVERRIDE {}

After:
  void someLongFunction(
      int someLongParameter) OVERRIDE {}

This fixes llvm.org/PR19363.

llvm-svn: 205845
2014-04-09 10:01:49 +00:00
Daniel Jasper b175d57edc clang-format: Recognize lists ending in trailing commas correctly.
Previously, this did not look through trailing comments leading to a few
formatting oddities.

llvm-svn: 205843
2014-04-09 09:53:23 +00:00
Daniel Jasper b77105d2ce clang-format: Fix incorrect multi-block-parameter computation.
llvm-svn: 205763
2014-04-08 14:04:31 +00:00
Daniel Jasper 139d4a3875 clang-format: Correctly understand arrays of pointers.
Before:
  A<int * []> a;

After:
  A<int *[]> a;

This fixes llvm.org/PR19360.

llvm-svn: 205761
2014-04-08 13:07:41 +00:00
Daniel Jasper d74cf40386 clang-format: Extend AllowShortFunctions.. to only merge inline functions.
Before AllowShortFunctionsOnASingleLine could either be true, merging
all functions, or false, merging no functions. This patch adds a third
value "Inline", which can be used to only merge short functions defined
inline in a class, i.e.:

  void f() {
    return 42;
  }

  class C {
    void f() { return 42; }
  };

llvm-svn: 205760
2014-04-08 12:46:38 +00:00
Daniel Jasper 922349cdba clang-format: Don't merge simple blocks in case statements.
Before:
  switch (a) {
  case 1: { return 'a'; }
  }

After:
  switch (a) {
  case 1: {
    return 'a';
  }
  }

llvm-svn: 205611
2014-04-04 06:46:23 +00:00
Samuel Benzaquen 5548eadb1c Revert "Add support for named values in the parser."
This was submitted before it was ready.

This reverts commit 62060a01e095cf35eb9ca42a333752d12714f35c.

llvm-svn: 205533
2014-04-03 12:50:47 +00:00
Daniel Jasper 5c33265c9e clang-format: Prefer an additional line-break over hanging indent.
Don't allow the RHS of an operator to be split over multiple
lines unless there is a line-break right after the operator.

Before:
  if (aaaa && bbbbb || // break
                  cccc) {
  }

After:
  if (aaaa &&
      bbbbb || // break
          cccc) {
  }

In most cases, this seems to increase readability.

llvm-svn: 205527
2014-04-03 12:00:33 +00:00
Daniel Jasper cc7bf7fda1 clang-format: Understand that "auto" is a type.
Before:
  MACRO(auto * a);

After:
  MACRO(auto *a);

llvm-svn: 205517
2014-04-03 09:00:49 +00:00
Samuel Benzaquen f10662923a Add matcher for ExprWithCleanups.
Summary: Add matcher for ExprWithCleanups.

Reviewers: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D3248

llvm-svn: 205420
2014-04-02 13:12:14 +00:00
Samuel Benzaquen 2019cea863 Add support for named values in the parser.
Summary:
Add support for named values in the parser.
This allows injection of arbitrary constants using a custom Sema object.
Completions are not supported right now.

Will be used by clang_query to support the 'let' command.
Usage example:
  clang_query> let unique_ptr recordDecl(hasName("unique_ptr"))
  clang_query> match varDecl(hasType(unique_ptr))

Reviewers: klimek, pcc

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D3229

llvm-svn: 205419
2014-04-02 13:11:45 +00:00
David Blaikie abe1a398e3 Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda at ... )')
For namespaces, this is consistent with mangling and GCC's debug info
behavior. For structs, GCC uses <anonymous struct> but we prefer
consistency between all anonymous entities but don't want to confuse
them with template arguments, etc, so we'll just go with parens in all
cases.

llvm-svn: 205398
2014-04-02 05:58:29 +00:00
Aaron Ballman 2b9036d54d Fixing the MSVC 2012 build bot, which cannot do initializer lists yet. Amends r205307.
llvm-svn: 205325
2014-04-01 16:30:35 +00:00
Daniel Jasper e1e4319ab7 clang-format: Support configurable list of foreach-macros.
This fixes llvm.org/PR17242.

Patch by Brian Green, thank you!

llvm-svn: 205307
2014-04-01 12:55:11 +00:00
Daniel Jasper 03b1bc7a2a clang-format: Fix aligning of comments and escaped newlines in macros.
Before:
  #define A      \
    int i;   /*a*/ \
    int jjj; /*b*/

After:
  #define A        \
    int i;   /*a*/ \
    int jjj; /*b*/

llvm-svn: 205011
2014-03-28 15:06:01 +00:00
Daniel Jasper 395193c7a0 clang-format: Recognize more ObjC blocks with parameters/return type.
llvm-svn: 204990
2014-03-28 07:48:59 +00:00
Saleem Abdulrasool 377066a5f5 Use the new Windows environment for target detection
This follows the LLVM change to canonicalise the Windows target triple
spellings.  Rather than treating each Windows environment as a single entity,
the environments are now modelled properly as an environment.  This is a
mechanical change to convert the triple use to reflect that change.

llvm-svn: 204978
2014-03-27 22:50:18 +00:00
Manuel Klimek 1f9d80ac66 Improve handling of bool expressions in template arguments.
Now correctly formats:
  foo<true && false>();

llvm-svn: 204950
2014-03-27 19:00:52 +00:00
Daniel Jasper 5d2587daa2 clang-format: Avoid line-breaks that increase the current column.
While these might make sense for some rule (e.g. break after multi-line
operand), they generally appear ugly and confusing.

Before:
  fffffffffff(R\"x(
  multiline raw string literal xxxxxxxxxxxxxx
  )x\" + bbbbbb)

After:
  fffffffffff(R\"x(
  multiline raw string literal xxxxxxxxxxxxxx
  )x\" +
              bbbbbb)

llvm-svn: 204937
2014-03-27 16:14:13 +00:00
Manuel Klimek f81e5c0e50 Fix bool expression special case.
Clang-format now correctly formats:
  some_type<a * b> v;
  template <bool a, bool b> typename enabled_if<a && b>::type f() {}

llvm-svn: 204913
2014-03-27 11:17:36 +00:00
Daniel Jasper c13ee34378 clang-format: Correctly identify ObjC Block with return type.
llvm-svn: 204905
2014-03-27 09:43:54 +00:00
Manuel Klimek ce68f7714a Fixes a bug in DynTypedNode.
Two DynTypedNodes can be equal if they do not have the same node type,
because DynTypedNodes for the same underlying object might have been
created from different types (for example, Decl vs VarDecl).

llvm-svn: 204722
2014-03-25 14:39:26 +00:00
Daniel Jasper a65e887587 clang-format: Fix incorrect &/* detection.
Before:
  STATIC_ASSERT((a &b) == 0);

After:
  STATIC_ASSERT((a & b) == 0);

llvm-svn: 204709
2014-03-25 10:52:45 +00:00
Daniel Jasper a26fc5c9db clang-format: Add flag for removing empty lines at the start of blocks.
This unbreaks polly-formatting-tests and we can make a decision for
LLVM style independently.

llvm-svn: 204467
2014-03-21 13:43:14 +00:00
Daniel Jasper 01b35482e5 clang-format: Don't remove empty lines at the start of namespaces.
llvm-svn: 204462
2014-03-21 13:03:33 +00:00
Daniel Jasper 11164bdaf5 clang-format: Remove empty lines at the beginning of blocks.
They very rarely aid readability.

Formatting:
  void f() {

    if (a) {

      f();

    }

  }

Now leads to:
  void f() {
    if (a) {
      f();
    }
  }

llvm-svn: 204460
2014-03-21 12:58:53 +00:00
Daniel Jasper a125d53a7b clang-format: Let a trailing comma in braced lists enforce linebreaks.
Before:
  vector<int> x{1, 2, 3, 4, };

After:
  vector<int> x{
      1, 2, 3, 4,
  };

This fixes llvm.org/PR18519.

llvm-svn: 204458
2014-03-21 12:38:57 +00:00
Daniel Jasper 28df0a356e clang-format: Fix for r204456.
llvm-svn: 204457
2014-03-21 12:15:40 +00:00
Daniel Jasper 14e58e5290 clang-format: Preserve meaning of trailing comments on parameters.
Formatting:
  SomeFunction(a,
            b, // comment
            c);

Before:
  SomeFunction(a, b, // comment
               c);

After:
  SomeFunction(a,
               b, // comment
               c);

llvm-svn: 204456
2014-03-21 11:58:45 +00:00
Argyrios Kyrtzidis a9ab4d46bb [libclang] Introduce clang_VirtualFileOverlay_setCaseSensitivity that exposes the VFS option
to set the case-sensitivity for lookups.

rdar://16374696

llvm-svn: 204303
2014-03-20 04:51:48 +00:00
Alexander Kornienko ce08126733 clang-format: Detect function-like macros only when upper case is used.
Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D3110

llvm-svn: 204156
2014-03-18 14:35:20 +00:00
Manuel Klimek 819788da83 Fix crasher bug.
Due to not resetting the fake rparen data on the token when iterating
over annotated lines, we would pop the last element of the paren stack.

This patch fixes the underlying root cause, and makes the code more
robust against similar problems in the future:
- reset the first token when iterating on the same annotated lines due
  to preprocessor branches
- never pop the last element from the paren stack, so we do not crash,
  but rather incorrectly format
- add assert()s so we can figure out if our assumptions are violated

llvm-svn: 204140
2014-03-18 11:22:45 +00:00
Daniel Jasper 1fd6f1f8d6 clang-format: Indent from dict literal labels.
Before:
  @{
    NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
    regularFont,
  };

After:
  @{
    NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
        regularFont,
  };

llvm-svn: 204041
2014-03-17 14:32:47 +00:00
NAKAMURA Takumi 7ebbda83a2 ASTTests//EvaluateAsRValueTest.cpp: Appease *-win32 target to add -fno-delayed-template-parsing.
llvm-svn: 203991
2014-03-15 00:36:51 +00:00
James Dennett 622831b739 Change a raw string literal back to C++98 style to fix freeBSD9.2 builtbot
llvm-svn: 203961
2014-03-14 20:08:11 +00:00
James Dennett 0492ef0e0b Fix a crash (assertion failure) in EvaluateAsRValue.
Summary:
Gracefully fail to evaluate a constant expression if its type is
unknown, rather than failing an assertion trying to access the type.

Reviewers: klimek

Reviewed By: klimek

CC: chandlerc, cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3075

llvm-svn: 203950
2014-03-14 17:44:10 +00:00
Daniel Jasper ac7e34e778 clang-format: Prevent ObjC code from confusing the braced-init detection
This was leading to bad formatting, e.g.:
Before:
  f(^{
      @autoreleasepool {
        if (a) {
          g();
  }
  }
  });

After:
  f(^{
      @autoreleasepool {
        if (a) {
          g();
        }
      }
  });

llvm-svn: 203777
2014-03-13 10:11:17 +00:00
Hans Wennborg 501eadb429 Check for LLVM_ON_WIN32 instead of _WIN32.
This is a follow-up to r203624 to address Anton's comment.

llvm-svn: 203668
2014-03-12 16:07:46 +00:00
Daniel Jasper da353cd5f1 clang-format: Fix crasher.
Caused by unknown tokens (e.g. "\n") not properly updating the state.

Example:
  const char* c = STRINGIFY(
  \na : b);

llvm-svn: 203645
2014-03-12 08:24:47 +00:00
Daniel Jasper 8f59ae537c clang-format: Avoid unnecessary break before lambda return type.
Before:
  auto aaaaaaaa = [](int i,  // break
                     int j)
                      -> int {
    return fffffffffffffffffffffffffffffffffffffff(i * j);
  };

After:
  auto aaaaaaaa = [](int i,  // break
                     int j) -> int {
    return fffffffffffffffffffffffffffffffffffffff(i * j);
  };

llvm-svn: 203562
2014-03-11 11:03:26 +00:00
Daniel Jasper a58dd5db29 clang-format: Fix another false positive in the lambda detection.
Before:
  int i = (*b)[a] -> f();

After:
  int i = (*b)[a]->f();

llvm-svn: 203557
2014-03-11 10:03:33 +00:00
Daniel Jasper d3c7ab975f clang-format: Fix incorrect lambda recognition exposed by r203452.
Before:
  int i = a[a][a] -> f();

After:
  int i = a[a][a]->f();

llvm-svn: 203556
2014-03-11 09:59:36 +00:00
Daniel Jasper c580af96fa clang-format: Detect weird macro lambda usage.
Before:
  void f() {
    MACRO((const AA & a) { return 1; });
  }

After:
  void f() {
    MACRO((const AA &a) { return 1; });
  }

llvm-svn: 203551
2014-03-11 09:29:46 +00:00
David Blaikie 0e18ed2eba Fix use of uninitialized variable in ExternalASTSourceTest.cpp (introduced in 203525)
llvm-svn: 203545
2014-03-11 06:49:26 +00:00
Richard Smith 023d2ca451 Add a unittest for the ExternalASTSource.
llvm-svn: 203525
2014-03-11 01:18:47 +00:00
Samuel Benzaquen a083935d0a Add loc() to the dynamic registry.
Summary:
Add loc() to the dynamic registry.
Other fixes:
 - Fix the polymorphic variant value to accept an exact match, even if
   there are other possible conversions.
 - Fix specifiesTypeLoc() to not crash on an empty
   NestedNameSpecifierLoc.

Reviewers: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2928

llvm-svn: 203467
2014-03-10 15:40:23 +00:00
Daniel Jasper 84a12e18d3 clang-format: Add spaces between lambdas and comments.
Before:
  void f() {
    bar([]() {}// Does not respect SpacesBeforeTrailingComments
        );
  }

After:
  void f() {
    bar([]() {} // Does not respect SpacesBeforeTrailingComments
        );
  }

This fixes llvm.org/PR19017.

llvm-svn: 203466
2014-03-10 15:06:25 +00:00
Alexander Kornienko 4504f93901 Preserve hanging indent when breaking line comments.
Summary:
If we need to break the second line here:
// something: aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa aaaaa aaaaaa aaaaa aaaaa aaaaa

with the patch it will be turned to

// something: aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa

instead of

// something: aaaaa aaaaa aaaaaa aaaaa aaaaa
//            aaaaa aaaaa aaaaaa aaaaa aaaaa
// aaaaa

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2988

llvm-svn: 203458
2014-03-10 13:14:56 +00:00
Daniel Jasper 81a20787db clang-format: Add spaces around trailing/lambda return types.
Before:
  int c = []()->int { return 2; }();

After:
  int c = []() -> int { return 2; }();

llvm-svn: 203452
2014-03-10 10:02:02 +00:00
Richard Smith 664b32b814 Revert accidentally-committed file.
llvm-svn: 203318
2014-03-08 00:04:19 +00:00
Richard Smith 9bca298f6d Module [extern_c] attribute: inherit to submodules, don't write 'extern "C"'
blocks when building in C mode, and serialize and deserialize the attribute.

llvm-svn: 203317
2014-03-08 00:03:56 +00:00
Ahmed Charles b89843299a Replace OwningPtr with std::unique_ptr.
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.

llvm-svn: 203279
2014-03-07 20:03:18 +00:00
Ahmed Charles d72a5f103d Replace OwningPtr::isValid() with conversion to bool.
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203277
2014-03-07 19:51:06 +00:00
Ahmed Charles 9a16beb8bc Change OwningPtr::take() to OwningPtr::release().
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203275
2014-03-07 19:33:25 +00:00
Alexander Kornienko 86b2dfdc3b Fix operator<< recognition (PR19064).
llvm-svn: 203123
2014-03-06 15:13:08 +00:00
Ben Langmuir 9385323747 Attempt to re-enable the VFS unittests on Windows
Using a //net/ path to hopefully avoid problems with non-absolute paths
on Windows.

llvm-svn: 203010
2014-03-05 21:32:20 +00:00
NAKAMURA Takumi 6a927ecb7a Disable BasicTests/VFS on win32 for now. Investigating.
Failing Tests (5):
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.CaseInsensitive
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.MappedFiles
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.MultiComponentPath
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.TrailingSlashes
    Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.UseExternalName

llvm-svn: 202952
2014-03-05 09:10:04 +00:00
David Majnemer 197e2103a2 Speculatively fix MSVC buildbots
llvm-svn: 202938
2014-03-05 06:32:38 +00:00
Chandler Carruth 757fcd6d1f [cleanup] Re-sort includes with llvm/utils/sort_includes.py and fix
a missing include from CLog.h.

CLog.h referenced most of the core libclang types but never directly
included Index.h that provides them. Previously it got lucky and other
headers were always included first but with the sorting it ended up
first in one case and stopped compiling. Adding the Index.h include
fixes it right up.

llvm-svn: 202810
2014-03-04 10:05:20 +00:00
Dmitri Gribenko 5ea34fcc8d Decl printing: add tests for typedefs
Patch by Konrad Kleine.

llvm-svn: 202709
2014-03-03 13:21:00 +00:00
Peter Collingbourne f93725459a MSVC 2012 doesn't support std::initializer_list at all, so don't rely on
that std::vector constructor.

llvm-svn: 202684
2014-03-03 08:13:06 +00:00
Peter Collingbourne 2bbb029599 MSVC cannot understand temporaries formed from initializer lists.
llvm-svn: 202682
2014-03-03 07:49:35 +00:00
Argyrios Kyrtzidis d502a10c5e [libclang] Introduce APIs that assist in constructing a simple module.map file for a user framework.
rdar://16092858

llvm-svn: 202681
2014-03-03 07:41:45 +00:00
Argyrios Kyrtzidis 74c96c0c75 [libclang] Change clang_VirtualFileOverlay_writeToBuffer to return a malloc'ed buffer.
Returning CXString is not appropriate if we want to switch to a non-string format buffer.

llvm-svn: 202675
2014-03-03 06:38:52 +00:00
Peter Collingbourne c0423b349b Disable all dependency output options when using the Tooling library.
It isn't appropriate for a tool to be stomping over the dependency files,
especially if the actual build uses a compiler other than Clang or the tool
cannot find all the headers for some reason (which would cause the existing
dependency file to be deleted).

If a tool actually needs to care about dependency files we can think about
adding a mechanism for getting to this information.

Differential Revision: http://llvm-reviews.chandlerc.com/D2912

llvm-svn: 202669
2014-03-02 23:37:26 +00:00
Chandler Carruth f8b7266d57 [C++11] Switch the clang-format LLVM style to use C++11 style braced
init list formatting. This suggestion has now gone into the LLVM coding
standards, and is particularly relevant now that we're using C++11.

Updated a really ridiculous number of tests to reflect this change.

llvm-svn: 202637
2014-03-02 12:37:31 +00:00
Craig Topper a798a9db93 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202625
2014-03-02 09:32:10 +00:00
Ben Langmuir d066d4c849 Reapply fixed "Honour 'use-external-names' in FileManager"
Was r202442

There were two issues with the original patch that have now been fixed.
1. We were memset'ing over a FileEntry in a test case. After adding a
   std::string to FileEntry, this still happened to not break for me.
2. I didn't pass the FileManager into the new compiler instance in
   compileModule. This was hidden in some cases by the fact I didn't
   clear the module cache in the test.

Also, I changed the copy constructor for FileEntry, which was memcpy'ing
in a (now) unsafe way.

llvm-svn: 202539
2014-02-28 21:16:07 +00:00
Ben Langmuir 1b8d44f59b Revert "Honour 'use-external-names' in FileManager"
Revert r202442, which broke the buildbots.

llvm-svn: 202443
2014-02-27 23:48:03 +00:00
Ben Langmuir 09e0d5c1bb Honour 'use-external-names' in FileManager
Pass through the externally-visible names that we got from the VFS down
to FileManager, and test that this is the name showing up in __FILE__,
diagnostics, and debug information.

llvm-svn: 202442
2014-02-27 23:27:54 +00:00
Ben Langmuir b59cf679e8 Add a 'use-external-names' option to VFS overlay files
When true, sets the name of the file to be the name from
'external-contents'. Otherwise, you get the virtual path that the file
was looked up by. This will not affect any non-virtual paths, or fully
virtual paths (for which there is no reasonable 'external' name anyway).

The setting is available globally, but can be overriden on a per-file
basis.

The goal is that this setting will control which path you see in debug
info, diagnostics, etc. which are sensitive to which path is used. That
will come in future patches that pass the name through to FileManager.

llvm-svn: 202329
2014-02-27 00:25:12 +00:00
Benjamin Kramer 594802f744 Add a StmtPrinter test for implicit and explicit conversion operator calls.
Put back a comment that I removed too aggressively.

llvm-svn: 202255
2014-02-26 10:23:43 +00:00
Benjamin Kramer 2907b08219 Pretty Printer: Print constexpr and ref qualifiers. Don't print return types on destructors.
llvm-svn: 202181
2014-02-25 18:49:49 +00:00
Benjamin Kramer 00e8a1915a Reapply "Pretty Printer: Fix printing of conversion operator decls and calls."
There were many additional tests that had the bad behavior baked in.

llvm-svn: 202174
2014-02-25 18:03:55 +00:00
Ben Langmuir 47ff9ab1be Allow multi-component paths in VFS file nodes
This allows the 'name' field to contain a path, like

{ 'type': 'directory',
  'name': '/path/to/dir',
  'contents': [ ... ] }

which not only simplifies reading and writing these files (for humans),
but makes it possible to easily modify locations via textual
replacement, which would not have worked in the old scheme.

E.g. sed s:<ROOT>:<NEW ROOT>

llvm-svn: 202109
2014-02-25 04:34:14 +00:00
Argyrios Kyrtzidis 0b9682efa4 [libclang] Introduce libclang APIs for creating a buffer with a JSON virtual file overlay description.
The current API only supports adding 'virtual file path' -> 'real file path' mappings.

rdar://15986708

llvm-svn: 202105
2014-02-25 03:59:23 +00:00
Ben Langmuir 509fe8fd63 Improve some gtest assertions
As requested during review, compare pointers to NULL explicitly to make what's
going on more clear.

llvm-svn: 202090
2014-02-24 23:44:17 +00:00
Ben Langmuir 97882e7b7f Pass through context for DiagHandler in VFS
This allows the unit tests to not use global state when checking
diagnostics.

llvm-svn: 202072
2014-02-24 20:56:37 +00:00
Dmitri Gribenko 51c1b55bc2 ASTMatchers: added CXXMethodDecl matcher isPure()
The isPure() CXXMethodDecl matcher matches pure method declaration like "A::x"
in this example:

class A {
  virtual void x() = 0;
}

Patch by Konrad Kleine.

llvm-svn: 202012
2014-02-24 09:27:46 +00:00
Peter Collingbourne b8d17e7a3b Correctly set brace range for CXXConstructExprs formed by list initialization.
Differential Revision: http://llvm-reviews.chandlerc.com/D2711

llvm-svn: 201926
2014-02-22 02:59:41 +00:00
Ben Langmuir d51ba0b39f Add a VFSFromYAML class and a parser to create it
Provides a way to create a virtual file system using a YAML file that
supports mapping a file to a path on an 'external' file system. The
external file system will typically be the 'real' file system, but for
testing it can be changed.

A future patch will add a clang option to allow the user to specify such
a file and overlay it, but for now this code is only exercised by the
unit tests.

Differential Revision: http://llvm-reviews.chandlerc.com/D2835

llvm-svn: 201905
2014-02-21 23:39:37 +00:00
Ben Langmuir c8130a74f4 Recommit virtual file system
Previously reverted in r201755 due to causing an assertion failure.

I've removed the offending assertion, and taught the CompilerInstance to
create a default virtual file system inside createFileManager. In the
future, we should be able to reach into the CompilerInvocation to
customize this behaviour without breaking clients that don't care.

llvm-svn: 201818
2014-02-20 21:59:23 +00:00
Peter Collingbourne 564597fd26 Add TemplateSpecializationType polymorphism for hasTemplateArgument and
hasAnyTemplateArgument, and (out of necessity) an isExpr matcher.

Also updates the TemplateArgument doxygen to reflect reality for
non-canonical template arguments.

Differential Revision: http://llvm-reviews.chandlerc.com/D2810

llvm-svn: 201804
2014-02-20 19:18:03 +00:00
Juergen Ributzka a32575e4f6 Reverting the virtual file system implementation, because it triggers an assertion
in our internal build bots.

This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696.

llvm-svn: 201755
2014-02-20 05:24:58 +00:00
Ben Langmuir ac7a74a836 Fix some test issues in VirtualFileSystemTest
Use camel-case names, remove some dead code, and fix a copy-and-pasted test.

llvm-svn: 201691
2014-02-19 15:58:49 +00:00
Dmitri Gribenko 8850cdad34 libclang: ensure clang_createTranslationUnit2 always initializes *TU
llvm-svn: 201657
2014-02-19 10:24:00 +00:00
Ben Langmuir 6f95efb683 Attempt to appease C++11 buildbots
Explicit operator bool doesn't not play nicely with gtest assertion
macros (i.e. it performs as advertised and I wish that gtest subverted
it for me).

llvm-svn: 201639
2014-02-19 04:17:47 +00:00
Ben Langmuir 87ba87bc4d Add an OverlayFileSystem class
Provides a way to merge multiple vfs::FileSystem objects into a single
filesystem.

llvm-svn: 201635
2014-02-19 03:29:17 +00:00
Ben Langmuir 090610d37a Initial implementation of virtual file system
This adds the minimum virtual file system support to start migrating
FileManager onto the VFS.

Originally discussed here:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html

Differential Revision: http://llvm-reviews.chandlerc.com/D2745

llvm-svn: 201618
2014-02-19 00:10:30 +00:00
Dmitri Gribenko f85b929211 Add files that I forgot to svn add in 201578.
llvm-svn: 201579
2014-02-18 15:29:17 +00:00
Dmitri Gribenko 1bf8d9107b libclang: fix a bug in processing invalid arguments, introduced in r201249
Recommit r201346, reverted in r201373.

llvm-svn: 201578
2014-02-18 15:20:02 +00:00
Daniel Jasper 5550de684f clang-format: Don't wrap "const" etc. of function declarations.
Generally people seem to prefer wrapping the first function parameter
over wrapping the trailing tokens "const", "override" and "final". This
does not extend to function-like annotations and probably not to other
non-standard annotations.

Before:
  void someLongFunction(int SomeLongParameter)
      const { ... }

After:
  void someLongFunction(
      int SomeLongParameter) const { ... }

llvm-svn: 201504
2014-02-17 07:57:46 +00:00
NAKAMURA Takumi 7d2da0b2ae clang/unittests/AST,ASTMatchers: Remove _MSC_VER.
llvm-svn: 201485
2014-02-16 10:16:09 +00:00
David Blaikie 8972f4e966 Consistently print anonymous namespace names as "<anonymous namespace>"
For some reason we have two bits of code handling this printing:

lib/AST/Decl.cpp:        OS << "<anonymous namespace>";
lib/AST/TypePrinter.cpp:      OS << "<anonymous namespace>::";

it would be nice if we only had one...

llvm-svn: 201437
2014-02-14 22:12:54 +00:00
Daniel Jasper 3a122c029d clang-format: Fix formatting of class template declaration.
Before:
  template <class R, class C>
  struct Aaaaaaaaaaaaaaaaa<R (C::*)(int)
                           const> : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};

After:
  template <class R, class C>
  struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const>
      : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};

llvm-svn: 201424
2014-02-14 18:22:40 +00:00
Juergen Ributzka d59364086f Revert "[CMake] Disable libclangTests.exe on win32 for now."
Because I also reverted the original commit that required this change.

llvm-svn: 201374
2014-02-13 23:51:55 +00:00