Commit Graph

2171 Commits

Author SHA1 Message Date
Owen Pan cb5ffbed71 [ClangFormat] 'try' of function-try-block doesn't obey BraceWrapping
It should respond to AfterFunction, not AfterControlStatement.

Fixes PR39067

llvm-svn: 343305
2018-09-28 09:17:00 +00:00
Martin Probst 3315aed44a clang-format: [JS] conditional types.
Summary:
This change adds some rudimentary support for conditional types.
Specifically it avoids breaking before `extends` and `infer` keywords,
which are subject to Automatic Semicolon Insertion, so breaking before
them creates incorrect syntax.

The actual formatting of the type expression is odd, but there is as of
yet no clear idea on how to format these.

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#conditional-types.

Reviewers: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52536

llvm-svn: 343179
2018-09-27 06:48:13 +00:00
Fangrui Song 55fab260ca llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.

Reviewers: rsmith, #clang, dblaikie

Reviewed By: rsmith, #clang

Subscribers: mgrang, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52576

llvm-svn: 343147
2018-09-26 22:16:28 +00:00
Martin Probst cc525e7b8d clang-format: [JS] space after parameter naming.
Summary:
Previously:
    foo(/*bar=*/baz);

Now:
    foo(/*bar=*/ baz);

The run-in parameter naming comment is not intended in JS.

Reviewers: mboehme

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52535

llvm-svn: 343080
2018-09-26 08:28:33 +00:00
Owen Pan 9da65a3ab0 [clang-format] Do not merge short case labels if followed by a block.
Do not allow short case labels on a single line if the label is followed by a
left brace.

Fixes PR38926.

llvm-svn: 342708
2018-09-21 03:46:36 +00:00
Ilya Biryukov 370eff85b9 [clang-Format] Fix indentation of member call after block
Summary:
before patch:
> echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google

```
test() {
  ([]() -> {
    int b = 32;
    return 3;
  })
      .as();
});
```

after patch:
> echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google

```
test() {
  ([]() -> {
    int b = 32;
    return 3;
  }).as();
});
```

Patch by Anders Karlsson (ank)!

Reviewers: klimek

Reviewed By: klimek

Subscribers: danilaml, acoomans, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D45719

llvm-svn: 342363
2018-09-17 07:46:20 +00:00
Owen Pan 58c3dee3b3 [clang-format] Wrapped block after case label should not be merged into one line
PR38854

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

llvm-svn: 342116
2018-09-13 07:27:15 +00:00
Sam McCall 6f3778c372 clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier
This fixes formatting namespaces with preceding 'inline' and 'export' (Modules TS) specifiers.

This change fixes namespaces not being identified as such with preceding 'inline' or 'export' specifiers.

Motivation: I was experimenting with the Modules TS (-fmodules-ts) and found it would be useful if clang-format would correctly format 'export namespace'. While making the changes, I noticed that similar issues still exist with 'inline namespace', and addressed them as well.

Patch by Marco Elver!

Reviewers: klimek, djasper, owenpan, sammccall

Reviewed By: owenpan, sammccall

Subscribers: owenpan, cfe-commits

Differential Revision: https://reviews.llvm.org/D51036

llvm-svn: 341450
2018-09-05 07:44:02 +00:00
Jonas Toth 81b61a8291 Fix Bug 38713: clang-format mishandles a short block after "default:" in a switch statement
Summary:
See https://bugs.llvm.org/show_bug.cgi?id=38713

Patch by Owen Pan!

Reviewers: djasper, klimek, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D51294

llvm-svn: 341284
2018-09-02 09:04:51 +00:00
Jonas Toth 90d2aa2335 [clang-format] fix PR38557 - comments between "default" and ':' causes the case label to be treated as an identifier
Summary:
The Bug was reported and fixed by Owen Pan. See the original bug report here: https://bugs.llvm.org/show_bug.cgi?id=38557

Patch by Owen Pan!

Reviewers: krasimir, djasper, klimek

Reviewed By: klimek

