Commit Graph

2123 Commits

Author SHA1 Message Date
Daniel Jasper 362a1bfcff clang-format: Lower penalty for breaking between array subscripts.
Before:
  aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)][bbbbbbbbbbb(
      bbbbbbbbbbbb)]

After:
  aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)]
                           [bbbbbbbbbbb(bbbbbbbbbbbb)]

llvm-svn: 256343
2015-12-23 18:01:43 +00:00
Daniel Jasper 95516cd380 clang-format: Fix incorrect pointer detection.
Before:
  return * this += 1;

After:
  return *this += 1;

llvm-svn: 256342
2015-12-23 18:01:29 +00:00
Samuel Benzaquen bd3232af03 [ASTMatchers] Add booleanType() matcher.
llvm-svn: 256278
2015-12-22 20:06:40 +00:00
Daniel Jasper b542f9f144 clang-format: [JS] Support arrays of object-type literals.
Before:
  interface I {
    o: {}
    [];
  }

After:
  interface I {
    o: {}[];
  }

llvm-svn: 256247
2015-12-22 15:48:35 +00:00
Daniel Jasper e2deb59fa3 clang-format: [JS] Conservatively introduce column layout for JS array
initializers. For now, only use it for 20 items or more. Otherwise,
clang-format formats these one-per-line and thus increases the vertical
code size a lot.

llvm-svn: 256246
2015-12-22 15:48:15 +00:00
Daniel Jasper 72a1b6a5f2 clang-format: [JS] "operator" is not a keyword in Java/JavaScript.
llvm-svn: 256245
2015-12-22 15:47:56 +00:00
Daniel Jasper eb65e912aa clang-format: Properly set the BlockKind for more blocks.
Before:
  void f() { struct Dummy { };
    f();
  }

After:
  void f() {
    struct Dummy {};
    f();
  }

llvm-svn: 256175
2015-12-21 18:31:15 +00:00
Daniel Jasper a252f5d56d clang-format: Only consider the first #include that looks right to be
the main #include.

llvm-svn: 256170
2015-12-21 17:28:24 +00:00
Daniel Jasper 41a2bf74ed clang-format: [JS] Change Google-style default for aligning operands.
The style guide allows both, but apparently, this is the more dominant use.

llvm-svn: 256154
2015-12-21 13:52:19 +00:00
Daniel Jasper 32d75fa293 clang-format: Only try to find the "main" include in the first block of
includes.

llvm-svn: 256153
2015-12-21 13:40:49 +00:00
Daniel Jasper 0bfdeb4b6d clang-format: Extend detection of the "main" #include to use the filename
Before, the first (non-system) header in a file was considered to be
the main include. This is conservative as it makes clang-format change
the #include order less often. Instead implement some basic usage of
the filename itself. With this patch, clang-format considers every
header to be a main include if the header file's basename is a prefix
to the filename the #include is in.

llvm-svn: 256148
2015-12-21 12:14:17 +00:00
Zachary Turner 6bc7f97f56 Fix invalid enum comparison.
llvm-svn: 256055
2015-12-18 22:58:42 +00:00
Zachary Turner 448592eeac Support AlwaysBreakAfterReturnType
This changes the behavior of AlwaysBreakAfterDeclarationReturnType
so that it supports breaking after declarations, definitions, or
both.

Differential Revision: http://reviews.llvm.org/D10370
Reviewed By: Daniel Jasper

llvm-svn: 256046
2015-12-18 22:20:15 +00:00
Richard Trieu 031406fab0 Add a test for r255875 & r255929, comparisons on DynTypeNode wrapped QualType.
llvm-svn: 255937
2015-12-17 23:20:57 +00:00
Daniel Jasper d2629dc812 clang-format: Extend header sort category implementation.
Specifically, it is sometimes necessary to keep certain #includes as
the first #include, even before the main #include for a .cc file.
Switching the category to be signed instead of unsigned isn't ideal,
but it seems as good of an option as any and is fully backwards
compatible.

llvm-svn: 255757
2015-12-16 10:10:16 +00:00
Gabor Horvath 009c5d52e3 Add a new matcher to match character types.
llvm-svn: 255627
2015-12-15 08:35:45 +00:00
Daniel Jasper 870d1bcdf9 clang-format: Add test for AlignAfterOpenBracket = AlwaysBreak in C++.
Revision 251405 added AlwaysBreak to support Google's JavaScript style. This
changeset complete existing AlignsAfterOpenBracket tests to exercise
AlwaysBreak for C++.

I thought this would be worthwhile.  With this option we can support request
from http://lists.llvm.org/pipermail/cfe-dev/2015-May/042942.html, that had
been requested a few times. This also partially solve related Bug 23422 and is
probably sufficient for most people.

  AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
  BinPackArguments = false;
  BinPackParameters = false;

