Skip to content

Commit 7fd5c11

Browse files
committed
release/18.x: [clang-format] Revert breaking stream operators to previous default (#89016)
Backport 29ecd6d
1 parent e6c3289 commit 7fd5c11

File tree

5 files changed

+9
-26
lines changed

5 files changed

+9
-26
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5157,12 +5157,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
51575157
return true;
51585158
if (Left.IsUnterminatedLiteral)
51595159
return true;
5160-
// FIXME: Breaking after newlines seems useful in general. Turn this into an
5161-
// option and recognize more cases like endl etc, and break independent of
5162-
// what comes after operator lessless.
5163-
if (Right.is(tok::lessless) && Right.Next &&
5164-
Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
5165-
Left.TokenText.ends_with("\\n\"")) {
5160+
if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
5161+
Right.Next->is(tok::string_literal)) {
51665162
return true;
51675163
}
51685164
if (Right.is(TT_RequiresClause)) {

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27019,12 +27019,6 @@ TEST_F(FormatTest, PPBranchesInBracedInit) {
2701927019
"};");
2702027020
}
2702127021

27022-
TEST_F(FormatTest, StreamOutputOperator) {
27023-
verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
27024-
verifyFormat("std::cout << \"foo\\n\"\n"
27025-
" << \"bar\";");
27026-
}
27027-
2702827022
TEST_F(FormatTest, BreakAdjacentStringLiterals) {
2702927023
constexpr StringRef Code{
2703027024
"return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
@@ -27039,6 +27033,7 @@ TEST_F(FormatTest, BreakAdjacentStringLiterals) {
2703927033
Style.BreakAdjacentStringLiterals = false;
2704027034
verifyFormat(Code, Style);
2704127035
}
27036+
2704227037
} // namespace
2704327038
} // namespace test
2704427039
} // namespace format

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,15 +2611,6 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
26112611
EXPECT_BRACE_KIND(Tokens[14], BK_Block);
26122612
}
26132613

2614-
TEST_F(TokenAnnotatorTest, StreamOperator) {
2615-
auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
2616-
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
2617-
EXPECT_FALSE(Tokens[1]->MustBreakBefore);
2618-
EXPECT_FALSE(Tokens[3]->MustBreakBefore);
2619-
// Only break between string literals if the former ends with \n.
2620-
EXPECT_TRUE(Tokens[5]->MustBreakBefore);
2621-
}
2622-
26232614
} // namespace
26242615
} // namespace format
26252616
} // namespace clang

polly/lib/Analysis/DependenceInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,8 @@ class DependenceInfoPrinterLegacyPass final : public ScopPass {
950950
bool runOnScop(Scop &S) override {
951951
DependenceInfo &P = getAnalysis<DependenceInfo>();
952952

953-
OS << "Printing analysis '" << P.getPassName() << "' for " << "region: '"
954-
<< S.getRegion().getNameStr() << "' in function '"
953+
OS << "Printing analysis '" << P.getPassName() << "' for "
954+
<< "region: '" << S.getRegion().getNameStr() << "' in function '"
955955
<< S.getFunction().getName() << "':\n";
956956
P.printScop(OS, S);
957957

polly/lib/Analysis/ScopBuilder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,9 +2689,10 @@ void ScopBuilder::addUserContext() {
26892689
if (NameContext != NameUserContext) {
26902690
std::string SpaceStr = stringFromIslObj(Space, "null");
26912691
errs() << "Error: the name of dimension " << i
2692-
<< " provided in -polly-context " << "is '" << NameUserContext
2693-
<< "', but the name in the computed " << "context is '"
2694-
<< NameContext << "'. Due to this name mismatch, "
2692+
<< " provided in -polly-context "
2693+
<< "is '" << NameUserContext << "', but the name in the computed "
2694+
<< "context is '" << NameContext
2695+
<< "'. Due to this name mismatch, "
26952696
<< "the -polly-context option is ignored. Please provide "
26962697
<< "the context in the parameter space: " << SpaceStr << ".\n";
26972698
return;

0 commit comments

Comments
 (0)