summaryrefslogtreecommitdiffstats
path: root/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersNodeTest.cpp74
1 files changed, 70 insertions, 4 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 1bd4e09e77..16e682aeff 100644
--- a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1,9 +1,8 @@
//== unittests/ASTMatchers/ASTMatchersNodeTest.cpp - AST matcher unit tests ==//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -755,6 +754,11 @@ TEST(Matcher, NullPtrLiteral) {
EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
}
+TEST(Matcher, ChooseExpr) {
+ EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+ chooseExpr()));
+}
+
TEST(Matcher, GNUNullExpr) {
EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
}
@@ -1761,5 +1765,67 @@ TEST(ObjCAutoreleaseMatcher, AutoreleasePool) {
EXPECT_FALSE(matchesObjC(ObjCStringNoPool, autoreleasePoolStmt()));
}
+TEST(OMPExecutableDirective, Matches) {
+ auto Matcher = stmt(ompExecutableDirective());
+
+ const std::string Source0 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP(Source0, Matcher));
+
+ const std::string Source1 = R"(
+void x() {
+#pragma omp taskyield
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP(Source1, Matcher));
+
+ const std::string Source2 = R"(
+void x() {
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source2, Matcher));
+}
+
+TEST(OMPDefaultClause, Matches) {
+ auto Matcher = ompExecutableDirective(hasAnyClause(ompDefaultClause()));
+
+ const std::string Source0 = R"(
+void x() {
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+ const std::string Source1 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source1, Matcher));
+
+ const std::string Source2 = R"(
+void x() {
+#pragma omp parallel default(none)
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP(Source2, Matcher));
+
+ const std::string Source3 = R"(
+void x() {
+#pragma omp parallel default(shared)
+;
+})";
+ EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
+
+ const std::string Source4 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+ EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+}
+
} // namespace ast_matchers
} // namespace clang