aboutsummaryrefslogtreecommitdiff
path: root/lib/Format
AgeCommit message (Collapse)Author
2019-01-07clang-format: [JS] support goog.requireType.Martin Probst
Summary: It's a new primitive for importing symbols, and should be treated like the (previously handled) `goog.require` and `goog.forwardDeclare`. Reviewers: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56385 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350516 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-22[clang-format] Do not treat asm clobber [ as ObjCExpr, refinedKrasimir Georgiev
Summary: r346756 refined clang-format to not treat the `[` in `asm (...: [] ..)` as an ObjCExpr. However that's not enough, as we might have a comma-separated list of such clobbers as in the newly added test. This updates the detection to instead look at the Line's first token being `asm` and not mark `[`-s as ObjCExprs in this case. Reviewers: djasper, benhamilton Reviewed By: djasper, benhamilton Subscribers: benhamilton, cfe-commits Differential Revision: https://reviews.llvm.org/D54795 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347465 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-20[clang-format] JS: don't treat is: as a type matcherKrasimir Georgiev
Summary: Clang-format is treating all occurences of `is` in js as type matchers. In some cases this is wrong, as it might be a dict key. Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54753 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347307 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13[clang-format] Do not treat the asm clobber [ as ObjCExprKrasimir Georgiev
Summary: The opening square of an inline asm clobber was being annotated as an ObjCExpr. This caused, amongst other things, the ObjCGuesser to guess header files containing that pattern as ObjC files. Reviewers: benhamilton Reviewed By: benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54111 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346756 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-12[clang-format] Support breaking consecutive string literals for TableGenJordan Rupprecht
Summary: clang-format can get confused by string literals in TableGen: it knows that strings can be broken up, but doesn't seem to understand how that can be indented across line breaks, and arranges them in a weird triangular pattern. Take this output example from `clang-format tools/llvm-objcopy/ObjcopyOpts.td` (which has now been formatted in rL345896 with this patch applied): ``` defm keep_global_symbols : Eq< "keep-global-symbols", "Reads a list of symbols from <filename> and " "runs as if " "--keep-global-symbol=<symbol> " "is set for each one. " "<filename> " "contains one " "symbol per line " "and may contain " "comments " "beginning " "with" " '#'" ". " "Lead" "ing " ``` Reviewers: alexshap, MaskRay, djasper Reviewed By: MaskRay Subscribers: krasimir, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D53952 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346687 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-09Fix ClangFormat issue of recognizing ObjC subscript as C++ attributes when ↵Yan Zhang
message target is a result of a C-style method. Summary: The issue is that for array subscript like: ``` arr[[Foo() bar]]; ``` ClangFormat will recognize it as C++11 attribute syntax and put a space between 'arr' and first '[', like: ``` arr [[Foo() bar]]; ``` Now it is fixed. Tested with: ``` ninja FormatTests ``` Reviewers: benhamilton Reviewed By: benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54288 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346566 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-05[Format] Add debugging to ObjC language guesserBen Hamilton
Summary: To handle diagnosing bugs where ObjCHeaderStyleGuesser guesses wrong, this diff adds a bit more debug logging to the Objective-C language guesser. Reviewers: krasimir Reviewed By: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54110 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346144 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31[clang-format] tweaked another case of lambda formattingKrasimir Georgiev
Summary: This is done in order to improve cases where the lambda's body is moved too far to the right. Consider the following snippet with column limit set to 79: ``` void f() { leader::MakeThisCallHere(&leader_service_, cq_.get(), [this, liveness](const leader::ReadRecordReq& req, std::function<void()> done) { logger_->HandleReadRecord( req, resp, std::move(done)); }); leader::MakeAnother(&leader_service_, cq_.get(), [this, liveness](const leader::ReadRecordReq& req, std::function<void()> done) { logger_->HandleReadRecord( req, resp, std::move(done), a); }); } ``` The tool favors extra indentation for the lambda body and so the code incurs extra wrapping and adjacent calls are indented to a different level. I find this behavior annoying and I'd like the tool to favor new lines and, thus, use the extra width. The fix, reduced, brings the following formatting. Before: function(1, [] { DoStuff(); // }, 1); After: function( 1, [] { DoStuff(); // }, 1); Refer to the new tests in FormatTest.cpp Contributed by oleg.smolsky! Reviewers: djasper, klimek, krasimir Subscribers: cfe-commits, owenpan Tags: #clang Differential Revision: https://reviews.llvm.org/D52676 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345753 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345637 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25[clang-format] Break before next parameter after a formatted multiline raw ↵Krasimir Georgiev
string parameter Summary: Currently clang-format breaks before the next parameter after multiline parameters (also recursively for the parent expressions of multiline parameters). However, it fails to do so for formatted multiline raw string literals: ``` $ cat test.cc // Examples // Regular multiline tokens int x = f(R"(multi line)", 2); } int y = g(h(R"(multi line)"), 2); // Formatted multiline tokens int z = f(R"pb(multi: 1 # line: 2)pb", 2); int w = g(h(R"pb(multi: 1 # line: 2)pb"), 2); $ clang-format -style=google test.cc // Examples // Regular multiline tokens int x = f(R"(multi line)", 2); } int y = g(h(R"(multi line)"), 2); // Formatted multiline tokens int z = f(R"pb(multi: 1 # line: 2)pb", 2); int w = g(h(R"pb(multi: 1 # line: 2)pb"), 2); ``` This patch addresses this inconsistency by forcing breaking after multiline formatted raw string literals. This requires a little tweak to the indentation chosen for the contents of a formatted raw string literal: in case when that's a parameter and not the last one, the indentation is based off of the uniform indentation of all of the parameters. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52448 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345242 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-19Java annotation declaration being handled correctlyHans Wennborg
Previously, Java annotation declarations (@interface AnnotationName) were being handled as ObjC interfaces. This caused the brace formatting to mess up, so that when you had a class with an interface defined in it, it would indent the final brace of the class. It used to format this class like so: class A { @interface B {} } But will now just skip the @interface and format it like so: class A { @interface B {} } Patch by Sam Maier! Differential Revision: https://reviews.llvm.org/D53434 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344789 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-12[clang-format] Fix BraceWrapping AfterFunction for ObjC methodsBen Hamilton
Summary: > clang-format --version > clang-format version 7.0.0 (tags/RELEASE_700/final) > echo "@implementation Foo\n- (void)foo:(id)bar\n{\n}\n@end\n" |clang-format -style='{BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true}}' ``` @implementation Foo - (void)foo:(id)bar { } @end ``` with patch: > bin/clang-format --version > clang-format version 8.0.0 (trunk 344285) > echo "@implementation Foo\n- (void)foo:(id)bar\n{\n}\n@end\n" |bin/clang-format -style='{BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true}}' ``` @implementation Foo - (void)foo:(id)bar { } @end ``` Contributed by hultman@. Reviewers: benhamilton, jolesiak, klimek, Wizard Reviewed By: benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53197 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344406 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-10Lift VFS from clang to llvm (NFC)Jonas Devlieghere
This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344140 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-05clang-format: Don't insert spaces in front of :: for Java 8 Method References.Nico Weber
The existing code kept the space if it was there for identifiers, and it didn't handle `this`. After this patch, for Java `this` is handled in addition to identifiers, and existing space is always stripped between identifier and `::`. Also accept `::` in addition to `.` in front of `<` in `foo::<T>bar` generic calls. Differential Revision: https://reviews.llvm.org/D52842 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343872 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-05[clang-format] Java import sorting in clang-formatKrasimir Georgiev
Contributed by SamMaier! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343862 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-02clang-format: better handle statement macrosFrancois Ferrand
Summary: Some macros are used in the body of function, and actually contain the trailing semicolon: they should thus be automatically followed by a new line, and not get merged with the next line. This is for example the case with Qt's Q_UNUSED macro: void foo(int a, int b) { Q_UNUSED(a) return b; } This patch deals with these cases by introducing a new option to specify list of statement macros. This re-uses the system already in place for foreach macros, to ensure there is no impact on performance. Reviewers: krasimir, djasper, klimek Reviewed By: krasimir Subscribers: acoomans, mgrang, alexfh, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33440 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343602 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01[clang-format] Update comment, NFCIKrasimir Georgiev
The initializer of `ParameterCount` was updated from 1 to 0 in r175165, but the comment was never touched: https://github.com/llvm-mirror/clang/commit/9fc56f2636137fcde8acb38865555ed6c7b84dfd git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343517 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01[clang-format] Fix typo in comment, NFCIKrasimir Georgiev
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343513 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28[ClangFormat] 'try' of function-try-block doesn't obey BraceWrappingOwen Pan
It should respond to AfterFunction, not AfterControlStatement. Fixes PR39067 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343305 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27clang-format: [JS] conditional types.Martin Probst
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343179 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343147 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26clang-format: [JS] space after parameter naming.Martin Probst
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343080 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-21[clang-format] Do not merge short case labels if followed by a block.Owen Pan
Do not allow short case labels on a single line if the label is followed by a left brace. Fixes PR38926. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342708 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17[clang-Format] Fix indentation of member call after blockIlya Biryukov
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342363 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-13[clang-format] Wrapped block after case label should not be merged into one lineOwen Pan
PR38854 Differential Revision: http://reviews.llvm.org/D51719 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342116 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-05clang-format: Fix formatting C++ namespaces with preceding 'inline' or ↵Sam McCall
'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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341450 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-02Fix Bug 38713: clang-format mishandles a short block after "default:" in a ↵Jonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341284 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24[clang-format] fix PR38557 - comments between "default" and ':' causes the ↵Jonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340624 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24[clang-format] fix PR38525 - Extraneous continuation indent spaces with ↵Jonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340623 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15clang-format: Change Google style wrt. the formatting of empty messages.Daniel Jasper
Before: message Empty { } After: message Empty {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339803 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-07[clang-format] comment reflow: add last line's penalty when ending brokenKrasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339123 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03clang-format: [JS] don't break comments before any '{'Martin Probst
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338890 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03Revert "clang-format: [JS] don't break comments before any '{'"Tim Northover
This reverts commit r338837, it introduced an infinite loop on all bots. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338879 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03clang-format: [JS] don't break comments before any '{'Martin Probst
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338837 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02clang-format: fix a crash in comment wraps.Martin Probst
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338706 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01[Format] Fix for bug 35641Ilya Biryukov
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338578 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01[clang-format] Add some text proto functions to Google styleKrasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338524 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01[clang-format] Add @private to the list of jsdoc annotationsKrasimir Georgiev
Reviewers: mprobst Reviewed By: mprobst Subscribers: acoomans, cfe-commits Differential Revision: https://reviews.llvm.org/D50138 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338519 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-30Remove trailing spaceFangrui Song
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-30[clang-format] Silence -Wdocumentation warningsKrasimir Georgiev
introduced in r338232 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338245 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-30[clang-format] Indent after breaking Javadoc annotated lineKrasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338232 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24NFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have itErik Pilkington
https://llvm.org/docs/CodingStandards.html#file-headers git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337780 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09[clang-format/ObjC] Put ObjC method arguments into one line when they fitJacek Olesiak
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336521 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09[clang-format/ObjC] Improve split priorities for ObjC methodsJacek Olesiak
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336520 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09[clang-format/ObjC] Prohibit breaking after a bracket opening ObjC method ↵Jacek Olesiak
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336519 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09[clang-format/ObjC] Fix counting selector name parts for ObjCJacek Olesiak
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336518 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29[clang-format/ObjC] Fix NS_SWIFT_NAME(foo(bar:baz:)) after ObjC method declBen Hamilton
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335983 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29[clang-format] Support additional common functions for text proto formattingKrasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335978 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28[clang-format] Do not format raw string literals inside a recognized ↵Krasimir Georgiev
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335876 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26[clang-format] Enable text proto formatting in common functionsKrasimir Georgiev
Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48363 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335595 91177308-0d34-0410-b5e6-96231b3b80d8