[clang] [Clang][Unittest] Support for `target` update directive and `from` clause in clang unittests (PR #150580)
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 4 07:13:35 PDT 2025
================
@@ -4734,6 +4734,65 @@ void x() {
EXPECT_TRUE(matchesWithOpenMP(Source8, Matcher));
}
+TEST_P(ASTMatchersTest, OMPTargetUpdateDirective_IsStandaloneDirective) {
+ auto Matcher = ompTargetUpdateDirective(isStandaloneDirective());
+
+ StringRef Source0 = R"(
+ void foo() {
+ int arr[8];
+ #pragma omp target update from(arr[0:8:2])
+ ;
+ }
+ )";
+ EXPECT_TRUE(matchesWithOpenMP(Source0, Matcher));
+}
+
+TEST_P(ASTMatchersTest, OMPTargetUpdateDirective_HasStructuredBlock) {
+ StringRef Source0 = R"(
+ void foo() {
+ int arr[8];
+ #pragma omp target update from(arr[0:8:2])
+ ;
+ }
+ )";
+ EXPECT_TRUE(notMatchesWithOpenMP(
+ Source0, ompTargetUpdateDirective(hasStructuredBlock(nullStmt()))));
+}
+
+TEST_P(ASTMatchersTest, OMPTargetUpdateDirective_HasClause) {
+ auto Matcher = ompTargetUpdateDirective(hasAnyClause(anything()));
+
+ StringRef Source0 = R"(
+ void foo() {
+ int arr[8];
+ #pragma omp target update from(arr[0:8:2])
----------------
shiltian wrote:
same here
https://github.com/llvm/llvm-project/pull/150580
More information about the cfe-commits
mailing list