From bda8482abaa87376f08700876504267bafa09880 Mon Sep 17 00:00:00 2001 From: Krasimir Georgiev Date: Thu, 18 Apr 2019 17:14:05 +0000 Subject: [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 --- clang/unittests/Format/FormatTestRawStrings.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'clang/unittests/Format/FormatTestRawStrings.cpp') 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 -- cgit v1.2.3