Index: clang/unittests/Format/FormatTestUtils.h =================================================================== --- clang/unittests/Format/FormatTestUtils.h +++ clang/unittests/Format/FormatTestUtils.h @@ -53,10 +53,9 @@ std::string WithoutWhitespace; if (MessedUp[0] != ' ') WithoutWhitespace.push_back(MessedUp[0]); - for (unsigned i = 1, e = MessedUp.size(); i != e; ++i) { + for (unsigned i = 1, e = MessedUp.size(); i != e; ++i) if (MessedUp[i] != ' ' || MessedUp[i - 1] != ' ') WithoutWhitespace.push_back(MessedUp[i]); - } return WithoutWhitespace; } Index: clang/unittests/Format/TokenAnnotatorTest.cpp =================================================================== --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -509,13 +509,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "struct Bar;"); @@ -529,13 +531,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "struct Bar {" @@ -555,13 +559,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "Bar(T) -> Bar;"); @@ -575,13 +581,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "T foo();"); @@ -595,13 +603,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "T foo() {\n" @@ -621,13 +631,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "T foo();"); @@ -641,13 +653,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "T foo() {\n" @@ -666,13 +680,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("template\n" "Bar(T) -> Bar;"); @@ -690,13 +706,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } BaseTokens = annotate("struct [[nodiscard]] zero_t {\n" " template\n" @@ -719,13 +737,15 @@ NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens) << ConstrainedTokens; - for (auto I = 0u; I < NumberOfBaseTokens; ++I) - if (I < NumberOfTokensBeforeRequires) + for (auto I = 0u; I < NumberOfBaseTokens; ++I) { + if (I < NumberOfTokensBeforeRequires) { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I; - else + } else { EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I + NumberOfAdditionalRequiresClauseTokens]) << I; + } + } } TEST_F(TokenAnnotatorTest, UnderstandsAsm) {