summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestTextProto.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-format] Fix comment, NFCKrasimir Georgiev2018-08-131-1/+1
| | | | llvm-svn: 339573
* [clang-format] Keep @message together in text protosKrasimir Georgiev2018-06-251-0/+18
| | | | | | | | | | | | 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
* [clang-format] Fix end-of-file comments text proto formattingKrasimir Georgiev2018-06-251-0/+17
| | | | | | | | | | | | | | | | | | | | 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
* [clang-format] Discourage breaks in submessage entries, hard ruleKrasimir Georgiev2018-06-121-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-format] text protos: put entries on separate lines if there is a ↵Krasimir Georgiev2018-06-111-10/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-format] Consider tok::hashhash in python-style commentsKrasimir Georgiev2018-06-071-0/+22
| | | | | | | | | | 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
* [clang] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-3/+3
| | | | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Explicitly avoided changing the strings in the clang-format tests. Differential Revision: https://reviews.llvm.org/D44975 llvm-svn: 332350
* [clang-format] Respect BreakBeforeClosingBrace while calculating lengthKrasimir Georgiev2018-05-091-0/+12
| | | | | | | | | | | | | | | | | | Summary: This patch makes `getLengthToMatchingParen` respect the `BreakBeforeClosingBrace` ParenState for matching scope closers. In order to distinguish between paren states introduced by real vs. fake parens, I've added the token opening the ParensState to that struct. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D46519 llvm-svn: 331857
* Revert "[clang-format] Improve Incomplete detection for (text) protos"Krasimir Georgiev2018-04-231-49/+2
| | | | | | | | This reverts commit r330016. The incomplete detection has too many false positives, picking up typos for hard failures and refusing to format anything in that case. llvm-svn: 330569
* [clang-format] Improve Incomplete detection for (text) protosKrasimir Georgiev2018-04-131-2/+49
| | | | | | | | | | | | | | | | | | Summary: This patch improves detection of incomplete code for protos and text protos. This is especially important for text protos in raw string literals, since they might be partial strings concatenated, and we'd like to disable formatting in these cases. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44203 llvm-svn: 330016
* [clang-format] Preserve spaces before a percent in (text) protosKrasimir Georgiev2018-04-051-1/+3
| | | | | | | This makes sure that we do not change the meaning of pieces of text with format specifiers. llvm-svn: 329263
* [clang-format] In tests, expected code should be format-stableMark Zeren2018-04-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: Extend various verifyFormat helper functions to check that the expected text is "stable". This provides some protection against bugs where formatting results are ocilating between two forms, or continually change in some other way. Testing Done: * Ran unit tests. * Reproduced a known instability in preprocessor indentation which was caught by this new check. Reviewers: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42034 llvm-svn: 329231
* [clang-format] Disallow breaks before ']' in text proto extensionsKrasimir Georgiev2018-03-161-4/+21
| | | | | | | | | | Summary: This disallows patterns like `[ext.name\n]` in text protos. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44569 llvm-svn: 327716
* clang-format: Properly handle implicit string concatenation in text protosDaniel Jasper2018-03-121-0/+17
| | | | | | | | | | | | | Three issues to fix: - char_constants weren't properly treated as string literals - Prevening the break after "label: " does not make sense in concunction with AlwaysBreakBeforeMultilineStrings. It leads to situations where clang-format just cannot find a viable format (it must break and yet it must not break). - AlwaysBreakBeforeMultilineStrings should not be on for LK_TextProto in Google style. llvm-svn: 327255
* [clang-format] Break consecutive string literals in text protosKrasimir Georgiev2018-03-071-0/+6
| | | | | | | | | | | | | | | | Summary: This patch fixes a bug where consecutive string literals in text protos were put on the same line. Reviewers: alexfh Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44204 llvm-svn: 326945
* [clang-format] Format operator key in protosKrasimir Georgiev2018-02-271-0/+12
| | | | | | | | | | 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] Fix text proto extension scope opening detectionKrasimir Georgiev2018-02-191-0/+8
| | | | | | | | | | | | | | | | | | | | 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] Support repeated field lists in protosKrasimir Georgiev2018-02-151-4/+46
| | | | | | | | | | | | | | | | | | 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] Recognize percents as format specifiers in protosKrasimir Georgiev2018-02-141-0/+4
| | | | | | | | | | | | | | | | 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-131-0/+61
| | | | | | | | | | | | | | | | | | | | | | 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/+12
| | | | | | | | | | 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] Do not break before long string literals in protosKrasimir Georgiev2018-02-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Adds space around angle brackets in text protosKrasimir Georgiev2018-02-061-43/+43
| | | | | | | | | | | | | | | | | | 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] Adds space around braces in text protosKrasimir Georgiev2018-01-311-20/+20
| | | | | | | | | | | | | | | | | 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] Fixes indentation of inner text proto messagesKrasimir Georgiev2018-01-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Ignore UnbreakableTailLength sometimes during breakingKrasimir Georgiev2018-01-231-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Fix indent of 'key <...>' and 'key {...}' in text protosKrasimir Georgiev2017-08-031-0/+44
| | | | | | | | | | | | | | | | | Summary: This patch fixes the indentation of the code pattern `key <...>`and `key {...}` in text protos. Previously, such line would be alinged depending on the column of the previous colon, which usually indents too much. I'm gonna go ahead and commit this since it's a straightforward bugfix. Reviewers: djasper, klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36143 llvm-svn: 309941
* [clang-format] Add space between a message field key and the opening bracket ↵Krasimir Georgiev2017-07-061-37/+36
| | | | | | | | | | | | | | | | | | in proto messages Summary: This patch updates the formatting of message fields of type `a{...}` to `a {...}` for proto messages. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D35015 llvm-svn: 307261
* [clang-format] Support text proto messagesKrasimir Georgiev2017-07-031-0/+251
Summary: This patch adds support for textual protocol buffer messages. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek, mgorny Differential Revision: https://reviews.llvm.org/D34441 llvm-svn: 307029
OpenPOWER on IntegriCloud