Skip to content

Commit c0b4837

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

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
@@ -27031,12 +27031,6 @@ TEST_F(FormatTest, PPDirectivesAndCommentsInBracedInit) {
2703127031
getLLVMStyleWithColumns(30));
2703227032
}
2703327033

27034-
TEST_F(FormatTest, StreamOutputOperator) {
27035-
verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
27036-
verifyFormat("std::cout << \"foo\\n\"\n"
27037-
" << \"bar\";");
27038-
}
27039-
2704027034
TEST_F(FormatTest, BreakAdjacentStringLiterals) {
2704127035
constexpr StringRef Code{
2704227036
"return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
@@ -27051,6 +27045,7 @@ TEST_F(FormatTest, BreakAdjacentStringLiterals) {
2705127045
Style.BreakAdjacentStringLiterals = false;
2705227046
verifyFormat(Code, Style);
2705327047
}
27048+
2705427049
} // namespace
2705527050
} // namespace test
2705627051
} // namespace format

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,15 +2624,6 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
26242624
EXPECT_BRACE_KIND(Tokens[21], BK_BracedInit);
26252625
}
26262626

2627-
TEST_F(TokenAnnotatorTest, StreamOperator) {
2628-
auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
2629-
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
2630-
EXPECT_FALSE(Tokens[1]->MustBreakBefore);
2631-
EXPECT_FALSE(Tokens[3]->MustBreakBefore);
2632-
// Only break between string literals if the former ends with \n.
2633-
EXPECT_TRUE(Tokens[5]->MustBreakBefore);
2634-
}
2635-
26362627
} // namespace
26372628
} // namespace format
26382629
} // 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)