llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tools-extra

Author: dmaclach (dmaclach)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/216497.diff


1 Files Affected:

- (modified) clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp (+40) 


``````````diff
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

``````````

</details>


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

Reply via email to