Index: docs/LibASTMatchersReference.html =================================================================== --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -1375,6 +1375,16 @@ +Matcher<Stmt>ompExecutableDirectiveMatcher<OMPExecutableDirective>... +
Matches any ``#pragma omp`` executable directive.
+
+Example:
+
+  #pragma omp parallel
+  #pragma omp for <...>
+
+ + Matcher<Stmt>opaqueValueExprMatcher<OpaqueValueExpr>...
Matches opaque value expressions. They are used as helpers
 to reference another expressions and can be met
Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -60,6 +60,7 @@
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
+#include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -6369,6 +6370,25 @@
   return false;
 }
 
+//----------------------------------------------------------------------------//
+// OpenMP handling.
+//----------------------------------------------------------------------------//
+
+/// Matches any ``#pragma omp`` executable directive.
+///
+/// Example:
+///
+/// \code
+///   #pragma omp parallel
+///   #pragma omp for <...>
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+    ompExecutableDirective;
+
+//----------------------------------------------------------------------------//
+// End OpenMP handling.
+//----------------------------------------------------------------------------//
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: lib/ASTMatchers/ASTMatchersInternal.cpp
===================================================================
--- lib/ASTMatchers/ASTMatchersInternal.cpp
+++ lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -845,5 +845,8 @@
     AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
                                     PointerType, ReferenceType));
 
+const internal::VariadicDynCastAllOfMatcher
+    ompExecutableDirective;
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===================================================================
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -505,6 +505,7 @@
   REGISTER_MATCHER(voidType);
   REGISTER_MATCHER(whileStmt);
   REGISTER_MATCHER(withInitializer);
+  REGISTER_MATCHER(ompExecutableDirective);
 }
 
 RegistryMaps::~RegistryMaps() = default;
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1765,5 +1765,20 @@
   EXPECT_FALSE(matchesObjC(ObjCStringNoPool, autoreleasePoolStmt()));
 }
 
+TEST(OMPExecutableDirective, Matches) {
+  auto Matcher = stmt(ompExecutableDirective());
+
+  const std::string SourceGood = R"(void x() {
+#pragma omp parallel
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(SourceGood, Matcher));
+
+  const std::string SourceBad = R"(void x() {
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(SourceBad, Matcher));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: unittests/ASTMatchers/ASTMatchersTest.h
===================================================================
--- unittests/ASTMatchers/ASTMatchersTest.h
+++ unittests/ASTMatchers/ASTMatchersTest.h
@@ -234,6 +234,18 @@
   return matchesConditionallyWithCuda(Code, AMatcher, false, "-std=c++11");
 }
 
+template 
+testing::AssertionResult matchesWithOpenMP(const std::string &Code,
+                                           const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, true, "-fopenmp");
+}
+
+template 
+testing::AssertionResult notMatchesWithOpenMP(const std::string &Code,
+                                              const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, false, "-fopenmp");
+}
+
 template 
 testing::AssertionResult
 matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,