https://github.com/dmaclach updated https://github.com/llvm/llvm-project/pull/220763
>From ba5a3bfcaec1f69e33d7468d84ff2244d11af20c Mon Sep 17 00:00:00 2001 From: Dave MacLachlan <[email protected]> Date: Wed, 2 Sep 2026 16:24:47 -0700 Subject: [PATCH 1/2] [include-cleaner] Add WalkAST unit tests for Objective-C constructs Adds test coverage for walking AST nodes related to: - Objective-C interface inheritance (`@interface Derived : Base`) - Forward class and protocol declarations (`@class` and `@protocol`) - Objective-C interface types used as function arguments This is just to make sure that current code is covered. No new features. --- .../include-cleaner/unittests/WalkASTTest.cpp | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp index 1e2ff594ef87a..307f1fcf8ceec 100644 --- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -579,6 +579,8 @@ TEST(WalkAST, CleanupAttr) { "void foo() { __attribute__((__cleanup__(^freep))) char* x = 0; }"); } +// Objective-C Test + TEST(WalkAST, ObjCInterfaceTypeLoc) { testWalk(R"objc( @interface $explicit^MyClass @@ -604,6 +606,18 @@ TEST(WalkAST, ObjCImplementationDeclDependsOnInterface) { {"-x", "objective-c"}); } +TEST(WalkAST, ObjCMessageExprFunctionArg) { + testWalk(R"objc( + @interface $explicit^MyClass + @end + )objc", + R"objc( + void test(^MyClass *obj) { + } + )objc", + {"-x", "objective-c"}); +} + TEST(WalkAST, ObjCMessageExprSelectorLoc) { testWalk(R"objc( @interface $implicit^MyClass @@ -1000,6 +1014,18 @@ TEST(WalkAST, ObjCPropertyRefExprSuperNestedProtocolReceiver) { {"-x", "objective-c"}); } +TEST(WalkAST, ObjCInterfaceDeclInheritance) { + testWalk(R"objc( + @interface $explicit^BaseClass + @end + )objc", + R"objc( + @interface DerivedClass : ^BaseClass + @end + )objc", + {"-x", "objective-c"}); +} + TEST(WalkAST, ObjCProtocolInType) { testWalk(R"objc( @protocol $explicit^MyProtocol @@ -1132,6 +1158,28 @@ TEST(WalkAST, ObjCCompatibleAliasUsage) { {"-x", "objective-c"}); } +TEST(WalkAST, ObjCForwardClassDecl) { + testWalk(R"objc( + @interface MyClass + @end + )objc", + R"objc( + @class ^MyClass; + )objc", + {"-x", "objective-c"}); +} + +TEST(WalkAST, ObjCForwardProtocolDecl) { + testWalk(R"objc( + @protocol MyProtocol + @end + )objc", + R"objc( + @protocol ^MyProtocol; + )objc", + {"-x", "objective-c"}); +} + TEST(WalkAST, ObjCIvarRefExprExplicit) { testWalk(R"objc( @interface MyClass { >From 1ad77686e67d3e193e2ee307db2ee3f76b9f399e Mon Sep 17 00:00:00 2001 From: Dave MacLachlan <[email protected]> Date: Sat, 5 Sep 2026 19:08:13 -0700 Subject: [PATCH 2/2] Addressed comments. --- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp index 307f1fcf8ceec..11f89c29dc039 100644 --- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -579,7 +579,7 @@ TEST(WalkAST, CleanupAttr) { "void foo() { __attribute__((__cleanup__(^freep))) char* x = 0; }"); } -// Objective-C Test +// Objective-C Tests TEST(WalkAST, ObjCInterfaceTypeLoc) { testWalk(R"objc( @@ -606,7 +606,7 @@ TEST(WalkAST, ObjCImplementationDeclDependsOnInterface) { {"-x", "objective-c"}); } -TEST(WalkAST, ObjCMessageExprFunctionArg) { +TEST(WalkAST, ObjCClassFunctionArg) { testWalk(R"objc( @interface $explicit^MyClass @end _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
