[clang] [clang-format] Change GNU style language standard to LS_Latest (PR #104669)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 17 03:30:29 PDT 2024
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/104669
>From d7c7c0da69864067999ecd9b1621fdbb85d4d365 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Sat, 17 Aug 2024 02:32:19 -0700
Subject: [PATCH 1/2] [clang-format] Change GNU style language standard to
LS_Latest
Fixes #104655.
---
clang/lib/Format/Format.cpp | 1 -
clang/unittests/Format/TokenAnnotatorTest.cpp | 8 ++++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 5358b35c19de25..e8fe17ecee1837 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1904,7 +1904,6 @@ FormatStyle getGNUStyle() {
Style.Cpp11BracedListStyle = false;
Style.FixNamespaceComments = false;
Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
- Style.Standard = FormatStyle::LS_Cpp03;
return Style;
}
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 256bbd49c424fa..c40df0794ab9ae 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3360,6 +3360,14 @@ TEST_F(TokenAnnotatorTest, TypenameMacro) {
EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_Unknown);
}
+TEST_F(TokenAnnotatorTest, GNULanguageStandard) {
+ auto Style = getGNUStyle();
+ EXPECT_EQ(Style.Standard, FormatStyle::LS_Latest);
+
+ auto Tokens = annotate("return 1 <=> 2;", Style);
+ EXPECT_TOKEN(Tokens[2], tok::spaceship, TT_BinaryOperator);
+}
+
} // namespace
} // namespace format
} // namespace clang
>From 9a5913fd3bf4bb682d4647ad8bf77689a1b9d6ee Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Sat, 17 Aug 2024 03:30:21 -0700
Subject: [PATCH 2/2] Update TokenAnnotatorTest.cpp
---
clang/unittests/Format/TokenAnnotatorTest.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index c40df0794ab9ae..99798de43e70ff 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3365,6 +3365,7 @@ TEST_F(TokenAnnotatorTest, GNULanguageStandard) {
EXPECT_EQ(Style.Standard, FormatStyle::LS_Latest);
auto Tokens = annotate("return 1 <=> 2;", Style);
+ ASSERT_EQ(Tokens.size(), 6u);
EXPECT_TOKEN(Tokens[2], tok::spaceship, TT_BinaryOperator);
}
More information about the cfe-commits
mailing list