[clang-tools-extra] ad9259c - [include-cleaner] Add WalkAST unit tests for Objective-C constructs (#220763)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 5 19:27:48 PDT 2026
Author: Dave MacLachlan
Date: 2026-09-06T02:27:43Z
New Revision: ad9259c18b15f1d2c35e2f8748afc7fd13c2e976
URL: https://github.com/llvm/llvm-project/commit/ad9259c18b15f1d2c35e2f8748afc7fd13c2e976
DIFF: https://github.com/llvm/llvm-project/commit/ad9259c18b15f1d2c35e2f8748afc7fd13c2e976.diff
LOG: [include-cleaner] Add WalkAST unit tests for Objective-C constructs (#220763)
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.
Added:
Modified:
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index 742a74aae41e3..23f0ec4468450 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 Tests
+
TEST(WalkAST, ObjCInterfaceTypeLoc) {
testWalk(R"objc(
@interface $explicit^MyClass
@@ -604,6 +606,18 @@ TEST(WalkAST, ObjCImplementationDeclDependsOnInterface) {
{"-x", "objective-c"});
}
+TEST(WalkAST, ObjCClassFunctionArg) {
+ 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 {
More information about the cfe-commits
mailing list