aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2024-04-19 23:58:35 -0700
committerOwen Pan <owenpiano@gmail.com>2024-04-24 21:29:46 -0700
commitc0b48372d82aa0adaef671788ee1a37a650ee4fd (patch)
tree9e8d769eb9e58214e7f2a14113d8674ef380c973
parent3b4ba7277bd735ebea489d94c4ae771427283e6e (diff)
downloadllvm-c0b48372d82aa0adaef671788ee1a37a650ee4fd.tar.gz
release/18.x: [clang-format] Revert breaking stream operators to previous default (#89016)
Backport 29ecd6d50f14
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp8
-rw-r--r--clang/unittests/Format/FormatTest.cpp7
-rw-r--r--clang/unittests/Format/TokenAnnotatorTest.cpp9
-rw-r--r--polly/lib/Analysis/DependenceInfo.cpp4
-rw-r--r--polly/lib/Analysis/ScopBuilder.cpp7
5 files changed, 9 insertions, 26 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 4d482e6543d6..9c4a8381f998 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5157,12 +5157,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
return true;
if (Left.IsUnterminatedLiteral)
return true;
- // FIXME: Breaking after newlines seems useful in general. Turn this into an
- // option and recognize more cases like endl etc, and break independent of
- // what comes after operator lessless.
- if (Right.is(tok::lessless) && Right.Next &&
- Right.Next->is(tok::string_literal) && Left.is(tok::string_literal) &&
- Left.TokenText.ends_with("\\n\"")) {
+ if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) &&
+ Right.Next->is(tok::string_literal)) {
return true;
}
if (Right.is(TT_RequiresClause)) {
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 6b4f9075d8f0..2ac0b0aab1be 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27031,12 +27031,6 @@ TEST_F(FormatTest, PPDirectivesAndCommentsInBracedInit) {
getLLVMStyleWithColumns(30));
}
-TEST_F(FormatTest, StreamOutputOperator) {
- verifyFormat("std::cout << \"foo\" << \"bar\" << baz;");
- verifyFormat("std::cout << \"foo\\n\"\n"
- " << \"bar\";");
-}
-
TEST_F(FormatTest, BreakAdjacentStringLiterals) {
constexpr StringRef Code{
"return \"Code\" \"\\0\\52\\26\\55\\55\\0\" \"x013\" \"\\02\\xBA\";"};
@@ -27051,6 +27045,7 @@ TEST_F(FormatTest, BreakAdjacentStringLiterals) {
Style.BreakAdjacentStringLiterals = false;
verifyFormat(Code, Style);
}
+
} // namespace
} // namespace test
} // namespace format
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index f767b83a8754..cbe6b79a3668 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2624,15 +2624,6 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
EXPECT_BRACE_KIND(Tokens[21], BK_BracedInit);
}
-TEST_F(TokenAnnotatorTest, StreamOperator) {
- auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";");
- ASSERT_EQ(Tokens.size(), 9u) << Tokens;
- EXPECT_FALSE(Tokens[1]->MustBreakBefore);
- EXPECT_FALSE(Tokens[3]->MustBreakBefore);
- // Only break between string literals if the former ends with \n.
- EXPECT_TRUE(Tokens[5]->MustBreakBefore);
-}
-
} // namespace
} // namespace format
} // namespace clang
diff --git a/polly/lib/Analysis/DependenceInfo.cpp b/polly/lib/Analysis/DependenceInfo.cpp
index 69257c603877..d58dc9917bc9 100644
--- a/polly/lib/Analysis/DependenceInfo.cpp
+++ b/polly/lib/Analysis/DependenceInfo.cpp
@@ -950,8 +950,8 @@ public:
bool runOnScop(Scop &S) override {
DependenceInfo &P = getAnalysis<DependenceInfo>();
- OS << "Printing analysis '" << P.getPassName() << "' for " << "region: '"
- << S.getRegion().getNameStr() << "' in function '"
+ OS << "Printing analysis '" << P.getPassName() << "' for "
+ << "region: '" << S.getRegion().getNameStr() << "' in function '"
<< S.getFunction().getName() << "':\n";
P.printScop(OS, S);
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index c62cb2a85c83..64314d6041b8 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -2689,9 +2689,10 @@ void ScopBuilder::addUserContext() {
if (NameContext != NameUserContext) {
std::string SpaceStr = stringFromIslObj(Space, "null");
errs() << "Error: the name of dimension " << i
- << " provided in -polly-context " << "is '" << NameUserContext
- << "', but the name in the computed " << "context is '"
- << NameContext << "'. Due to this name mismatch, "
+ << " provided in -polly-context "
+ << "is '" << NameUserContext << "', but the name in the computed "
+ << "context is '" << NameContext
+ << "'. Due to this name mismatch, "
<< "the -polly-context option is ignored. Please provide "
<< "the context in the parameter space: " << SpaceStr << ".\n";
return;