With these setting we obtain this formatting:

  void fooWithAVeryLongParamList(
      int firstParameter,
      int secondParameter
      int lastParameter)
  {
      object.alsoThisDoenstFitSoIBreakImmidiatly(
          firstParameter,
          secondParameter,
          lastParameter);
  }

Patch by Jean-Philippe Dufraigne, thank you.

llvm-svn: 255486
2015-12-14 08:41:18 +00:00
Daniel Jasper 96cbb502b7 clang-format: Extend Linux-brace-wrapping test.
llvm-svn: 255485
2015-12-14 08:33:07 +00:00
Ben Langmuir f13302e63f [VFS] Fix status() of opened redirected file
Make RedirectedFileSystem::openFilForRead(path)->status() the same as
RedirectedFileSystem::status(path). Previously we would just get the
status of the underlying real file, which would not have the IsVFSMapped
bit set.

This fixes rebuilding a module that has an include that is relative to
the includer where we will lookup the real path of that file before we
lookup the VFS location.

rdar://problem/23640339

llvm-svn: 255312
2015-12-10 23:41:39 +00:00
Daniel Jasper f901a57cda clang-format: Make wrapping after "./->" cheaper, even if the element
before it is not a closing parenthesis.

Otherwise, this frequently leads to "hanging" indents that users
perceive as "weird".

