Commit Graph

2290 Commits

Author SHA1 Message Date
Daniel Jasper b618a98582 clang-format: Make AlignAfterOpenBracket also affect angle brackets.
Patch by Matthew Whitehead, thank you.

llvm-svn: 259487
2016-02-02 10:28:11 +00:00
Nico Weber c097337493 Always build a new TypeSourceInfo for function templates with parameters
RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and
`DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's
ParmVarDecls.

For a function template that doesn't have parameters that explicitly depend on
the template parameter, we used to be clever and not build a new
TypeSourceInfo. That meant that when an instantiation of such a template is
visited, its TypeSourceInfo would point to the ParmVarDecls of the template,
not of the instantiation, which then confused clients of RecursiveASTVisitor.

So don't be clever for function templates that have parameters, even if none of
the parameters depend on the type.

Fixes PR26257.
http://reviews.llvm.org/D16478

llvm-svn: 259428
2016-02-01 22:31:51 +00:00
Aaron Ballman 7e7b7b2def Reapply r259210 with a fix for RegistryTest.cpp.
Patch by Richard Thomson.

llvm-svn: 259359
2016-02-01 14:11:47 +00:00
Daniel Jasper d27df3dd3d clang-format: Fix incorrect pointer detection in lambdas in constructor
initializers.

Before:
  Constructor() : member([](A *a, B * b) {}) {}

After:
  Constructor() : member([](A *a, B *b) {}) {}

llvm-svn: 259353
2016-02-01 11:21:07 +00:00
Daniel Jasper e1a7b76338 clang-format: Add option to disable string literal formatting.
llvm-svn: 259352
2016-02-01 11:21:02 +00:00
Daniel Jasper bb37a2f6f3 clang-format: Fix alignment of trailing multiline columns.
llvm-svn: 259351
2016-02-01 11:20:55 +00:00
Daniel Jasper 1ce41112a4 clang-format: [JS] Treat "in" as a proper operator.
llvm-svn: 259350
2016-02-01 11:20:47 +00:00
Hans Wennborg 2b79910d8b Revert r259210 "Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes."
It didn't pass check-clang.

llvm-svn: 259218
2016-01-29 18:24:34 +00:00
Aaron Ballman fb9d0e354d Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes.
Patch by Richard Thomson

llvm-svn: 259210
2016-01-29 17:03:11 +00:00
Benjamin Kramer 987a1d21e7 Add an optional ToolName argument to runToolOnCodeWithArgs/buildASTFromCodeWithArgs.
This can be used as a way to modify argv[0] for a clang tool.

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

llvm-svn: 259187
2016-01-29 11:29:02 +00:00
Nico Weber 7b837f578a Include RecordDecls from anonymous unions in the AST.
For

  void f() {
    union { int i; };
  }

clang used to omit the RecordDecl from the anonymous union from the AST.
That's because the code creating it only called PushOnScopeChains(), which adds
it to the current DeclContext, which here is the function's DeclContext. But
RecursiveASTVisitor doesn't descent into all decls in a FunctionDecl.

Instead, for DeclContexts that contain statements, return the RecordDecl so
that it can be included in the DeclStmt containing the VarDecl for the union.

Interesting bits from the AST before this change:

|-FunctionDecl
| `-CompoundStmt
|   |-DeclStmt
|   | `-VarDecl 0x589cd60 <col:3> col:3 implicit used 'union (anonymous at test.cc:3:3)' callinit

After this change:

-FunctionDecl
| `-CompoundStmt
|   |-DeclStmt
|   | |-CXXRecordDecl 0x4612e48 <col:3, col:18> col:3 union definition
|   | | |-FieldDecl 0x4612f70 <col:11, col:15> col:15 referenced i 'int'
|   | `-VarDecl 0x4613010 <col:3> col:3 implicit used 'union (anonymous at test.cc:3:3)' callinit

This is now closer to how anonymous struct and unions are represented as
members of structs.  It also enabled deleting some one-off code in the
template instantiation code.

Finally, it fixes a crash with ASTMatchers, see the included test case
(this fixes http://crbug.com/580749).

llvm-svn: 259079
2016-01-28 19:25:00 +00:00
Daniel Jasper 15b01116d9 clang-format: [Java] Remove unnecessary line break after complex annotations
Before:
  @Annotation("Some"
      + " text")
  List<Integer>
      list;

After:
  @Annotation("Some"
      + " text")
  List<Integer> list;

llvm-svn: 258981
2016-01-27 20:14:23 +00:00
Chris Bieneman 2bf68c6c1c Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

    "This is the way [autoconf] ends
    Not with a bang but a whimper."
    -T.S. Eliot

Reviewers: chandlerc, grosbach, bob.wilson, echristo

Subscribers: klimek, cfe-commits

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

llvm-svn: 258862
2016-01-26 21:30:40 +00:00
Eugene Zelenko 1660a5d298 Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes.
Differential revision: http://reviews.llvm.org/D16567

llvm-svn: 258836
2016-01-26 19:01:06 +00:00
Aaron Ballman 31bde8762e Add am AST matcher for isMoveAssignmentOperator.
Patch by Jonathan Coe.

llvm-svn: 258573
2016-01-22 22:37:09 +00:00
Nico Weber c4acee3380 Let RecursiveASTVisitor visit array index VarDecls
An implicit copy ctor creates loop VarDecls that hang off CXXCtorInitializer.
RecursiveASTVisitor used to not visit them, so that they didn't show up in the
parent map used by ASTMatchers, causing asserts() when the implicit
DeclRefExpr() in a CXXCtorInitializer referred to one of these VarDecls.

Fixes PR26227.
http://reviews.llvm.org/D16413

llvm-svn: 258503
2016-01-22 15:11:54 +00:00
Nico Weber 5fe4122348 Replace some tabs with spaces.
llvm-svn: 258500
2016-01-22 14:12:44 +00:00
Nico Weber a415a1d0d7 Add an isVirtualAsWritten AST matcher.
http://reviews.llvm.org/D16394

llvm-svn: 258415
2016-01-21 17:56:24 +00:00
Aaron Ballman 2b6963fce9 Add AST matcher support for FunctionDecls with the hasBody matcher.
Patch by Aleksei Sidorin.

llvm-svn: 258322
2016-01-20 16:26:48 +00:00
Aaron Ballman e8295d7980 Add AST matcher for paren expressions.
Patch by Adrian Zgorzałek.

llvm-svn: 258321
2016-01-20 16:17:39 +00:00
Manuel Klimek 27f278186d Fix formatting of fully qualified names in array subscripts.
Before:
  a[ :🅱️:c];

After:
  a[:🅱️:c];

llvm-svn: 258123
2016-01-19 14:05:32 +00:00
Aaron Ballman 9e373df2f7 The destructor name should be matched to ~Foo instead of Foo.
llvm-svn: 258077
2016-01-18 20:47:02 +00:00
Aaron Ballman eb85b04c7e Add an AST matcher for checking whether a function is defaulted.
Patch by Jonathan Coe.

llvm-svn: 258072
2016-01-18 20:37:44 +00:00
Aaron Ballman d7b18b9f2f Augments r258042; changes the AST matcher tests to use matchesNot and EXPECT_TRUE instead of EXPECT_FALSE. Adds a matcher test to ensure that static member functions are properly handled. Generates the documentation from the matcher.
llvm-svn: 258070
2016-01-18 20:28:57 +00:00
Manuel Klimek ce28f9ebd3 Add forEachArgumentWithParam AST matcher.
The new matcher allows users to provide a matcher for both the argument
of a CallExpr/CxxConstructExpr a well as the ParmVarDecl of the
argument.

Patch by Felix Berger.

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

llvm-svn: 258042
2016-01-18 11:20:09 +00:00
Daniel Jasper a3cd216483 clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.
Before:
  aaaa[bbbb]
      .cccc();

After:
  aaaa[bbbb].cccc();

llvm-svn: 257763
2016-01-14 13:36:46 +00:00
Daniel Jasper 11a876533e clang-format: [JS] Fix incorrect line break leading to semicolon insertion.
clang-format only works for JavaScript code, if all the semicolons are
present anyway, so this linebreak can never be desired.

Before (with appropriate statement lengths or column limit):
  return
      [ aaa ];

After:
  return [
    aaaa
  ];

llvm-svn: 257741
2016-01-14 05:37:52 +00:00
Daniel Jasper 50780ce110 clang-format: [ObjC+JS] Allow bin-packing of array literals.
After reading the style guides again, they don't actually say how to
pack or not pack array literals. Based on some user reports, array
initializers can unnecessarily get quite long if they contain many
small elements. Array literals with trailing commas are still formatted
one per line so that users have a way to opt out of the packing.

Before:
  var array = [
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa,
    aaaaaa
  ];

After:
  var array = [
    aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa, aaaaaa,
    aaaaaa, aaaaaa
  ];

llvm-svn: 257615
2016-01-13 16:41:34 +00:00
Aaron Ballman 580ccaf827 Properly track the end location of an exception specification.
Patch by Adrian Zgorzałek

llvm-svn: 257521
2016-01-12 21:04:22 +00:00
Daniel Jasper 8620d4c55b clang-format: [JS] Support exporting abstract classes.
Before:
  export abstract class X {y: number;}
(and all sorts of other havoc in more complicated cases).

After:
  export abstract class X { y: number; }

llvm-svn: 257451
2016-01-12 06:24:38 +00:00
Daniel Jasper f55e418247 clang-format: [JS] Teach clang-format about "export interface".
llvm-svn: 257406
2016-01-11 22:57:40 +00:00
Benjamin Kramer dab50463d0 [clang-format] Fix comment aligning when there are changes within the comment
As soon as a comment had whitespace changes inside of the token, we
couldn't identify the whole comment as a trailing comment anymore and
alignment stopped working. Add a new boolean to Change for this special
case and fix trailing comment identification to use it.

This also changes WhitespaceManager to sum the length of all Changes
inside of a token into the first Change.

Before this fix

  int xy;  // a
  int z;   //b

became

  int xy;  // a
  int z;  // b

with this patch we immediately get to:

  int xy;  // a
  int z;   // b

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

llvm-svn: 257341
2016-01-11 16:27:16 +00:00
Daniel Jasper df51f2e634 clang-format: Fix overloading "operator," definitions more thoroughly.
Before:
  aaaaaaaaaaaaaaaaaaaaaa operator,(aaaaaaaaaaaaaaaaaaaaa &
                                   aaaaaaaaaaaaaaaaaaaaaaaaaa) const;
After:
  aaaaaaaaaaaaaaaaaaaaaa operator,(
      aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaaaaaaaaaaaaaaaaaaa) const;

llvm-svn: 257330
2016-01-11 12:55:33 +00:00
Daniel Jasper 06ca0fc69d clang-format: Slightly row back on r257257.
r257257 change the way clang-format enforces line breaks after a
templated type has been line-wrapped. This was to fix an incorrect line
break if BinPackParameters is set to false. However, it also leads to
an unwanted line break in a different case. Thus, for now, only do this
when BinPackParameters is false. This isn't ideal yet, but helps us
until we have a better solution.

With BinPackParameters:
Before:
  void fffffffffff(aaaaaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaa,
                                               aaaaaaaaaa> aaaaaaaaaa);

After:
  void fffffffffff(
      aaaaaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaa>
          aaaaaaaaaa);

llvm-svn: 257325
2016-01-11 11:01:05 +00:00
Daniel Jasper 2802456097 clang-format: [JS] Improve line-flow when calling functions on array literals.
Before:
  return [
    aaaaaaaaaaaaaaaaaaaaaa
  ].aaaaaaa(function() {
     //
   })
   .bbbbbb();

After:
  return [aaaaaaaaaaaaaaaaaaaaaa]
      .aaaaaaa(function() {
	//
      })
      .bbbbbb();

llvm-svn: 257324
2016-01-11 11:00:58 +00:00
Benjamin Kramer 2a23e55803 Simplify test code with initializer lists.
No functional change intended.

llvm-svn: 257287
2016-01-10 10:45:19 +00:00
Benjamin Kramer 730338b6a3 Make test work on windows by turning \ in paths back into /.
llvm-svn: 257286
2016-01-10 10:36:59 +00:00
Daniel Jasper e1f72a6727 clang-format: Fix the counting of leading whitespace in tok::unknown tokens
Previously, all whitespace characters would increase the starting
column, which doesn't make sense. This fixes a problem, e.g. with the
length calculation in JS template strings.

llvm-svn: 257267
2016-01-09 21:12:45 +00:00
Benjamin Kramer e9e7607974 [vfs] Normalize working directory if requested.
FixedCompilationDatabase sets the working dir to "." by default. For
chdir(".") this is a noop but this lead to InMemoryFileSystem to create
bogus paths. Fixes PR25327.

llvm-svn: 257260
2016-01-09 16:33:16 +00:00
Daniel Jasper 417fc81540 clang-format: Improve selective comment formatting.
Starting here:
  int x; // Format this line only.
  int xx; //
  int xxxxx; //

Before:
  int x;     // Format this line only.
  int xx; //
  int xxxxx; //

After:
  int x;  // Format this line only.
  int xx; //
  int xxxxx; //

llvm-svn: 257258
2016-01-09 15:56:53 +00:00
Daniel Jasper 00693b08cf clang-format: Fix incorrect line break in certain configurations.
Before:
  void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                          vector<int>
                              bbbbbbbbbbbbbbb);

After:
  void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                          vector<int> bbbbbbbbbbbbbbb);

llvm-svn: 257257
2016-01-09 15:56:47 +00:00
Daniel Jasper 804a276fcf clang-format: Support definitions/declarations of operator,.
Before:
  bool operator, ();

After:
  bool operator,();

llvm-svn: 257256
2016-01-09 15:56:40 +00:00
Daniel Jasper b9a4990a9c clang-format: [JS] Support semicolons in TypeScript's TypeMemberLists.
Before:
  var x: {
    a: string;
    b: number;
  }
  = {};

After:
  var x: {a: string; b: number;} = {};

llvm-svn: 257255
2016-01-09 15:56:28 +00:00
Daniel Jasper f412e26d04 clang-format: [JS] Prefer wrapping before the TypeScript return type
over wrapping before parameters.

Before:
  function someFunc(
      args: string[]): {longReturnValue: string[]} {}

After:
  function someFunc(args: string[]):
      {longReturnValue: string[]} {}

llvm-svn: 257162
2016-01-08 10:51:24 +00:00
Daniel Jasper d196abbba3 clang-format: [JS] Add some Closure Compiler JSDoc tags to the default
Google configuration so that they aren't line-wrapped.

llvm-svn: 257159
2016-01-08 08:14:58 +00:00
Daniel Jasper d5ec65ba33 clang-format: [JS] Support more ES6 classes.
Before:
  foo = class {
      constructor() {}
  }
  ;

After:
  foo = class {
      constructor() {}
  };

llvm-svn: 257154
2016-01-08 07:06:07 +00:00
Daniel Jasper 7bec87c998 clang-format: Fix corner case in one-per-line formatting.
Before (example is JS, but also applies to C++):
  return [
    aaaa()
        .bbbbbbbb('A'),
    aaaa().bbbbbbbb('B'),
    aaaa().bbbbbbbb('C'),
  ];

After:
  return [
    aaaa().bbbbbbbb('A'),
    aaaa().bbbbbbbb('B'),
    aaaa().bbbbbbbb('C'),
  ];

llvm-svn: 257079
2016-01-07 18:11:54 +00:00
Daniel Jasper 54353dac75 clang-format: Support weird lambda macros.
Before:
  MACRO((AA & a) { return 1; });

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

llvm-svn: 257062
2016-01-07 14:36:11 +00:00
Daniel Jasper efc1a83a99 clang-format: [JS] Support more ES6 imports.
Before:
  import a, {X, Y}
  from 'some/module.js';

After:
  import a, {X, Y} from 'some/module.js';

llvm-svn: 257038
2016-01-07 08:53:35 +00:00
Daniel Jasper 411af72e8c clang-format: Fix corner case in "if it saves columns"-calculation.
Before:
  aaaa
      .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
	  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
      .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
	  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
      .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 256841
2016-01-05 16:10:39 +00:00
Daniel Jasper 0a589416e8 clang-format: Handle \n the same way as std::endl with stream operator.
clang-format breaks multi-line streams after std::endl.
It now also break for '\n', the suggested replacement for std::endl:

  http://llvm.org/docs/CodingStandards.html#avoid-std-endl

Before:
  llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n' << bbbbbbbbbbbbbbbbbbbbbb
               << '\n';
  llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n" << bbbb
               << "bbbbbbbbbbbbbbbbbb\n";

After:
  llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n'
               << bbbbbbbbbbbbbbbbbbbbbb << '\n';
  llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n"
               << bbbb << "bbbbbbbbbbbbbbbbbb\n";

This changeset ensure that multiline streams have a line break after:
  - std::endl
  - '\n'
  - "\n"
  - "Some Text\n"

Patch by Jean-Philippe Dufraigne, thank you.

llvm-svn: 256832
2016-01-05 13:06:27 +00:00
Daniel Jasper 801cdb27e4 clang-format: Avoid creating hanging indents in call sequences.
Before:
  aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaa(
                      aaaaaaaaaaaaaaaaaaaa)
        .aaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  aaaaaaaaaaaaaaaa
        .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa)
        .aaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 256831
2016-01-05 13:03:59 +00:00
Daniel Jasper 00492f96bf clang-format: Improve line wrapping behavior in call sequences.
r256750 has been leading to an undesired behavior:

  aaaaaaaaaa
      .aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

This change increases penalty for wrapping before member accesses that aren't
calls. Thus, this is again formatted as (as it has been before r256750):

  aaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 256830
2016-01-05 13:03:50 +00:00
Daniel Jasper 5e27146df7 clang-format: [JS] Support more ES6 default exports.
llvm-svn: 256759
2016-01-04 16:10:36 +00:00
Daniel Jasper b14f6675da clang-format: [JS] Support ES6 exports of array literals.
Before:
  export default[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
		 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb];
  export default[];

After:
  export default [
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  ];
  export default [];

llvm-svn: 256758
2016-01-04 15:51:56 +00:00
Daniel Jasper ebcb71fb87 clang-format: [JS] Improve empty array literal detection.
Previously, the [] in the following example were recognized as an array
subscript leading to weird indentation.

Before:
  var aaaa = aaaaa || // wrap
                          [];

After:
  var aaaa = aaaaa || // wrap
             [];

llvm-svn: 256753
2016-01-04 13:11:41 +00:00
Daniel Jasper 42011b2106 clang-format: Fix corner case in builder-type call formatting.
Before:
  return aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa,
						  aaaaaaaaaaaaaaaaa)
      .aaaa(aaaaaaaaaaaaaa);

After:
  return aaaaaaaaaaaaaaaa
      .aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)
      .aaaa(aaaaaaaaaaaaaa);

llvm-svn: 256750
2016-01-04 12:41:11 +00:00
Daniel Jasper 55582073e4 clang-format: Align long braced init lists even if they are nested in
function calls.

llvm-svn: 256740
2016-01-04 07:30:44 +00:00
Daniel Jasper 9c8a774c48 clang-format: Fix corner case for lambda assignments.
Before:
  std::function<std::string(const std::string &)> my_lambda = [](
      const string &s) { return s; };

After:
  std::function<std::string(const std::string &)> my_lambda =
      [](const string &s) { return s; };

llvm-svn: 256739
2016-01-04 07:29:40 +00:00
Daniel Jasper 06a269574c clang-format: Fix corner-case in ObjC method declaration formatting
Before:
  - (void)shortf:(GTMFoo *)theFoo
     longKeyword:(NSRect)theRect
   longerKeyword:(float)theInterval
           error:(NSError **)theError {
  }

After:
  - (void)shortf:(GTMFoo *)theFoo
        longKeyword:(NSRect)theRect
      longerKeyword:(float)theInterval
              error:(NSError **)theError {
  }

llvm-svn: 256738
2016-01-04 07:29:07 +00:00
Daniel Jasper ffbad0e8aa clang-format: [Proto] Basic support for options with <> for repeated fields.
llvm-svn: 256737
2016-01-04 07:28:12 +00:00
Daniel Jasper ccff4d1e60 clang-format: [Proto] Improve wrapping of message field attributes.
Before:
  optional AAA aaa = 1 [foo =
			    {
			      key: "a"  //
			    },
			bar = {
			  key: "a"  //
			}];

After:
  optional AAA aaa = 1 [
    foo = {
      key: "a"  //
    },
    bar = {
      key: "a"  //
    }
  ];

llvm-svn: 256736
2016-01-04 07:27:33 +00:00
Daniel Jasper e1afb9b8ee clang-format: Slightly row back on r256343 by increasing penalty for
breaking between array subscripts.

Before:
  if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa]
                                                     [aaaaaaaaaaaaa])
After:
  if (aaaaaaaaaaaaaaaaaaaaaaaa &&
      aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa][aaaaaaaaaaaaa])

llvm-svn: 256640
2015-12-30 12:23:00 +00:00
Daniel Jasper 779c66f3ca clang-format: [JS] Support TypeScript 1.6 user defined type guards.
Before:
  function foo(check: Object): check
  is{foo: string, bar: string, baz: string, foobar: string} {
    return 'bar' in check;
  }

After:
  function foo(check: Object):
      check is {foo: string, bar: string, baz: string, foobar: string} {
    return 'bar' in check;
  }

llvm-svn: 256631
2015-12-30 08:00:58 +00:00
Daniel Jasper 6f5a1933b7 clang-format: [JS/TypeScript] Support "enum" as property name.
Before:
  enum: string
  [];

After:
  enum: string[];

llvm-svn: 256546
2015-12-29 08:54:23 +00:00
Daniel Jasper a85c331e8f clang-format: Fix incorrect function type detection.
Before:
  int x = f (&h)();

After:
  int x = f(&h)();

llvm-svn: 256488
2015-12-28 07:44:25 +00:00
Daniel Jasper 498f558fcf clang-format: [TableGen] Support ;-less include lines.
llvm-svn: 256412
2015-12-25 08:53:31 +00:00
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
Daniel Jasper f83834feb1 clang-format: Simplify and improve stop condition for formatting
unaffected lines with incorrect initial indent.

Starting from:
  namespace {
    int i; // There shouldn't be indentation here.
    int j; // <- call clang-format on this line.
  }

Before:
  namespace {
    int i;
    int j;
    }

After:
  namespace {
    int i;
    int j;
  }

llvm-svn: 251824
2015-11-02 20:02:49 +00:00
Daniel Jasper f67c32466d clang-format: Be slightly more cautious when formatting subsequent lines after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing closing brace, e.g. while writing code in an editor.
Summary:
With this change, clang-format stops formatting when either it leaves
the current scope or when it comes back to the initial scope after
going into a nested one.

Reviewers: klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 251760
2015-11-01 00:27:35 +00:00
Angel Garcia Gomez 4647ed74ac Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.
Summary: This matchers are going to be used in modernize-use-default, but are generic enough to be placed in ASTMatchers.h.

Reviewers: klimek

Subscribers: alexfh, cfe-commits, klimek

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

llvm-svn: 251693
2015-10-30 09:35:51 +00:00
Saleem Abdulrasool 328085f325 Format: support inline namespaces
Correct handling for C++17 inline namespaces.  We would previously fail to
identify the inline namespaces as a namespace name since multiple ones may be
concatenated now with C++17.

llvm-svn: 251690
2015-10-30 05:07:56 +00:00
Daniel Jasper b488a74f99 clang-format: [JS] Add goog.setTestOnly to the list of stuff that
is import-statement-like and shouldn't be wrapped.

llvm-svn: 251643
2015-10-29 19:05:20 +00:00
Daniel Jasper a1036e5d08 clang-format: When a line is formatted, also format subsequence lines if their indent is off.
Summary: This is especially important so that if a change is solely inserting a block around a few statements, clang-format-diff.py will still clean up and add indentation to the inner parts.

Reviewers: klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 251474
2015-10-28 01:08:22 +00:00
Samuel Antao 4c1f1c33b1 Minor fix in ToolChainTest.cpp to allow user defined GCC toolchain.
If the user configured clang with a custom GCC toolchain that will take precedence on what the ToolChainTest.cpp expects to evaluate. 
This is fixed here by passing --gcc-toolchain= to the driver, in order to override any user defined GCC toolchain.

llvm-svn: 251459
2015-10-27 22:20:26 +00:00
Daniel Jasper bd73bcf84a clang-format: Undo unwanted format change done in r251405.
Specifically, don't wrap between the {} of an empty constructor if the
"}" falls on column 81 and ConstructorInitializerAllOnOneLineOrOnePerLine
is set.

llvm-svn: 251406
2015-10-27 13:42:08 +00:00
Daniel Jasper 6501f7e8fd clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.
Summary:
If this option is set, clang-format will always insert a line wrap, e.g.
before the first parameter of a function call unless all parameters fit
on the same line. This obviates the need to make a decision on the
alignment itself.

Use this style for Google's JavaScript style and add some minor tweaks
to correctly handle nested blocks etc. with it. Don't use this option
for for/while loops.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 251405
2015-10-27 12:38:37 +00:00
Daniel Jasper 74331d4c43 clang-format: Fix false positive in cast detection.
Before (with spaces in parentheses):
  void inFunction() { std::function<void( int, int )> fct; }

After:
  void inFunction() { std::function<void( int, int)> fct; }

llvm-svn: 251284
2015-10-26 12:08:47 +00:00
Benjamin Kramer 94355aeff8 [AST] Re-add TypeLocs and NestedNameSpecifierLocs to the ParentMap.
This relands r250831 after some fixes to shrink the ParentMap overall
with one addtional tweak: nodes with pointer identity (e.g. Decl* and
friends) can be store more efficiently so I put them in a separate map.
All other nodes (so far only TypeLoc and NNSLoc) go in a different map
keyed on DynTypedNode. This further uglifies the code but significantly
reduces memory overhead.

Overall this change still make ParentMap significantly larger but it's
nowhere as bad as before. I see about 25 MB over baseline (pre-r251008)
on X86ISelLowering.cpp. If this becomes an issue we could consider
splitting the maps further as DynTypedNode is still larger (32 bytes)
than a single TypeLoc (16 bytes) but I didn't want to introduce even
more complexity now.

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

llvm-svn: 251101
2015-10-23 09:04:55 +00:00
Benjamin Kramer 9bccaa158a [Tooling] Add a utility function to replace one nested name with another.
One problem in clang-tidy and other clang tools face is that there is no
way to lookup an arbitrary name in the AST, that's buried deep inside Sema
and might not even be what the user wants as the new name may be freshly
inserted and not available in the AST.

A common use case for lookups is replacing one nested name with another
while minimizing namespace qualifications, so replacing 'ns::foo' with
'ns::bar' will use just 'bar' if we happen to be inside the namespace 'ns'.
This adds a little helper utility for exactly that use case.

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

llvm-svn: 251022
2015-10-22 15:04:10 +00:00
Nico Weber ff06370e12 clang-format: Teach --sort-includes to interleave #include and #import.
clang accepts both #include and #import for includes (the latter having an
implicit header guard).  Let clang-format interleave both types if
--sort-includes is passed.  #import is used frequently in Objective-C code.

http://reviews.llvm.org/D13853

llvm-svn: 250909
2015-10-21 17:13:45 +00:00
Benjamin Kramer 998039e2f6 Shrink DynTypedNode by one pointer from 40 to 32 bytes (on x86_64).
The MemoizationData cache was introduced to avoid a series of enum
compares at the cost of making DynTypedNode bigger. This change reverts
to using an enum compare but instead of building a chain of comparison
the enum values are reordered so the check can be performed with a
simple greater than. The alternative would be to steal a bit from the
enum but I think that's a more complex solution and not really needed
here.

I tried this on several large .cpp files with clang-tidy and didn't
notice any performance difference. The test change is due to matchers
being sorted by their node kind.

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

llvm-svn: 250905
2015-10-21 16:33:15 +00:00
Benjamin Kramer e8c51fdbd6 Revert "[AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap."
Putting DynTypedNode in the ParentMap bloats its memory foot print.
Before the void* key had 8 bytes, now we're at 40 bytes per key which
can mean multiple gigabytes increase for large ASTs and this count
doesn't even include all the added TypeLoc nodes. Revert until I come
up with a better data structure.

This reverts commit r250831.

llvm-svn: 250889
2015-10-21 10:07:26 +00:00
Benjamin Kramer 36307ffa1b [AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap.
Firstly this changes the type of parent map to be keyed on DynTypedNode to
simplify the following changes. This comes with a DenseMapInfo for
DynTypedNode, which is a bit incomplete still and will probably only work
for parentmap right now.

Then the RecursiveASTVisitor in ASTContext is updated and finally
ASTMatchers hasParent and hasAncestor learn about the new functionality.

Now ParentMap is only missing TemplateArgumentLocs and CXXCtorInitializers.

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

llvm-svn: 250831
2015-10-20 15:08:46 +00:00
Angel Garcia Gomez 637d1e6694 Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

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

llvm-svn: 250827
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez b5250d3448 Apply modernize-use-default to clang.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: bkramer, klimek

Subscribers: klimek, alexfh, cfe-commits

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

llvm-svn: 250822
2015-10-20 12:52:55 +00:00
Benjamin Kramer b993613800 Revert accidental commit. This isn't ready yet.
llvm-svn: 250804
2015-10-20 07:53:14 +00:00
Benjamin Kramer 1b7dd8d7e3 Put back dead code that's used out-of-tree.
Partially reverts r250418.

llvm-svn: 250803
2015-10-20 07:50:21 +00:00
Nico Weber afa62fae1e clang-format: Extend main header include sorting heuristic to Objective-C files.
llvm-svn: 250675
2015-10-19 01:36:09 +00:00
Daniel Jasper 265309e38a clang-format: [JS] Handle string literals spanning character classes.
If a RegExp contains a character group with a quote (/["]/), the
trailing end of it is first tokenized as a string literal, which leads
to the merging code seeing an unbalanced bracket.

This change parses regex literals from the left hand side. That
simplifies the parsing code and also allows correctly handling escapes
and character classes, hopefully correctly parsing all regex literals.

Patch by Martin Probst, thank you.
Review: http://reviews.llvm.org/D13765

llvm-svn: 250648
2015-10-18 07:02:28 +00:00
Eric Fiselier 3acf5fdd88 Add an AST node matcher for TemplateTypeParmDecl objects.
llvm-svn: 250602
2015-10-17 02:34:44 +00:00
Nico Weber 2cd92f1cc7 clang-format/java: Break after annotations on fields in Chromium style.
Chromium follows the Android style guide for Java code, and that doesn't make
the distinction between fields and non-fields that the Google Java style guide
makes:

https://source.android.com/source/code-style.html#use-standard-java-annotations
https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations

llvm-svn: 250422
2015-10-15 16:03:01 +00:00
Benjamin Kramer f420dda18d [Driver] Use the parent_path of the clang executable as the default InstalledDir
This is what most people want anyways. Clang -cc1's main() will override
this but for other tools this is the most sensible default and avoids
some work.

llvm-svn: 250164
2015-10-13 15:19:32 +00:00
Matthias Gehre 2cf7e803bb Add decayedType and hasDecayedType AST matchers
Summary: Add decayedType and hasDecayedType AST matchers

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 250114
2015-10-12 21:46:07 +00:00
Benjamin Kramer 71ce376b2f [VFS] Let the user decide if they want path normalization.
This is a more principled version of what I did earlier. Path
normalization is generally a good thing, but may break users in strange
environments, e. g. using lots of symlinks. Let the user choose and
default it to on.

This also changes adding a duplicated file into returning an error if
the file contents are different instead of an assertion failure.

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

llvm-svn: 250060
2015-10-12 16:16:39 +00:00
Benjamin Kramer 753726d6a9 [VFS] Unbreak test.
llvm-svn: 250037
2015-10-12 13:39:33 +00:00
Benjamin Kramer 4ad1c43edd [VFS] Don't try to be heroic with '.' in paths.
Actually the only special path we have to handle is ./foo, the rest is
tricky to get right so do the same thing as the existing YAML vfs here.

llvm-svn: 250036
2015-10-12 13:30:38 +00:00
Benjamin Kramer c3741ec8d3 [VFS] remove handling of '..' for now.
This can fail badly if we're overlaying a real file system and there are
symlinks there. Just keep the path as-is for now.

This essentially reverts r249830.

llvm-svn: 250021
2015-10-12 09:22:07 +00:00
Daniel Jasper 4d72449de6 clang-format: Fixed typecast getting put on a separate line from the
key in Obj-C dictionary literals

This fixes: https://llvm.org/PR22647

Patch by Kent Sutherland. Thank you.

llvm-svn: 250010
2015-10-12 03:19:07 +00:00
Daniel Jasper 8d0e223498 clang-format: [JS] handle character classes in regexes.
Slashes in regular expressions do not need to be escaped and do not
terminate the regular expression even without a preceding backslash.

Patch by Martin Probst. Thank you.

llvm-svn: 250009
2015-10-12 03:13:48 +00:00
Reid Kleckner 04ab116e41 Fix VFS GCC unittest on Windows
llvm-svn: 249846
2015-10-09 16:48:52 +00:00