summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-format] Improve detection of ObjC for-in statementsBen Hamilton2018-03-061-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect the following as an Objective-C for-in statement: for (int x = in.value(); ...) {} because the logic only decided a for-loop was definitely *not* an Objective-C for-in loop after it saw a semicolon or a colon. To fix this, I delayed the decision of whether this was a for-in statement until after we found the matching right-paren, at which point we know if we've seen a semicolon or not. Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak Reviewed By: jolesiak Subscribers: djasper, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43904 llvm-svn: 326815
* [clang-format] fix handling of consecutive unary operatorsKrasimir Georgiev2018-03-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Code that used to be formatted as `if (! + object) {` is now formatted as `if (!+object) {` (we have a particular object in our codebase where unary `operator+` is overloaded to return the underlying value, which in this case is a `bool`) We still preserve the TypeScript behavior where `!` is a trailing non-null operator. (This is already tested by an existing unit test in `FormatTestJS.cpp`) It doesn't appear like handling of consecutive unary operators are tested in general, so I added another test for completeness Patch contributed by @kevinl! Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43312 llvm-svn: 326792
* [clang-format] Add SpaceBeforeColon optionFrancois Ferrand2018-03-012-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When disabled, this option allows removing the space before colon, making it act more like the semi-colon. When enabled (default), the current behavior is not affected. This mostly affects C++11 loop, initializer list, inheritance list and container literals: class Foo: Bar {} Foo::Foo(): a(a) {} for (auto i: myList) {} f({a: 1, b: 2, c: 3}); Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32525 llvm-svn: 326426
* [clang-format] Format operator key in protosKrasimir Georgiev2018-02-271-0/+3
| | | | | | | | | | Summary: This fixes a glitch where ``operator: value`` in a text proto would mess up the underlying formatting since it gets parsed as a kw_operator instead of an identifier. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43830 llvm-svn: 326227
* [clang-format] Tidy up new API guessLanguage()Ben Hamilton2018-02-271-6/+5
| | | | | | | | | | | | | | | | | | Summary: This fixes a few issues djasper@ brought up in his review of D43522. Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43598 llvm-svn: 326205
* clang-format: use AfterControlStatement to format ObjC control blocksFrancois Ferrand2018-02-272-2/+10
| | | | | | | | | | | | | | | | | | ObjC defines `@autoreleasepool` and `@synchronized` control blocks. These used to be formatted according to the `AfterObjCDeclaration` brace- wrapping flag, which is not very consistent. This patch changes the behavior to use the `AfterControlStatement` flag instead. This should not affect the behavior unless a custom brace wrapping mode is used. Reviewers: krasimir, djasper, klimek, benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43232 llvm-svn: 326192
* clang-format: fix formatting of ObjC @synchronized blocksFrancois Ferrand2018-02-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | | Summary: The blocks used to be formatted using the "default" behavior, and would thus be mistaken for function calls followed by blocks: this could lead to unexpected inlining of the block and extra line-break before the opening brace. They are now formatted similarly to `@autoreleasepool` blocks, as expected: @synchronized(self) { f(); } Reviewers: krasimir, djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43114 llvm-svn: 326191
* [clang-format] Fix regression when getStyle() called with empty filenameBen Hamilton2018-02-211-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: D43522 caused an assertion failure when getStyle() was called with an empty filename: P8065 This adds a test to reproduce the failure and fixes the issue by ensuring we never pass an empty filename to Environment::CreateVirtualEnvironment(). Test Plan: New test added. Ran test with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Before diff, test failed with P8065. Now, test passes. Reviewers: vsapsai, jolesiak, krasimir Reviewed By: vsapsai Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43590 llvm-svn: 325722
* [clang-format] New API guessLanguage()Ben Hamilton2018-02-211-11/+20
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: For clients which don't have a filesystem, calling getStyle() doesn't make much sense (there's no .clang-format files to search for). In this diff, I hoist out the language-guessing logic from getStyle() and move it into a new API guessLanguage(). I also added support for guessing the language of files which have no extension (they could be C++ or ObjC). Test Plan: New tests added. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: jolesiak, krasimir Reviewed By: jolesiak, krasimir Subscribers: klimek, cfe-commits, sammccall Differential Revision: https://reviews.llvm.org/D43522 llvm-svn: 325691
* [clang-format] Fix text proto extension scope opening detectionKrasimir Georgiev2018-02-191-0/+1
| | | | | | | | | | | | | | | | | | | | Summary: This fixes the detection of scope openers in text proto extensions; previously they were not detected correctly leading to instances like: ``` msg { [aa.bb ] { key: value } } ``` Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43469 llvm-svn: 325513
* [clang-format] Fixup a case of text proto message attributesKrasimir Georgiev2018-02-191-0/+6
| | | | | | | | | | Summary: This patch fixes a case where a proto message attribute is wrongly identified as an text proto extension. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43465 llvm-svn: 325509
* clang-format: [JS] fix `of` detection.Martin Probst2018-02-191-1/+1
| | | | | | | | | | | | | | | | | | | Summary: `of` is only a keyword when after an identifier, but not when after an actual keyword. Before: return of (a, b, c); After: return of(a, b, c); Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43440 llvm-svn: 325489
* [clang-format] Enable google text proto formatting in R"proto('sKrasimir Georgiev2018-02-161-0/+2
| | | | llvm-svn: 325336
* [clang-format] Support repeated field lists in protosKrasimir Georgiev2018-02-151-7/+24
| | | | | | | | | | | | | | | | | | Summary: This patch adds support for list initialization of proto repeated fields: ``` keys: [1, 2, 3] ``` Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43298 llvm-svn: 325252
* [clang-format] Improve ObjC headers detectionJacek Olesiak2018-02-151-2/+7
| | | | | | | | | | | | | | Summary: Detect ObjC characteristic types when they start a line and add additional keywords. Reviewers: benhamilton Reviewed By: benhamilton Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43124 llvm-svn: 325221
* [clang-format] Recognize percents as format specifiers in protosKrasimir Georgiev2018-02-141-0/+3
| | | | | | | | | | | | | | | | Summary: Frequently, a percent in protos denotes a formatting specifier for string replacement. Thus it is desirable to keep the percent together with what follows after it. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43294 llvm-svn: 325159
* [clang-format] Support text proto extensionsKrasimir Georgiev2018-02-133-6/+41
| | | | | | | | | | | | | | | | | | | | | | Summary: This adds support for text proto extensions, like: ``` msg { [type.type/ext] { key: value } } ``` Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43180 llvm-svn: 324995
* [clang-format] Fix comment indentation in text protosKrasimir Georgiev2018-02-121-0/+1
| | | | | | | | | | Summary: This patch fixes a bug where the comment indent of comments in text protos gets messed up because by default paren states get created with AlignColons = true (which makes snese for ObjC). Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43194 llvm-svn: 324896
* clang-format: keep ObjC colon alignment with short object nameFrancois Ferrand2018-02-092-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When the target object expression is short and the first selector name is long, clang-format used to break the colon alignment: [I performSelectorOnMainThread:@selector(loadAccessories) withObject:nil waitUntilDone:false]; This happens because the colon is placed at `ContinuationIndent + LongestObjCSelectorName`, so that any selector can be wrapped. This is however not needed in case the longest selector is the firstone, and not wrapped. To overcome this, this patch does not include the first selector in `LongestObjCSelectorName` computation (in TokenAnnotator), and lets `ContinuationIndenter` decide how to account for the first selector when wrapping. (Note this was already partly the case, see line 521 of ContinuationIndenter.cpp) This way, the code gets properly aligned whenever possible without breaking the continuation indent. [I performSelectorOnMainThread:@selector(loadAccessories) withObject:nil waitUntilDone:false]; [I // force break performSelectorOnMainThread:@selector(loadAccessories) withObject:nil waitUntilDone:false]; [I perform:@selector(loadAccessories) withSelectorOnMainThread:true waitUntilDone:false]; Reviewers: krasimir, djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43121 llvm-svn: 324741
* [clang-format] Do not break Objective-C string literals inside array literalsBen Hamilton2018-02-082-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Concatenating Objective-C string literals inside an array literal raises the warning -Wobjc-string-concatenation (which is enabled by default). clang-format currently splits and concatenates string literals like the following: NSArray *myArray = @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ]; into: NSArray *myArray = @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaa" @"aaaaaaaaa" ]; which raises the warning. This is https://bugs.llvm.org/show_bug.cgi?id=36153 . The options I can think of to fix this are: 1) Have clang-format disable Wobjc-string-concatenation by emitting pragmas around the formatted code 2) Have clang-format wrap the string literals in a macro (which disables the warning) 3) Disable string splitting for Objective-C string literals inside array literals I think 1) has no precedent, and I couldn't find a good identity() macro for 2). So, this diff implements 3). Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: jolesiak, stephanemoore, djasper Reviewed By: jolesiak Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42704 llvm-svn: 324618
* [clang-format] Do not break before long string literals in protosKrasimir Georgiev2018-02-083-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is a follow-up to r323319 (which disables string literal breaking for text protos) and it disables breaking before long string literals. For example this: ``` keyyyyy: "long string literal" ``` used to get broken into: ``` keyyyyy: "long string literal" ``` While at it, I also enabled it for LK_Proto and fixed a bug in the mustBreak code. Reviewers: djasper, sammccall Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42957 llvm-svn: 324591
* [clang-format] Set ObjCBinPackProtocolList to Never for google styleBen Hamilton2018-02-081-0/+1
| | | | | | | | | | | | | | | | | | | | Summary: This is split off from D42650, and sets ObjCBinPackProtocolList to Never for the google style. Depends On D42650 Test Plan: New tests added. make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak, stephanemoore Reviewed By: krasimir, jolesiak, stephanemoore Subscribers: klimek, cfe-commits, hokein, Wizard Differential Revision: https://reviews.llvm.org/D42708 llvm-svn: 324553
* [clang-format] Fix ObjC message arguments formatting.Jacek Olesiak2018-02-073-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fixes formatting of ObjC message arguments when inline block is a first argument. Having inline block as a first argument when method has multiple parameters is discouraged by Apple: "It’s best practice to use only one block argument to a method. If the method also needs other non-block arguments, the block should come last" (https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW7), it should be correctly formatted nevertheless. Current formatting: ``` [object blockArgument:^{ a = 42; } anotherArg:42]; ``` Fixed (colon alignment): ``` [object blockArgument:^{ a = 42; } anotherArg:42]; ``` Test Plan: make -j12 FormatTests && tools/clang/unittests/Format/FormatTests Reviewers: krasimir, benhamilton Reviewed By: krasimir, benhamilton Subscribers: benhamilton, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42493 llvm-svn: 324469
* [clang-format] Add more tests for Objective-C 2.0 generic alignmentBen Hamilton2018-02-061-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In r236412, @djasper added a comment: // FIXME: We likely want to do this for more combinations of brackets. // Verify that it is wanted for ObjC, too. In D42650, @stephanemoore asked me to confirm this. This followup to D42650 adds more tests to verify the relative alignment behavior for Objective-C 2.0 generics passed to functions and removes the second half of the FIXME comment. Test Plan: make -j12 FormatTests && \ ./tools/clang/unittests/Format/FormatTests --gtest_filter=FormatTestObjC.\* Reviewers: stephanemoore, jolesiak, djasper Reviewed By: jolesiak Subscribers: klimek, cfe-commits, djasper, stephanemoore, krasimir Differential Revision: https://reviews.llvm.org/D42864 llvm-svn: 324364
* Test commit - fixing a comment.Jacek Olesiak2018-02-061-2/+2
| | | | | | | | | | | | | | Summary: A test commit. Reviewers: krasimir, benhamilton Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42901 llvm-svn: 324338
* [clang-format] Adds space around angle brackets in text protosKrasimir Georgiev2018-02-063-10/+51
| | | | | | | | | | | | | | | | | | Summary: This patch adds spaces around angle brackets in text proto Google style. Previously these were detected as template openers and closers, which happened to have the expected effect. Now we detect them as scope openers and closers similarly to the way braces are handled in this context. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42727 llvm-svn: 324337
* [clang-format] Re-land: Fixup #include guard indents after parseFile()Mark Zeren2018-02-052-27/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When a preprocessor indent closes after the last line of normal code we do not correctly fixup include guard indents. For example: #ifndef HEADER_H #define HEADER_H #if 1 int i; # define A 0 #endif #endif incorrectly reformats to: #ifndef HEADER_H #define HEADER_H #if 1 int i; # define A 0 # endif #endif To resolve this issue we must fixup levels after parseFile(). Delaying the fixup introduces a new state, so consolidate include guard search state into an enum. Reviewers: krasimir, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42035 llvm-svn: 324246
* Revert "[clang-format] Fixup #include guard indents after parseFile()"Mark Zeren2018-02-052-52/+26
| | | | | | | | This reverts r324238 | mzeren-vmw | 2018-02-05 06:35:54 -0800 (Mon, 05 Feb 2018) | 35 lines Incorrect version pushed upstream. llvm-svn: 324239
* [clang-format] Fixup #include guard indents after parseFile()Mark Zeren2018-02-052-26/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When a preprocessor indent closes after the last line of normal code we do not correctly fixup include guard indents. For example: #ifndef HEADER_H #define HEADER_H #if 1 int i; # define A 0 #endif #endif incorrectly reformats to: #ifndef HEADER_H #define HEADER_H #if 1 int i; # define A 0 # endif #endif To resolve this issue we must fixup levels after parseFile(). Delaying the fixup introduces a new state, so consolidate include guard search state into an enum. Reviewers: krasimir, klimek Reviewed By: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42035 llvm-svn: 324238
* [clang-format] New format param ObjCBinPackProtocolListBen Hamilton2018-02-022-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is an alternative approach to D42014 after some investigation by stephanemoore@ and myself. Previously, the format parameter `BinPackParameters` controlled both C function parameter list bin-packing and Objective-C protocol conformance list bin-packing. We found in the Google style, some teams were changing `BinPackParameters` from its default (`true`) to `false` so they could lay out Objective-C protocol conformance list items one-per-line instead of bin-packing them into as few lines as possible. To allow teams to use one-per-line Objective-C protocol lists without changing bin-packing for other areas like C function parameter lists, this diff introduces a new LibFormat parameter `ObjCBinPackProtocolList` to control the behavior just for ObjC protocol conformance lists. The new parameter is an enum which defaults to `Auto` to keep the previous behavior (delegating to `BinPackParameters`). Depends On D42649 Test Plan: New tests added. make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: jolesiak, stephanemoore, djasper Reviewed By: stephanemoore Subscribers: Wizard, hokein, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42650 llvm-svn: 324131
* [clang-format] Align preprocessor comments with #Mark Zeren2018-01-311-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: r312125, which introduced preprocessor indentation, shipped with a known issue where "indentation of comments immediately before indented preprocessor lines is toggled on each run". For example these two forms toggle: #ifndef HEADER_H #define HEADER_H #if 1 // comment # define A 0 #endif #endif #ifndef HEADER_H #define HEADER_H #if 1 // comment # define A 0 #endif #endif This happens because we check vertical alignment against the '#' yet indent to the level of the 'define'. This patch resolves this issue by aligning against the '#'. Reviewers: krasimir, klimek, djasper Reviewed By: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42408 llvm-svn: 323904
* [clang-format] Adds space around braces in text protosKrasimir Georgiev2018-01-311-0/+1
| | | | | | | | | | | | | | | | | Summary: This patch modifies the text proto Google style to add spaces around braces. I investigated using something different than Cpp11BracedListStyle, but it turns out it's what we want and also the java and js styles also depend on that. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42685 llvm-svn: 323860
* [clang-format] Disable some text proto delimiters and functions for google styleKrasimir Georgiev2018-01-291-9/+1
| | | | | | | | | | | | | | | | | | Summary: This disables some of the most commonly used text proto delimiters and functions for google style until we resolve several style options for that style. In particular, wheter there should be a space surrounding braces ``msg { sub { key : value } }`` and the extent of packing of submessages on a same line. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42651 llvm-svn: 323678
* clang-format: [JS] Prevent ASI before [ and (.Martin Probst2018-01-261-3/+5
| | | | | | | | | | | | | | | Summary: JavaScript automatic semicolon insertion can trigger before [ and (, so avoid breaking before them if the previous token is likely to terminate an expression. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42570 llvm-svn: 323532
* [clang-format] Fixes indentation of inner text proto messagesKrasimir Georgiev2018-01-251-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Consider the text proto: ``` message { sub { key: value } } ``` Previously the first `{` was TT_Unknown, which caused the inner message to be indented by the continuation width. This didn't happen for: ``` message { sub: { key: value } } ``` This is because the code to mark the first `{` as a TT_DictLiteral was only considering the case where it marches forward and reaches a `:`. This patch updates this by looking not only for `:`, but also for `<` and `{`. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42500 llvm-svn: 323419
* [clang-format] Disable string literal breaking for text protosKrasimir Georgiev2018-01-241-0/+6
| | | | | | | | | | | | | | | | Summary: Commonly string literals in protos are already multiline, so breaking them further is undesirable. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42373 llvm-svn: 323319
* Attempt to fix implicit-fallthrough warning after r323218.Nico Weber2018-01-241-0/+1
| | | | llvm-svn: 323294
* Fix typo in comment.Nico Weber2018-01-241-1/+1
| | | | llvm-svn: 323293
* Name two bool parameters. No behavior change.Nico Weber2018-01-231-1/+2
| | | | llvm-svn: 323228
* clang-format: Support macros in front of @interface / @protocol for ObjC code.Nico Weber2018-01-232-46/+58
| | | | llvm-svn: 323226
* clang-format: Support formatting Java 8 interface default methods.Nico Weber2018-01-231-3/+18
| | | | llvm-svn: 323218
* [clang-format] Ignore UnbreakableTailLength sometimes during breakingKrasimir Georgiev2018-01-233-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch fixes an issue where the UnbreakableTailLength would be counted towards the length of a token during breaking, even though we can break after the token. For example, this proto text with column limit 20 ``` # ColumnLimit: 20 V foo: { bar: { bazoo: "aaaaaaa" } } ``` was broken: ``` # ColumnLimit: 20 V foo: { bar: { bazoo: "aaaaaaa" } } ``` because the 2 closing `}` were counted towards the string literal's `UnbreakableTailLength`. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42376 llvm-svn: 323188
* [clang-format] Adds a canonical delimiter to raw string formattingKrasimir Georgiev2018-01-192-12/+66
| | | | | | | | | | | | | | | | Summary: This patch adds canonical delimiter support to the raw string formatting. This allows matching delimiters to be updated to the canonical one. Reviewers: bkramer Reviewed By: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42187 llvm-svn: 322956
* [clang-format] Fix shortening blocks in macros causing merged next lineKrasimir Georgiev2018-01-191-3/+9
| | | | | | | | | | | | | | | | Summary: This patch addresses bug 36002, where a combination of options causes the line following a short block in macro to be merged with that macro. Reviewers: bkramer Reviewed By: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42298 llvm-svn: 322954
* [ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google styleBen Hamilton2018-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The Google style guide is neutral on whether there should be a space before the protocol list in an Objective-C @interface or @implementation. The majority of Objective-C code in both Apple's public header files and Google's open-source uses a space before the protocol list, so this changes the google style to default ObjCSpaceBeforeProtocolList to true. Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, djasper, klimek Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41074 llvm-svn: 322873
* [clang-format] Replace unordered_set with an arrayKrasimir Georgiev2018-01-171-14/+5
| | | | | | | | | | | | | | Summary: This replaces an unordered_set from r322690 with an array and binary search. Reviewers: bkramer, benhamilton Reviewed By: bkramer, benhamilton Subscribers: jolesiak, benhamilton, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42189 llvm-svn: 322749
* [Format] Improve ObjC header guessing heuristicBen Hamilton2018-01-171-8/+116
| | | | | | | | | | | | | | | | | | | | | Summary: This improves upon the previous Objective-C header guessing heuristic from rC320479. Now, we run the lexer on C++ header files and look for Objective-C keywords and syntax. We also look for Foundation types. Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: jolesiak, krasimir Reviewed By: jolesiak Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42135 llvm-svn: 322690
* [clang-format] adds enclosing function detection to raw string formattingKrasimir Georgiev2018-01-173-15/+61
| | | | | | | | | | | | | | Summary: This patch adds enclosing function detection to raw string formatting. Reviewers: bkramer Reviewed By: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42167 llvm-svn: 322678
* [clang-format] Reorganize RawStringFormat based on languageKrasimir Georgiev2018-01-172-9/+28
| | | | | | | | | | | | | | | | | | Summary: This patch changes the structure for raw string formatting options by making it language based (enumerate delimiters per language) as opposed to delimiter-based (specify the language for a delimiter). The raw string formatting now uses an appropriate style from the .clang-format file, if exists. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42098 llvm-svn: 322634
* [clang-format] Adds a FormatStyleSetKrasimir Georgiev2018-01-151-9/+49
| | | | | | | | | | | | | | | | Summary: This patch adds a FormatStyleSet for storing per-language FormatStyles for the purposes of formatting code blocks inside the main code. Reviewers: bkramer Reviewed By: bkramer Subscribers: klimek, djasper, bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D41487 llvm-svn: 322479
OpenPOWER on IntegriCloud