Subscribers: JonasToth, cfe-commits

Differential Revision: https://reviews.llvm.org/D50697

llvm-svn: 340624
2018-08-24 17:25:06 +00:00
Jonas Toth 4636debc27 [clang-format] fix PR38525 - Extraneous continuation indent spaces with BreakBeforeBinaryOperators set to All
Summary: See bug report https://bugs.llvm.org/show_bug.cgi?id=38525 for more details.

Reviewers: djasper, klimek, krasimir, sammccall

Reviewed By: sammccall

Subscribers: hiraditya, JonasToth, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D50699

llvm-svn: 340623
2018-08-24 17:14:31 +00:00
Daniel Jasper 67e6521a67 clang-format: Change Google style wrt. the formatting of empty messages.
Before:
  message Empty {
  }

After:
  message Empty {}

llvm-svn: 339803
2018-08-15 19:07:55 +00:00
Krasimir Georgiev 123ca80bdb [clang-format] comment reflow: add last line's penalty when ending broken
Summary:
This fixes a bug in clang-format where the last line's penalty is not
taken into account when its ending is broken. Usually the last line's penalty
is handled by addNextStateToQueue, but in cases where the trailing `*/` is put
on a newline, the contents of the last line have to be considered for penalizing.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50378

llvm-svn: 339123
2018-08-07 10:23:24 +00:00
Martin Probst f326b6b975 clang-format: [JS] don't break comments before any '{'
Summary:
Previously, clang-format would avoid breaking before the first `{`
found, but then happily break before subsequent '{'s on the line. This
change fixes that by looking for the first location that has no opening
curly, if any.

This fixes the original commit by correcting the loop condition.

This reverts commit 66dc646e09b795b943668179c33d09da71a3b6bc.

Reviewers: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50249

llvm-svn: 338890
2018-08-03 13:58:33 +00:00
Tim Northover 608f136dbb Revert "clang-format: [JS] don't break comments before any '{'"
This reverts commit r338837, it introduced an infinite loop on all bots.

llvm-svn: 338879
2018-08-03 12:19:22 +00:00
Martin Probst ec45bc2fea clang-format: [JS] don't break comments before any '{'
Summary:
Previously, clang-format would avoid breaking before the first `{`
found, but then happily break before subsequent '{'s on the line. This
change fixes that by looking for the first location that has no opening
curly, if any.

Reviewers: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50230

llvm-svn: 338837
2018-08-03 09:34:41 +00:00
Martin Probst 9d7178139c clang-format: fix a crash in comment wraps.
Summary:
Previously, clang-format would crash if it tried to wrap an overlong
single line comment, because two parts of the code inserted a break in
the same location.

    /** heregoesalongcommentwithnospace */

This wasn't previously noticed as it could only trigger for an overlong
single line comment that did have no breaking opportunities except for a
whitespace at the very beginning.

This also introduces a check for JavaScript to not ever wrap a comment
before an opening curly brace:

    /** @mods {donotbreakbeforethecurly} */

This is because some machinery parsing these tags sometimes supports
breaks before a possible `{`, but in some other cases does not.
Previously clang-format was careful never to wrap a line with certain
tags on it. The better solution is to specifically disable wrapping
before the problematic token: this allows wrapping and aligning comments
but still avoids the problem.

Reviewers: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50177

llvm-svn: 338706
2018-08-02 11:52:08 +00:00
Ilya Biryukov f16a6fa8f3 [Format] Fix for bug 35641
Summary:
Bug was caused due to comments at the start of scope. For a code like:
```
int func() { //
  int b;
  int c;
}
```
the comment at the first line gets IndentAndNestingLevel (1,1) whereas
the following declarations get only (0,1) which prevents them from insertion
of a new scope. So, I changed the AlignTokenSequence to look at previous
*non-comment* token when deciding whether to introduce a new scope into
stack or not.

Patch by Kadir Cetinkaya!

Reviewers: rsmith, djasper

Reviewed By: djasper

Subscribers: lebedev.ri, cfe-commits, klimek

Tags: #clang

Differential Revision: https://reviews.llvm.org/D43303

llvm-svn: 338578
2018-08-01 15:32:56 +00:00
Krasimir Georgiev ce0b8d6935 [clang-format] Add some text proto functions to Google style
Summary: Adds 2 functions taking a text proto argument.

Reviewers: djasper, klimek

Reviewed By: djasper

Subscribers: acoomans, cfe-commits

Differential Revision: https://reviews.llvm.org/D50132

llvm-svn: 338524
2018-08-01 12:35:23 +00:00
Krasimir Georgiev 186478d8e2 [clang-format] Add @private to the list of jsdoc annotations
Reviewers: mprobst

Reviewed By: mprobst

Subscribers: acoomans, cfe-commits

Differential Revision: https://reviews.llvm.org/D50138

llvm-svn: 338519
2018-08-01 11:48:04 +00:00
Fangrui Song 6907ce2f8f Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

llvm-svn: 338291
2018-07-30 19:24:48 +00:00
Krasimir Georgiev e3424bf477 [clang-format] Silence -Wdocumentation warnings
introduced in r338232

llvm-svn: 338245
2018-07-30 12:22:41 +00:00
Krasimir Georgiev 6a5c95bd66 [clang-format] Indent after breaking Javadoc annotated line
Summary:
This patch makes clang-format indent the subsequent lines created by breaking a
long javadoc annotated line.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: acoomans, cfe-commits

Differential Revision: https://reviews.llvm.org/D49797

llvm-svn: 338232
2018-07-30 08:45:45 +00:00
Erik Pilkington 7adcf292a1 NFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it
https://llvm.org/docs/CodingStandards.html#file-headers

llvm-svn: 337780
2018-07-24 00:07:49 +00:00
Jacek Olesiak 2dc3dac90c [clang-format/ObjC] Put ObjC method arguments into one line when they fit
Reapply D47195:
Currently BreakBeforeParameter is set to true everytime message receiver spans multiple lines, e.g.:
```
[[object block:^{
  return 42;
}] aa:42 bb:42];
```
will be formatted:
```
[[object block:^{
  return 42;
}] aa:42
   bb:42];
```
even though arguments could fit into one line. This change fixes this behavior.

llvm-svn: 336521
2018-07-09 07:08:45 +00:00
Jacek Olesiak 6b475b730b [clang-format/ObjC] Improve split priorities for ObjC methods
Reduce penalty for aligning ObjC method arguments using the colon alignment as
this is the canonical way.

Trying to fit a whole expression into one line should not force other line
breaks (e.g. when ObjC method expression is a part of other expression).

llvm-svn: 336520
2018-07-09 06:54:52 +00:00
Jacek Olesiak e7c4b5901e [clang-format/ObjC] Prohibit breaking after a bracket opening ObjC method expression
Summary:
Don't break after a "[" opening an ObjC method expression.
Tests are added in D48719 where formatting is improved (to avoid adding and changing tests immediately).

Reviewers: benhamilton, klimek

Reviewed By: benhamilton

Subscribers: acoomans, cfe-commits

Differential Revision: https://reviews.llvm.org/D48718

llvm-svn: 336519
2018-07-09 06:04:58 +00:00
Jacek Olesiak 27a5579f15 [clang-format/ObjC] Fix counting selector name parts for ObjC
Summary:
Counts selector parts also for method declarations and counts correctly for methods without arguments.
This is an internal change and doesn't influence formatting on its own (at the current state). Its lack would be visible after applying D48719.

Reviewers: benhamilton, klimek

Reviewed By: benhamilton

Subscribers: acoomans, cfe-commits

Differential Revision: https://reviews.llvm.org/D48716

llvm-svn: 336518
2018-07-09 05:58:51 +00:00
Ben Hamilton 3007b385fa [clang-format/ObjC] Fix NS_SWIFT_NAME(foo(bar:baz:)) after ObjC method decl
Summary:
In D44638, I partially fixed `NS_SWIFT_NAME(foo(bar:baz:))`-style
annotations on C functions, but didn't add a test for Objective-C
method declarations.

For ObjC method declarations which are annotated with `NS_SWIFT_NAME(...)`,
we currently fail to annotate the final component of the selector
name as `TT_SelectorName`.

Because the token type is left unknown, clang-format will happily
cause a compilation error when it changes the following:

```
@interface Foo
- (void)doStuffWithFoo:(id)name
                   bar:(id)bar
                   baz:(id)baz
    NS_SWIFT_NAME(doStuff(withFoo:bar:baz:));
@end
```

to:

```
@interface Foo
- (void)doStuffWithFoo:(id)name
                   bar:(id)bar
                   baz:(id)baz
    NS_SWIFT_NAME(doStuff(withFoo:bar:baz
:));
@end
```

(note the linebreak before the final `:`).

The logic which decides whether or not to annotate the token before a
`:` with `TT_SelectorName` is pretty fragile, and has to handle some
pretty odd cases like pair-parameters:

```
[I drawRectOn:surface ofSize:aa:bbb atOrigin:cc:dd];
```

So, to minimize the effect of this change, I decided to only annotate
unknown identifiers before a `:` as `TT_SelectorName` for Objective-C
declaration lines.

Test Plan: New tests included. Confirmed tests failed before change and
  passed after change. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, krasimir, jolesiak

Reviewed By: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48679

llvm-svn: 335983
2018-06-29 15:26:37 +00:00
Krasimir Georgiev 61f46f2247 [clang-format] Support additional common functions for text proto formatting
Summary: This adds a few more common function names expecting a text proto argument.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48760

llvm-svn: 335978
2018-06-29 14:25:25 +00:00
Krasimir Georgiev 2d69f5d82e [clang-format] Do not format raw string literals inside a recognized function with a non-recognized delimiter
Summary:
This stops clang-format from touching raw string contents with unrecognized delimiters inside recognized functions.
Unrecognized delimiters signal that the string might be special.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48728

llvm-svn: 335876
2018-06-28 16:58:24 +00:00
Krasimir Georgiev 42948e3c8f [clang-format] Enable text proto formatting in common functions
Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48363

llvm-svn: 335595
2018-06-26 12:00:14 +00:00
Eric Liu b4adc9110d [clang-format] Add a default format style that can be used by users of `getStyle`
Summary:
Tools that reformat code often call `getStyle` to decide the format style
to use on a certain source file. In practice, "file" style is widely used. As a
result, many tools hardcode "file" when calling `getStyle`, which makes it hard
to control the default style in tools across a codebase when needed. This change
introduces a `DefaultFormatStyle` constant (default to "file" in upstream), which
can be modified downstream if wanted, so that all users/tools built from the same
source tree can have a consistent default format style.

This also adds an DefaultFallbackStyle that is recommended to be used by tools and can be modified downstream.

Reviewers: sammccall, djasper

Reviewed By: sammccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48492

llvm-svn: 335492
2018-06-25 16:29:19 +00:00
Krasimir Georgiev da5cca4f43 [clang-format] Keep @message together in text protos
Summary:
In C++ code snippets of the form `@field` are common. This makes clang-format
keep them together in text protos, whereas before it would break them.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48543

llvm-svn: 335459
2018-06-25 12:43:12 +00:00
Krasimir Georgiev 0895f5e8b9 [clang-format] Fix end-of-file comments text proto formatting
Summary:
The case of end-of-file comments was formatted badly:
```
key: value
    # end-of-file comment
```
This patch fixes that formatting:
```
key: value
# end-of-file comment
```

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48539

llvm-svn: 335449
2018-06-25 11:08:24 +00:00
David L. Jones 5de2272174 [Format] Do not use a global static value for EOF within ScopedMacroState.
ScopedMacroState injects its own EOF token under certain conditions, and the
returned token may be modified in several different locations. If multiple
reformat operations are started in different threads, then they will both see
the same fake EOF token, and may both try to modify it. This is a data race.

This bug was caught with tsan.

Reviewers: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47759

llvm-svn: 334801
2018-06-15 06:08:54 +00:00
Ben Hamilton 1ab722ed17 [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 📜
Contributed by @stephanemoore.

Reviewers: benhamilton, jolesiak, djasper

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47393

llvm-svn: 334739
2018-06-14 17:30:10 +00:00
Hans Wennborg bfc3406530 [clang-format] Add SpaceBeforeCpp11BracedList option.
WebKit C++ style for object initialization is as follows:

  Foo foo { bar };

Yet using clang-format -style=webkit changes this to:

  Foo foo{ bar };

As there is no existing combination of rules that will ensure a space
before a braced list in this fashion, this patch adds a new
SpaceBeforeCpp11BracedList rule.

Patch by Ross Kirsling!

Differential Revision: https://reviews.llvm.org/D46024

llvm-svn: 334692
2018-06-14 08:01:09 +00:00
Krasimir Georgiev 4fc55a76b8 [clang-format] Fix crash while reflowing backslash in comments
Summary:
The added test case was currently crashing with an assertion:
```
krasimir@krasimir> cat test.cc                                                                                                                                                              ~
// How to run:
// bbbbb run \
// rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr \
// <log_file> -- --output_directory="<output_directory>"
krasimir@krasimir> ~/work/llvm-build/bin/clang-format test.cc                                                                                                                               ~
clang-format: /usr/local/google/home/krasimir/work/llvm/tools/clang/lib/Format/WhitespaceManager.cpp:117: void clang::format::WhitespaceManager::calculateLineBreakInformation(): Assertion `PreviousOriginalWhitespaceEndOffset <= OriginalWhitespaceStartOffset' failed.
```
The root cause was that BreakableToken was not considering the case of a reflow between an unescaped newline in a line comment.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48089

llvm-svn: 334527
2018-06-12 19:33:15 +00:00
Krasimir Georgiev 70a9e47f53 [clang-format] Discourage breaks in submessage entries, hard rule
Summary:
Currently clang-format allows this for text protos:
```
submessage:
    { key: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }
```
when it is under the column limit and when putting it all on one line exceeds the column limit.

This is not a very intuitive formatting, so I'd prefer having
```
submessage: {
  key: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
}
```
instead, even if it takes one line more.

This patch prevents clang-format from inserting a break between `: {` and similar cases.

Reviewers: djasper, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48063

llvm-svn: 334517
2018-06-12 17:26:31 +00:00
Martin Probst c8b7a41a00 clang-format: [JS] strict prop init annotation.
Summary:
TypeScript uses the `!` token for strict property initialization
assertions, as in:

    class X {
      strictPropAsserted!: string;
    }

Previously, clang-format would wrap between the `!` and the `:` for
overly long lines. This patch fixes that by generally preventing the
wrap in that location.

Reviewers: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48030

llvm-svn: 334415
2018-06-11 16:20:13 +00:00
Francois Ferrand 6bb103f9fa clang-format: Introduce BreakInheritanceList option
Summary:
This option replaces the BreakBeforeInheritanceComma option with an
enum, thus introducing a mode where the colon stays on the same line as
constructor declaration:

  // When it fits on line:
  class A : public B, public C {
    ...
  };

  // When it does not fit:
  class A :
      public B,
      public C {
    ...
  };

This matches the behavior of the `BreakConstructorInitializers` option,
introduced in https://reviews.llvm.org/D32479.

Reviewers: djasper, klimek

Reviewed By: djasper

Subscribers: mzeren-vmw, cfe-commits

Differential Revision: https://reviews.llvm.org/D43015

llvm-svn: 334408
2018-06-11 14:41:26 +00:00
Krasimir Georgiev 8b98f5517f [clang-format] text protos: put entries on separate lines if there is a submessage
Summary:
This patch updates clang-format text protos to put entries of a submessage into separate lines if the submessage contains at least two entries and contains at least one submessage entry.

For example, the entries here are kept on separate lines even if putting them on a single line would be under the column limit:
```
message: {
  entry: 1
  submessage: { key: value }
}
```

Messages containing a single submessage or several scalar entries can still be put on one line if they fit:
```
message { submessage { key: value } }
message { x: 1 y: 2 z: 3 }
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D46757

llvm-svn: 334401
2018-06-11 12:53:25 +00:00
Krasimir Georgiev 45dde418a9 [clang-format] Consider tok::hashhash in python-style comments
Summary: We were missing the case when python-style comments in text protos start with `##`.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47870

llvm-svn: 334179
2018-06-07 09:46:24 +00:00
Eric Liu 44564ac7eb Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
This reverts commit r333534 (i.e. reland r332720) after fixing module build.

Differential Revision: https://reviews.llvm.org/D47068

llvm-svn: 333874
2018-06-04 09:04:12 +00:00
Ben Hamilton 707e68fb21 [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name
Summary:
Please take a close look at this CL. I haven't touched much of
`UnwrappedLineParser` before, so I may have gotten things wrong.

Previously, clang-format would incorrectly format the following:

```
@implementation Foo

- (Class)class {
}

- (void)foo {
}

@end
```

as:

```
@implementation Foo

- (Class)class {
}

    - (void)foo {
}

@end
```

The problem is whenever `UnwrappedLineParser::parseStructuralElement()`
sees any of the keywords `class`, `struct`, or `enum`, it calls
`parseRecord()` to parse them as a C/C++ record.

This causes subsequent lines to be parsed incorrectly, which
causes them to be indented incorrectly.

In Objective-C/Objective-C++, these keywords are valid selector
components.

This diff fixes the issue by explicitly handling `+` and `-` lines
inside `@implementation` / `@interface` / `@protocol` blocks
and parsing them as Objective-C methods.

Test Plan: New tests added. Ran tests with:
  make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, klimek

Reviewed By: jolesiak, klimek

Subscribers: klimek, cfe-commits, Wizard

Differential Revision: https://reviews.llvm.org/D47095

llvm-svn: 333553
2018-05-30 15:21:38 +00:00
Jacek Olesiak d8d5628834 Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"
Summary:
This reverts commit db9e5e9a616d7fdd4d1ba4c3b2cd89d8a0238533 (rC333171).

Mentioned change introduced unintended formatting of ObjC code due to split priorities inherited from C/C++, e.g.:
```
fooooooo = [
    [obj fooo] aaa:42 aaa:42];
```
instead of
```
fooooooo =
    [[obj fooo] aaa:42
                aaa:42];
```
when formatted with ColumnLimit = 30.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: benhamilton, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47527

llvm-svn: 333539
2018-05-30 12:57:58 +00:00
Eric Liu cfd01f94b2 Revert "Reland "Move #include manipulation code to new lib/Tooling/Inclusions.""
This reverts commit r333532. Revert for now to fix an internal bot issue.

llvm-svn: 333534
2018-05-30 12:09:58 +00:00
Eric Liu 4f20e9de0a Reland "Move #include manipulation code to new lib/Tooling/Inclusions."
This reverts commit r332751 (i.e. reland r332720) after fixing module
build.

Differential Revision: https://reviews.llvm.org/D47068

llvm-svn: 333532
2018-05-30 11:51:48 +00:00
Jacek Olesiak 34391f097d [clang-format] Fix putting ObjC message arguments in one line for multiline receiver
Summary:
Reapply reverted changes from D46879.

Currently BreakBeforeParameter is set to true everytime message receiver spans multiple lines, e.g.:
```
[[object block:^{
  return 42;
}] aa:42 bb:42];
```
will be formatted:
```
[[object block:^{
  return 42;
}] aa:42
   bb:42];
```
even though arguments could fit into one line. This change fixes this behavior.

Test Plan:
make -j12 FormatTests && tools/clang/unittests/Format/FormatTests

Reviewers: benhamilton, krasimir

Reviewed By: benhamilton, krasimir

Subscribers: djasper, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47195

llvm-svn: 333171
2018-05-24 10:50:36 +00:00