https://github.com/dmaclach created 
https://github.com/llvm/llvm-project/pull/216497

This adds tests to verify that include cleaner covers `@catch`, `@synchronized` 
and `@encode` statements. The current code was complete, this just adds test 
verification.

>From 4240849271b85913381de736867f0189ab1c70b5 Mon Sep 17 00:00:00 2001
From: Dave MacLachlan <[email protected]>
Date: Sat, 15 Aug 2026 09:58:54 -0700
Subject: [PATCH] [include-cleaner][objc] Add Tests for completeness for
 @catch, @synchronized, and @encode.

This adds tests to verify that include cleaner covers `@catch`, `@synchronized` 
and
`@encode` statements. The current code was complete, this just adds test 
verification.
---
 .../include-cleaner/unittests/WalkASTTest.cpp | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index bb3480a181577..9ed25d852ef01 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -1388,5 +1388,45 @@ TEST(WalkAST, ObjcSelectorCustomGetterClashWithMethod) {
            {"-x", "objective-c"});
 }
 
+TEST(WalkAST, ObjCAtCatchStmt) {
+  testWalk(R"objc(
+    @interface $explicit^CustomException
+    @end
+  )objc",
+           R"objc(
+    void test() {
+      @try {}
+      @catch (^CustomException *e) {}
+    }
+  )objc",
+           {"-x", "objective-c", "-fobjc-exceptions"});
+}
+
+TEST(WalkAST, ObjCAtSynchronizedStmt) {
+  testWalk(R"objc(
+    @interface $explicit^LockObject
+    + (id)sharedLock;
+    @end
+  )objc",
+           R"objc(
+    void test() {
+      @synchronized([^LockObject sharedLock]) {}
+    }
+  )objc",
+           {"-x", "objective-c", "-fobjc-exceptions"});
+}
+
+TEST(WalkAST, ObjCEncodeExpr) {
+  testWalk(R"objc(
+    struct $explicit^MyStruct { int x; };
+  )objc",
+           R"objc(
+    void test() {
+      const char *enc = @encode(struct ^MyStruct);
+    }
+  )objc",
+           {"-x", "objective-c"});
+}
+
 } // namespace
 } // namespace clang::include_cleaner

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to