diff options
author | Krasimir Georgiev <krasimir@google.com> | 2019-04-18 17:14:05 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2019-04-18 17:14:05 +0000 |
commit | bda8482abaa87376f08700876504267bafa09880 (patch) | |
tree | 3a61efe6587a50d8bd142f08ab1ba55911cba5ce /clang/unittests/Format/FormatTestRawStrings.cpp | |
parent | adf288c5d93e60a91fe226ae2dcebad0f760a259 (diff) | |
download | bcm5719-llvm-bda8482abaa87376f08700876504267bafa09880.tar.gz bcm5719-llvm-bda8482abaa87376f08700876504267bafa09880.zip |
[clang-format] Fix indent of trailing raw string param after newline
Summary:
Currently clang-format uses ContinuationIndent to indent the contents of a raw
string literal that is the last parameter of the function call. This is to
achieve formatting similar to trailing:
```
f(1, 2, R"pb(
x: y)pb");
```
However this had the unfortunate consequence of producing format like this:
```
fffffff(1, 2,
R"pb(
a: b
)pb");
```
This patch makes clang-format consider indenting a trailing raw string param
after a newline based off the start of the format delimiter, producing:
```
fffffff(1, 2,
R"pb(
a: b
)pb");
```
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60558
llvm-svn: 358689
Diffstat (limited to 'clang/unittests/Format/FormatTestRawStrings.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestRawStrings.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestRawStrings.cpp b/clang/unittests/Format/FormatTestRawStrings.cpp index 04b53c5ab39..dc2f6b51807 100644 --- a/clang/unittests/Format/FormatTestRawStrings.cpp +++ b/clang/unittests/Format/FormatTestRawStrings.cpp @@ -981,6 +981,20 @@ int f() { })test", Style)); } +TEST_F(FormatTestRawStrings, IndentsLastParamAfterNewline) { + FormatStyle Style = getRawStringPbStyleWithColumns(60); + expect_eq(R"test( +fffffffffffffffffffff("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + R"pb( + b: c + )pb");)test", + format(R"test( +fffffffffffffffffffff("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + R"pb( + b: c + )pb");)test", + Style)); +} } // end namespace } // end namespace format } // end namespace clang |