summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 1802eba2e18..012ca117c29 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2274,6 +2274,71 @@ TEST(Matcher, isMain) {
notMatches("int main2() {}", functionDecl(isMain())));
}
+TEST(OMPExecutableDirective, isStandaloneDirective) {
+ auto Matcher = ompExecutableDirective(isStandaloneDirective());
+
+ const std::string Source0 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+ const std::string Source1 = R"(
+void x() {
+#pragma omp taskyield
+})";
+ EXPECT_TRUE(matchesWithOpenMP(Source1, Matcher));
+}
+
+TEST(Stmt, isOMPStructuredBlock) {
+ const std::string Source0 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+ EXPECT_TRUE(
+ matchesWithOpenMP(Source0, stmt(nullStmt(), isOMPStructuredBlock())));
+
+ const std::string Source1 = R"(
+void x() {
+#pragma omp parallel
+{;}
+})";
+ EXPECT_TRUE(
+ notMatchesWithOpenMP(Source1, stmt(nullStmt(), isOMPStructuredBlock())));
+ EXPECT_TRUE(
+ matchesWithOpenMP(Source1, stmt(compoundStmt(), isOMPStructuredBlock())));
+}
+
+TEST(OMPExecutableDirective, hasStructuredBlock) {
+ const std::string Source0 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP(
+ Source0, ompExecutableDirective(hasStructuredBlock(nullStmt()))));
+
+ const std::string Source1 = R"(
+void x() {
+#pragma omp parallel
+{;}
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(
+ Source1, ompExecutableDirective(hasStructuredBlock(nullStmt()))));
+ EXPECT_TRUE(matchesWithOpenMP(
+ Source1, ompExecutableDirective(hasStructuredBlock(compoundStmt()))));
+
+ const std::string Source2 = R"(
+void x() {
+#pragma omp taskyield
+{;}
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(
+ Source2, ompExecutableDirective(hasStructuredBlock(anything()))));
+}
+
TEST(OMPExecutableDirective, hasClause) {
auto Matcher = ompExecutableDirective(hasAnyClause(anything()));
OpenPOWER on IntegriCloud