[clang] f06f016 - [clang-format][NFC] Add missing parens of __attribute in unit tests
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 2 12:46:20 PDT 2024
Author: Owen Pan
Date: 2024-06-02T12:44:40-07:00
New Revision: f06f0164199d4a968d8336937cd5ef2c05946d8d
URL: https://github.com/llvm/llvm-project/commit/f06f0164199d4a968d8336937cd5ef2c05946d8d
DIFF: https://github.com/llvm/llvm-project/commit/f06f0164199d4a968d8336937cd5ef2c05946d8d.diff
LOG: [clang-format][NFC] Add missing parens of __attribute in unit tests
Added:
Modified:
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 6057d5b724bf9..004ecb63f6620 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -14928,7 +14928,7 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
verifyFormat("union Z {\n int n;\n} x;");
verifyFormat("class MACRO Z {\n} n;");
verifyFormat("class MACRO(X) Z {\n} n;");
- verifyFormat("class __attribute__(X) Z {\n} n;");
+ verifyFormat("class __attribute__((X)) Z {\n} n;");
verifyFormat("class __declspec(X) Z {\n} n;");
verifyFormat("class A##B##C {\n} n;");
verifyFormat("class alignas(16) Z {\n} n;");
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index df268f49e1eca..a3b2569d80633 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1994,11 +1994,11 @@ TEST_F(TokenAnnotatorTest, UnderstandHashInMacro) {
TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacros) {
// '__attribute__' has special handling.
- auto Tokens = annotate("__attribute__(X) void Foo(void);");
- ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+ auto Tokens = annotate("__attribute__((X)) void Foo(void);");
+ ASSERT_EQ(Tokens.size(), 13u) << Tokens;
EXPECT_TOKEN(Tokens[0], tok::kw___attribute, TT_Unknown);
EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_AttributeLParen);
- EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_AttributeRParen);
+ EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen);
// Generic macro has no special handling in this location.
Tokens = annotate("A(X) void Foo(void);");
@@ -2020,11 +2020,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacros) {
TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacrosOnObjCDecl) {
// '__attribute__' has special handling.
- auto Tokens = annotate("__attribute__(X) @interface Foo");
- ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+ auto Tokens = annotate("__attribute__((X)) @interface Foo");
+ ASSERT_EQ(Tokens.size(), 10u) << Tokens;
EXPECT_TOKEN(Tokens[0], tok::kw___attribute, TT_Unknown);
EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_AttributeLParen);
- EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_AttributeRParen);
+ EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen);
// Generic macro has no special handling in this location.
Tokens = annotate("A(X) @interface Foo");
@@ -2048,11 +2048,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacrosOnObjCDecl) {
TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacrosOnObjCMethodDecl) {
// '__attribute__' has special handling.
- auto Tokens = annotate("- (id)init __attribute__(X);");
- ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+ auto Tokens = annotate("- (id)init __attribute__((X));");
+ ASSERT_EQ(Tokens.size(), 13u) << Tokens;
EXPECT_TOKEN(Tokens[5], tok::kw___attribute, TT_Unknown);
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_AttributeLParen);
- EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_AttributeRParen);
+ EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_AttributeRParen);
// Generic macro has no special handling in this location.
Tokens = annotate("- (id)init A(X);");
@@ -2076,11 +2076,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacrosOnObjCMethodDecl) {
TEST_F(TokenAnnotatorTest, UnderstandsAttributeMacrosOnObjCProperty) {
// '__attribute__' has special handling.
- auto Tokens = annotate("@property(weak) id delegate __attribute__(X);");
- ASSERT_EQ(Tokens.size(), 13u) << Tokens;
+ auto Tokens = annotate("@property(weak) id delegate __attribute__((X));");
+ ASSERT_EQ(Tokens.size(), 15u) << Tokens;
EXPECT_TOKEN(Tokens[7], tok::kw___attribute, TT_Unknown);
EXPECT_TOKEN(Tokens[8], tok::l_paren, TT_AttributeLParen);
- EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_AttributeRParen);
+ EXPECT_TOKEN(Tokens[12], tok::r_paren, TT_AttributeRParen);
// Generic macro has no special handling in this location.
Tokens = annotate("@property(weak) id delegate A(X);");
More information about the cfe-commits
mailing list