[clang] 626025a - Revert "[clang-format] Fix buildbot failures"
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sun May 12 18:35:42 PDT 2024
Author: Owen Pan
Date: 2024-05-12T18:35:35-07:00
New Revision: 626025ac7796b70cde9fc0fd4f688c3441949d04
URL: https://github.com/llvm/llvm-project/commit/626025ac7796b70cde9fc0fd4f688c3441949d04
DIFF: https://github.com/llvm/llvm-project/commit/626025ac7796b70cde9fc0fd4f688c3441949d04.diff
LOG: Revert "[clang-format] Fix buildbot failures"
This reverts commit 0869204cff22831d0bb19a82c99bf85e4deb4ae3, which caused a
buildbot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/43322
Added:
Modified:
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/lib/Format/QualifierAlignmentFixer.h
clang/unittests/Format/QualifierFixerTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp
index 077ce5e597a22..a904f0b773c6d 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -281,7 +281,7 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight(
const FormatToken *LastSimpleTypeSpecifier = TypeToken;
while (isQualifierOrType(LastSimpleTypeSpecifier->getNextNonComment(),
- &LangOpts)) {
+ LangOpts)) {
LastSimpleTypeSpecifier = LastSimpleTypeSpecifier->getNextNonComment();
}
@@ -414,7 +414,7 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft(
const FormatToken *LastSimpleTypeSpecifier = TypeToken;
while (isConfiguredQualifierOrType(
LastSimpleTypeSpecifier->getPreviousNonComment(),
- ConfiguredQualifierTokens, &LangOpts)) {
+ ConfiguredQualifierTokens, LangOpts)) {
LastSimpleTypeSpecifier =
LastSimpleTypeSpecifier->getPreviousNonComment();
}
@@ -613,18 +613,16 @@ void prepareLeftRightOrderingForQualifierAlignmentFixer(
}
bool LeftRightQualifierAlignmentFixer::isQualifierOrType(
- const FormatToken *Tok, const LangOptions *LangOpts) {
- return Tok &&
- (Tok->isTypeName(LangOpts ? *LangOpts : getFormattingLangOpts()) ||
- Tok->is(tok::kw_auto) || isQualifier(Tok));
+ const FormatToken *Tok, const LangOptions &LangOpts) {
+ return Tok && (Tok->isTypeName(LangOpts) || Tok->is(tok::kw_auto) ||
+ isQualifier(Tok));
}
bool LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
const FormatToken *Tok, const std::vector<tok::TokenKind> &Qualifiers,
- const LangOptions *LangOpts) {
- return Tok &&
- (Tok->isTypeName(LangOpts ? *LangOpts : getFormattingLangOpts()) ||
- Tok->is(tok::kw_auto) || isConfiguredQualifier(Tok, Qualifiers));
+ const LangOptions &LangOpts) {
+ return Tok && (Tok->isTypeName(LangOpts) || Tok->is(tok::kw_auto) ||
+ isConfiguredQualifier(Tok, Qualifiers));
}
// If a token is an identifier and it's upper case, it could
diff --git a/clang/lib/Format/QualifierAlignmentFixer.h b/clang/lib/Format/QualifierAlignmentFixer.h
index 97fcb42e4b2e5..710fa2dc00309 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.h
+++ b/clang/lib/Format/QualifierAlignmentFixer.h
@@ -72,11 +72,11 @@ class LeftRightQualifierAlignmentFixer : public TokenAnalyzer {
// Is the Token a simple or qualifier type
static bool isQualifierOrType(const FormatToken *Tok,
- const LangOptions *LangOpts = nullptr);
+ const LangOptions &LangOpts);
static bool
isConfiguredQualifierOrType(const FormatToken *Tok,
const std::vector<tok::TokenKind> &Qualifiers,
- const LangOptions *LangOpts = nullptr);
+ const LangOptions &LangOpts);
// Is the Token likely a Macro
static bool isPossibleMacro(const FormatToken *Tok);
diff --git a/clang/unittests/Format/QualifierFixerTest.cpp b/clang/unittests/Format/QualifierFixerTest.cpp
index 792d8f3c3a982..5463bfbb65ca6 100644
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -1055,70 +1055,82 @@ TEST_F(QualifierFixerTest, IsQualifierType) {
ConfiguredTokens.push_back(tok::kw_constexpr);
ConfiguredTokens.push_back(tok::kw_friend);
+ LangOptions LangOpts{getFormattingLangOpts()};
+
auto Tokens = annotate(
"const static inline auto restrict int double long constexpr friend");
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[0], ConfiguredTokens));
+ Tokens[0], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[1], ConfiguredTokens));
+ Tokens[1], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[2], ConfiguredTokens));
+ Tokens[2], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[3], ConfiguredTokens));
+ Tokens[3], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[4], ConfiguredTokens));
+ Tokens[4], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[5], ConfiguredTokens));
+ Tokens[5], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[6], ConfiguredTokens));
+ Tokens[6], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[7], ConfiguredTokens));
+ Tokens[7], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[8], ConfiguredTokens));
+ Tokens[8], ConfiguredTokens, LangOpts));
EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- Tokens[9], ConfiguredTokens));
-
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[0]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[1]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[2]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[3]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[4]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[5]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[6]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[7]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[8]));
- EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[9]));
+ Tokens[9], ConfiguredTokens, LangOpts));
+
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[0], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[1], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[2], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[3], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[4], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[5], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[6], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[7], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[8], LangOpts));
+ EXPECT_TRUE(
+ LeftRightQualifierAlignmentFixer::isQualifierOrType(Tokens[9], LangOpts));
auto NotTokens = annotate("for while do Foo Bar ");
ASSERT_EQ(NotTokens.size(), 6u) << Tokens;
EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- NotTokens[0], ConfiguredTokens));
+ NotTokens[0], ConfiguredTokens, LangOpts));
EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- NotTokens[1], ConfiguredTokens));
+ NotTokens[1], ConfiguredTokens, LangOpts));
EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- NotTokens[2], ConfiguredTokens));
+ NotTokens[2], ConfiguredTokens, LangOpts));
EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- NotTokens[3], ConfiguredTokens));
+ NotTokens[3], ConfiguredTokens, LangOpts));
EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- NotTokens[4], ConfiguredTokens));
+ NotTokens[4], ConfiguredTokens, LangOpts));
EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isConfiguredQualifierOrType(
- NotTokens[5], ConfiguredTokens));
-
- EXPECT_FALSE(
- LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[0]));
- EXPECT_FALSE(
- LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[1]));
- EXPECT_FALSE(
- LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[2]));
- EXPECT_FALSE(
- LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[3]));
- EXPECT_FALSE(
- LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[4]));
- EXPECT_FALSE(
- LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[5]));
+ NotTokens[5], ConfiguredTokens, LangOpts));
+
+ EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[0],
+ LangOpts));
+ EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[1],
+ LangOpts));
+ EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[2],
+ LangOpts));
+ EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[3],
+ LangOpts));
+ EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[4],
+ LangOpts));
+ EXPECT_FALSE(LeftRightQualifierAlignmentFixer::isQualifierOrType(NotTokens[5],
+ LangOpts));
}
TEST_F(QualifierFixerTest, IsMacro) {
More information about the cfe-commits
mailing list