Before:
  return !soooooooooooooome_map.insert(
                                   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
              .second;

After:
  return !soooooooooooooome_map
              .insert(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
              .second;

llvm-svn: 254933
2015-12-07 19:50:48 +00:00
Chris Bieneman 24423e9d03 [CMake] Don't build the libclang tests unless you're building libclang
This fixes a build issue reported by users at Apple.

llvm-svn: 254797
2015-12-04 23:12:19 +00:00
Aaron Ballman a60bcdab92 Add a narrowing AST matcher that matches on a FunctionDecl with a non-throwing exception specification.
llvm-svn: 254516
2015-12-02 15:23:59 +00:00
Daniel Jasper c8f472c3a6 Traverse the NestedNameSpecifier(Loc) of NamespaceAliasDecls.
Review: http://reviews.llvm.org/D15149
llvm-svn: 254510
2015-12-02 13:57:46 +00:00
Benjamin Kramer 5fecd67462 Avoid picking up system headers in unittest by providing a fake libstdc++ with a ridiculously high version number.
The host libstdc++ may be horribly broken and we want the fake one to be
picked up. This workaround is lame but I don't see a better way.

llvm-svn: 254446
2015-12-01 19:42:07 +00:00
Daniel Jasper a0a5039d2e clang-format: Make it possible to turn off comment reflowing.
llvm-svn: 254414
2015-12-01 13:28:53 +00:00
Daniel Jasper a00de6366a clang-format: treat Q_SIGNALS as an access modifier
Patch by Alexander Richardson, thank you!

llvm-svn: 254407
2015-12-01 12:05:04 +00:00
Daniel Jasper ec90e51c79 This fixes https://llvm.org/bugs/show_bug.cgi?id=25329, as well as
misalignments like the following:

  int a, b = 2;
  int c    = 3;

Patch by Beren Minor, thanks!

llvm-svn: 254406
2015-12-01 12:00:43 +00:00
Samuel Antao e5113bce6c Add --gcc-toolchain= to one of the libclang unitests to fix issue related to
the gcc libraries clang picks for when it was configures with a user defined 
path.

llvm-svn: 254306
2015-11-30 17:26:28 +00:00
Daniel Jasper 8e8b4fb678 clang-format: Re-add code path deleted in r253873 and add missing test.
llvm-svn: 253900
2015-11-23 19:11:45 +00:00
Aaron Ballman 6290fc9154 Add an AST matcher for narrowing when a type is volatile-qualified.
llvm-svn: 253882
2015-11-23 17:09:24 +00:00
Daniel Jasper 9bb3001d53 clang-format: Fix incorrect cast detection.
Before:
  bool b = f(g<int>)&&c;

After:
  bool b = f(g<int>) && c;

llvm-svn: 253872
2015-11-23 15:55:50 +00:00
Daniel Jasper 253dad2323 clang-format: If the template list of a variable declaration spans
multiple lines, also break before the variable name.

Before:
  std::vector<aaaaaa, // wrap
              aa> aaa;

After:
  std::vector<aaaaaa, // wrap
              aa>
      aaa;

llvm-svn: 253871
2015-11-23 15:55:45 +00:00
Daniel Jasper b68aabf7fc clang-format: Make moving of the Cursor work properly when sorting #includes.
llvm-svn: 253860
2015-11-23 08:36:35 +00:00
Daniel Jasper 3fed94525c Fix calculation of shifted cursor/code positions. Specifically support
the case where a specific range is replaced by new text. Previously,
the calculation would shift any position from within a replaced region
to the first character after the region. This is undersirable, e.g. for
clang-format's include sorting.

llvm-svn: 253859
2015-11-23 08:33:48 +00:00
Daniel Jasper 9b8c7c72f5 clang-format: Make sorting includes respect // clang-format off
llvm-svn: 253772
2015-11-21 09:17:08 +00:00
Daniel Jasper 71e574543f clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"
work properly.

llvm-svn: 253674
2015-11-20 16:44:28 +00:00
Daniel Jasper f95b1f4546 clang-format: [JS] Properly add a space after "in" in for loops.
llvm-svn: 253672
2015-11-20 16:18:42 +00:00
Daniel Jasper 09840efd92 clang-format: [JS] struct and union aren't keywords / reserved words.
llvm-svn: 253671
2015-11-20 15:58:50 +00:00
Daniel Jasper 7fa524b4b8 clang-format: Don't use incorrect space in macro calls with operators.
Before:
  MACRO(> );

After:
  MACRO(>);

Not overly important, but easy and good for symmetry reasons :-).

llvm-svn: 253669
2015-11-20 15:26:50 +00:00
Daniel Jasper d8d9839ae6 clang-format: [Proto] Support extending message.
Before:
  extend.foo.Bar {
  }

After:
  extend .foo.Bar {
  }

llvm-svn: 253667
2015-11-20 14:32:54 +00:00
Aaron Ballman f08e184815 Removing the AST matcher test for thread_local storage duration. Not all platforms support TLS, and on platforms that do not support it, use of thread_local causes an error. Since there's no way to determine whether the testing platform supports TLS, there's no way to know whether the test is safe to run or not. I will explore ways to enable this test, but this will appease at least one more build bot.
llvm-svn: 253486
2015-11-18 18:37:29 +00:00
Aaron Ballman 8e7f00b0eb Re-committing r253473 after hopefully fixing the bot breakage. There was a copy-pasta issue that my local testing did not catch.
llvm-svn: 253481
2015-11-18 17:56:55 +00:00
Aaron Ballman 81d17f2f7e Reverting r253473 while I investigate build bot failures.
llvm-svn: 253475
2015-11-18 17:16:01 +00:00
Aaron Ballman 34e0bd40e4 Adding AST matchers for VarDecl storage durations. Can now determine whether a VarDecl has automatic, static, or thread storage duration. This also updates the documentation for matchers, which appear to be missing some previous additions.
llvm-svn: 253473
2015-11-18 17:05:39 +00:00
Benjamin Kramer c02670ed50 [libclang] Add entry points that take a full command line including argv[0].
This provides both a more uniform interface and makes libclang behave like
clang tooling wrt relative paths against argv[0]. This is necessary for
finding paths to a c++ standard library relative to a clang binary given
in a compilation database. It can also be used to find paths relative to
libclang.so if the full path to it is passed in.

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

llvm-svn: 253466
2015-11-18 16:14:27 +00:00
Artem Belevich 8601733c1c [CUDA] Make CUDA compilation usable by default.
Currently clang requires several additional command
line options in order to enable new features needed
during CUDA compilation. This patch makes these
options default.

* Automatically include cuda_runtime.h if we've found
  a valid CUDA installation.
* Disable automatic CUDA header inclusion during unit tests.
* Added test case for command line construction.
* Enabled target overloads and relaxed call checks that are
  needed in order to include CUDA headers.
* Added CUDA-7.5 installation path to the CUDA installation search list.
* Define __CUDA__ macro to indicate CUDA compilation.

llvm-svn: 253389
2015-11-17 22:28:55 +00:00
Daniel Jasper da44677082 clang-format: Enable #include sorting by default.
This has seen quite some usage and I am not aware of any issues. Also
add a style option to enable/disable include sorting. The existing
command line flag can from now on be used to override whatever is set
in the style.

llvm-svn: 253202
2015-11-16 12:38:56 +00:00
Alexander Kornienko 4f35532dbe Adjust printQualifiedName to handle unscoped enums in a way similar to anonymous namespaces.
Patch by Sterling Augustine!

Differential revision: http://reviews.llvm.org/D14459

llvm-svn: 252488
2015-11-09 16:45:17 +00:00
Alexander Kornienko 857b10f471 Make ArgumentAdjuster aware of the current file being processed.
Summary:
This is needed to handle per-project configurations when adding extra
arguments in clang-tidy for example.

Reviewers: klimek, djasper

Subscribers: djasper, cfe-commits, klimek

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

llvm-svn: 252134
2015-11-05 02:19:53 +00:00
Alexander Kornienko e39993eb86 Make hasLHS and hasRHS matchers available for ArraySubscriptExpr
Summary:
The hasBase and hasIndex don't tell anything about the position of the
base and the index in the code, so we need hasLHS and hasRHS in some cases.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 251842
2015-11-02 22:23:21 +00:00