[cfe-dev] OMP4 Target Declare parse/sema patch

"C. Bergström" cbergstrom at pathscale.com
Tue Jul 1 09:19:19 PDT 2014


Hi

Trivial patch which implements OMP4 target declare. Can someone please 
review and push if is acceptable or let me know what needs fixing.

@Intel - I see you guys are missing it as well.. hopefully it helps save 
you a few minutes.

Thanks

-------------- next part --------------
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 04909b3..7e85f25 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -2178,6 +2178,7 @@ enum CXCursorKind {
   CXCursor_OMPTeamsDistributeParallelForSimdDirective = 268,
   CXCursor_OMPTargetTeamsDistributeParallelForDirective = 269,
   CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 270,
+  CXCursor_OMPDeclareTargetDirective     = 271,
 
   CXCursor_LastStmt                      = CXCursor_OMPTargetDirective,
 
diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h
index 6406992..d60d3ef 100644
--- a/include/clang/AST/DataRecursiveASTVisitor.h
+++ b/include/clang/AST/DataRecursiveASTVisitor.h
@@ -2505,6 +2505,10 @@ DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective, {
   return TraverseOMPExecutableDirective(S);
 })
 
+DEF_TRAVERSE_STMT(OMPDeclareTargetDirective, {
+  return TraverseOMPExecutableDirective(S);
+})
+
 DEF_TRAVERSE_STMT(OMPSectionsDirective, {
   return TraverseOMPExecutableDirective(S);
 })
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index ce92659..81ed9a8 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -2542,6 +2542,10 @@ DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective, {
   return TraverseOMPExecutableDirective(S);
 })
 
+DEF_TRAVERSE_STMT(OMPDeclareTargetDirective, {
+  return TraverseOMPExecutableDirective(S);
+})
+
 DEF_TRAVERSE_STMT(OMPSectionsDirective, {
   return TraverseOMPExecutableDirective(S);
 })
diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h
index ccc48da..a51f93a 100644
--- a/include/clang/AST/StmtOpenMP.h
+++ b/include/clang/AST/StmtOpenMP.h
@@ -3501,6 +3501,72 @@ public:
   }
 };
 
+/// \brief This represents '#pragma omp declare target' directive.
+///
+/// \code
+/// #pragma omp declare target(list)
+/// \endcode
+/// In this example directive '#pragma omp declare target' has list, which is
+/// a comma-separated list of named variables, procedure names and
+//  named common blocks. Common block names must appear between slashes. 
+///
+class OMPDeclareTargetDirective : public OMPExecutableDirective {
+  /// \brief Build directive with the given start and end location.
+  ///
+  /// \param StartLoc Starting location of the directive kind.
+  /// \param EndLoc Ending Location of the directive.
+  /// \param N The number of clauses.
+  ///
+  OMPDeclareTargetDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+                           unsigned N)
+      : OMPExecutableDirective(
+            OMPDeclareTargetDirectiveClass, OMPD_target_update, StartLoc, EndLoc,
+            N, reinterpret_cast<OMPClause **>(
+                   reinterpret_cast<char *>(this) +
+                   llvm::RoundUpToAlignment(sizeof(OMPDeclareTargetDirective),
+                                            llvm::alignOf<OMPClause *>())),
+            false, 0) {}
+
+  /// \brief Build an empty directive.
+  ///
+  /// \param N Number of clauses.
+  ///
+  explicit OMPDeclareTargetDirective(unsigned N)
+      : OMPExecutableDirective(
+            OMPDeclareTargetDirectiveClass, OMPD_declare_target, SourceLocation(),
+            SourceLocation(), N,
+            reinterpret_cast<OMPClause **>(
+                reinterpret_cast<char *>(this) +
+                llvm::RoundUpToAlignment(sizeof(OMPDeclareTargetDirective),
+                                         llvm::alignOf<OMPClause *>())),
+            false, 0) {}
+
+public:
+  /// \brief Creates directive with a list of \a Clauses.
+  ///
+  /// \param C AST context.
+  /// \param StartLoc Starting location of the directive kind.
+  /// \param EndLoc Ending Location of the directive.
+  /// \param Clauses List of clauses.
+  ///
+  static OMPDeclareTargetDirective *Create(const ASTContext &C,
+                                          SourceLocation StartLoc,
+                                          SourceLocation EndLoc,
+                                          ArrayRef<OMPClause *> Clauses);
+
+  /// \brief Creates an empty directive with the place for \a N clauses.
+  ///
+  /// \param C AST context.
+  /// \param N The number of clauses.
+  ///
+  static OMPDeclareTargetDirective *CreateEmpty(const ASTContext &C, unsigned N,
+                                               EmptyShell);
+
+  static bool classof(const Stmt *T) {
+    return T->getStmtClass() == OMPDeclareTargetDirectiveClass;
+  }
+};
+
 /// \brief This represents '#pragma omp teams distribute' directive.
 ///
 /// \code
diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def
index 7d74a3c..ef8ffcd 100644
--- a/include/clang/Basic/OpenMPKinds.def
+++ b/include/clang/Basic/OpenMPKinds.def
@@ -90,6 +90,9 @@
 #ifndef OPENMP_TARGET_TEAMS_CLAUSE
 #define OPENMP_TARGET_TEAMS_CLAUSE(Name)
 #endif
+#ifndef OPENMP_DECLARE_TARGET_CLAUSE
+#define OPENMP_DECLARE_TARGET_CLAUSE(Name)
+#endif
 #ifndef OPENMP_DEFAULT_KIND
 #define OPENMP_DEFAULT_KIND(Name)
 #endif
@@ -656,6 +659,7 @@ OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(map)
 #undef OPENMP_TARGET_UPDATE_CLAUSE
 #undef OPENMP_TARGET_TEAMS_CLAUSE
 #undef OPENMP_TARGET_DATA_CLAUSE
+#undef OPENMP_DECLARE_TARGET_CLAUSE
 #undef OPENMP_REDUCTION_OPERATOR
 #undef OPENMP_MAP_KIND
 #undef OPENMP_DEPENDENCE_TYPE
diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td
index 362dd76..f16816d 100644
--- a/include/clang/Basic/StmtNodes.td
+++ b/include/clang/Basic/StmtNodes.td
@@ -260,6 +260,7 @@ def OMPTeamsDistributeParallelForDirective : DStmt<OMPExecutableDirective>;
 def OMPTeamsDistributeParallelForSimdDirective : DStmt<OMPExecutableDirective>;
 def OMPTargetTeamsDistributeParallelForDirective : DStmt<OMPExecutableDirective>;
 def OMPTargetTeamsDistributeParallelForSimdDirective : DStmt<OMPExecutableDirective>;
+def OMPDeclareTargetDirective : DStmt<OMPExecutableDirective>;
 
 // Fortran Expressions
 include "clang/Basic/Fortran/ExprNodes.td"
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 61dcbfc..ce4d095 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -7555,6 +7555,11 @@ public:
   StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses,
                                         Stmt *AStmt, SourceLocation StartLoc,
                                         SourceLocation EndLoc);
+  /// \brief Called on well-formed '\#pragma omp target' after parsing
+  /// of the  associated statement.
+  StmtResult ActOnOpenMPDeclareTargetDirective(ArrayRef<OMPClause *> Clauses,
+                                        Stmt *AStmt, SourceLocation StartLoc,
+                                        SourceLocation EndLoc);
   /// \brief Called on well-formed '\#pragma omp target data' after parsing
   /// of the  associated statement.
   StmtResult ActOnOpenMPTargetDataDirective(ArrayRef<OMPClause *> Clauses,
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 3d1602d..697f702 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -1368,6 +1368,7 @@ namespace clang {
       STMT_OMP_CANCEL_DIRECTIVE,
       STMT_OMP_CANCELLATION_POINT_DIRECTIVE,
       STMT_OMP_TARGET_DIRECTIVE,
+      STMT_OMP_DECLARE_TARGET_DIRECTIVE,
       STMT_OMP_TARGET_DATA_DIRECTIVE,
       STMT_OMP_TARGET_UPDATE_DIRECTIVE,
       STMT_OMP_TARGET_TEAMS_DIRECTIVE,
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index f3fed32..d06eeff 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -2188,6 +2188,48 @@ OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
       OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, N);
 }
 
+OMPDeclareTargetDirective *
+OMPDeclareTargetDirective::Create(
+    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+    ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *NewIterVar,
+    Expr *NewIterEnd, Expr *Init, Expr *Final, Expr *LowerBound,
+    Expr *UpperBound, ArrayRef<Expr *> VarCnts) {
+  void *Mem =
+      C.Allocate(llvm::RoundUpToAlignment(
+                     sizeof(OMPDeclareTargetDirective),
+                     llvm::alignOf<OMPClause *>()) +
+                 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *) * 7 +
+                 sizeof(Stmt *) * VarCnts.size() + 2);
+  OMPDeclareTargetDirective *Dir =
+      new (Mem) OMPDeclareTargetDirective(
+          StartLoc, EndLoc, VarCnts.size(), Clauses.size());
+  Dir->setClauses(Clauses);
+  Dir->setAssociatedStmt(AssociatedStmt);
+  Dir->setNewIterVar(NewIterVar);
+  Dir->setNewIterEnd(NewIterEnd);
+  Dir->setInit(Init);
+  Dir->setFinal(Final);
+  Dir->setLowerBound(LowerBound);
+  Dir->setUpperBound(UpperBound);
+  Dir->setCounters(VarCnts);
+  return Dir;
+}
+
+OMPDeclareTargetDirective *
+OMPDeclareTargetDirective::CreateEmpty(const ASTContext &C,
+                                                          unsigned N,
+                                                          unsigned CollapsedNum,
+                                                          EmptyShell) {
+  void *Mem =
+      C.Allocate(llvm::RoundUpToAlignment(
+                     sizeof(OMPDeclareTargetDirective),
+                     llvm::alignOf<OMPClause *>()) +
+                 sizeof(OMPClause *) * N + sizeof(Stmt *) * 7 +
+                 sizeof(Stmt *) * CollapsedNum);
+  return new (Mem)
+      OMPDeclareTargetDirective(CollapsedNum, N);
+}
+
 OMPTargetTeamsDistributeParallelForSimdDirective *
 OMPTargetTeamsDistributeParallelForSimdDirective::Create(
     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index d6c6ef2..a7c7ee3 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -1302,6 +1302,12 @@ void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForDirective(
   VisitOMPExecutableDirective(Node);
 }
 
+void StmtPrinter::VisitOMPDeclareTargetDirective(
+    OMPDeclareTargetDirective *Node) {
+  Indent() << "#pragma omp target teams distribute parallel for ";
+  VisitOMPExecutableDirective(Node);
+}
+
 void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
     OMPTargetTeamsDistributeParallelForSimdDirective *Node) {
   Indent() << "#pragma omp target teams distribute parallel for simd ";
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index cccd141..cda2142 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -546,6 +546,10 @@ void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
   VisitOMPExecutableDirective(S);
 }
 
+void StmtProfiler::VisitOMPDeclareTargetDirective(const OMPDeclareTargetDirective *S) {
+  VisitOMPExecutableDirective(S);
+}
+
 void
 StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
   VisitOMPExecutableDirective(S);
diff --git a/lib/Basic/OpenMPKinds.cpp b/lib/Basic/OpenMPKinds.cpp
index d93314c..18ad0db 100644
--- a/lib/Basic/OpenMPKinds.cpp
+++ b/lib/Basic/OpenMPKinds.cpp
@@ -459,6 +459,16 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
       break;
     }
     break;
+  case OMPD_declare_target:
+    switch (CKind) {
+#define OPENMP_DECLARE_TARGET_CLAUSE(Name)                                             \
+  case OMPC_##Name:                                                            \
+    return true;
+#include "clang/Basic/OpenMPKinds.def"
+    default:
+      break;
+    }
+    break;
   case OMPD_target_data:
     switch (CKind) {
 #define OPENMP_TARGET_DATA_CLAUSE(Name)                                        \
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 46c048d..f4983d1 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -213,6 +213,10 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
       EmitOMPTargetTeamsDistributeParallelForDirective(
           cast<OMPTargetTeamsDistributeParallelForDirective>(*S));
       break;
+    case Stmt::OMPDeclareTargetDirectiveClass:
+      EmitOMPDeclareTargetDirective(
+          cast<OMPDeclareTargetDirective>(*S));
+      break;
     case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
       EmitOMPTargetTeamsDistributeParallelForSimdDirective(
           cast<OMPTargetTeamsDistributeParallelForSimdDirective>(*S));
diff --git a/lib/Parse/ParseOpenMP.cpp b/lib/Parse/ParseOpenMP.cpp
index d2f7483..265cc02 100644
--- a/lib/Parse/ParseOpenMP.cpp
+++ b/lib/Parse/ParseOpenMP.cpp
@@ -59,6 +59,21 @@ OpenMPDirectiveKind Parser::ParseOpenMPDirective() {
     }
     break;
   }
+case OMPD_declare_update: {
+    // This is to get correct directive name in the error message below.
+    // This whole switch actually should be extracted into a helper routine
+    // and reused in ParseOpenMPDeclarativeOrExecutableDirective below.
+    Token SavedToken = PP.LookAhead(0);
+    if (!SavedToken.isAnnotation()) {
+      OpenMPDirectiveKind SDKind =
+          getOpenMPDirectiveKind(PP.getSpelling(SavedToken));
+      if (SDKind == OMPD_declare_update) {
+        DKind = OMPD_declare_update;
+        ConsumeAnyToken();
+      }
+    }
+    break;
+  }
   case OMPD_distribute: {
     // This is to get correct directive name in the error message below.
     // This whole switch actually should be extracted into a helper routine
@@ -771,6 +786,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) {
   case OMPD_atomic:
   case OMPD_ordered:
   case OMPD_target:
+  case OMPD_declare_target:
   case OMPD_target_data:
   case OMPD_target_teams:
   case OMPD_teams_distribute:
diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp
index 8337dbd..e8506e3 100644
--- a/lib/Sema/SemaOpenMP.cpp
+++ b/lib/Sema/SemaOpenMP.cpp
@@ -2313,6 +2313,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
     Res = ActOnOpenMPTargetTeamsDirective(ClausesWithImplicit, AStmt, StartLoc,
                                           EndLoc);
     break;
+  case OMPD_declare_target:
+    Res = ActOnOpenMPDeclareTargetDirective(ClausesWithImplicit, AStmt, StartLoc,
+                                          EndLoc);
+    break;
   case OMPD_distribute:
     Res = ActOnOpenMPDistributeDirective(ClausesWithImplicit, AStmt, StartLoc,
                                          EndLoc);
@@ -3389,6 +3393,17 @@ StmtResult Sema::ActOnOpenMPMasterDirective(Stmt *AStmt,
 }
 
 StmtResult
+Sema::ActOnOpenMPDeclareTargetDirective(const DeclarationNameInfo &DirName,
+                                   Stmt *AStmt, SourceLocation StartLoc,
+                                   SourceLocation EndLoc) {
+  getCurFunction()->setHasBranchProtectedScope();
+
+  return Owned(
+      OMPDeclareTargetDirective::Create(Context, DirName, StartLoc, EndLoc, AStmt));
+}
+
+
+StmtResult
 Sema::ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName,
                                    Stmt *AStmt, SourceLocation StartLoc,
                                    SourceLocation EndLoc) {
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index fe7f716..988a457 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -7255,6 +7255,16 @@ TreeTransform<Derived>::TransformOMPTargetDirective(OMPTargetDirective *D) {
 }
 
 template <typename Derived>
+StmtResult
+TreeTransform<Derived>::TransformOMPDeclareTargetDirective(OMPDeckareTargetDirective *D) {
+  DeclarationNameInfo DirName;
+  getDerived().getSema().StartOpenMPDSABlock(OMPD_declare_target, DirName, 0);
+  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
+  getDerived().getSema().EndOpenMPDSABlock(Res.get());
+  return Res;
+}
+
+template <typename Derived>
 StmtResult TreeTransform<Derived>::TransformOMPTargetDataDirective(
     OMPTargetDataDirective *D) {
   DeclarationNameInfo DirName;
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index 11a8d31..2cd0479 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -2607,6 +2607,12 @@ void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
   VisitOMPExecutableDirective(D);
 }
 
+void ASTStmtReader::VisitOMPDeclareTargetDirective(OMPDeclareTargetDirective *D) {
+  VisitStmt(D);
+  ++Idx;
+  VisitOMPExecutableDirective(D);
+}
+
 void ASTStmtReader::VisitOMPTeamsDistributeDirective(OMPTeamsDistributeDirective *D) {
   VisitStmt(D);
   Idx += 2;
@@ -3685,6 +3691,10 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
       S = OMPTargetDirective::CreateEmpty(
           Context, Record[ASTStmtReader::NumStmtFields], Empty);
       break;
+    case STMT_OMP_DECLARE_TARGET_DIRECTIVE:
+      S = OMPDeclareTargetDirective::CreateEmpty(
+          Context, Record[ASTStmtReader::NumStmtFields], Empty);
+      break;
     case STMT_OMP_TARGET_DATA_DIRECTIVE:
       S = OMPTargetDataDirective::CreateEmpty(
           Context, Record[ASTStmtReader::NumStmtFields], Empty);
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index 9166967..a629c76 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -2520,6 +2520,13 @@ void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective *D) {
   Code = serialization::STMT_OMP_TARGET_DIRECTIVE;
 }
 
+void ASTStmtWriter::VisitOMPDeclareTargetDirective(OMPDeclareTargetDirective *D) {
+  VisitStmt(D);
+  Record.push_back(D->getNumClauses());
+  VisitOMPExecutableDirective(D);
+  Code = serialization::STMT_OMP_DECLARE_TARGET_DIRECTIVE;
+}
+
 void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
   VisitStmt(D);
   Record.push_back(D->getNumClauses());
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp
index e1fb09a..7e02f6b 100644
--- a/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -781,6 +781,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
     case Stmt::OMPCancelDirectiveClass:
     case Stmt::OMPCancellationPointDirectiveClass:
     case Stmt::OMPTargetDirectiveClass:
+    case Stmt::OMPDeclareTargetDirectiveClass:
     case Stmt::OMPTargetDataDirectiveClass:
     case Stmt::OMPTargetUpdateDirectiveClass:
     case Stmt::OMPTeamsDistributeDirectiveClass:
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 5993d69..f3a9b49 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1906,6 +1906,7 @@ public:
   void VisitOMPCancellationPointDirective(
                        const OMPCancellationPointDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
+  void VisitOMPDeclareTargetDirective(const OMPDeclareTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
   void VisitOMPTargetUpdateDirective(const OMPTargetUpdateDirective *D);
   void VisitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective *D);
@@ -2542,6 +2543,10 @@ void EnqueueVisitor::VisitOMPTargetDirective(const OMPTargetDirective *D) {
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPDeclareTargetDirective(const OMPDeclareTargetDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void
 EnqueueVisitor::VisitOMPTargetDataDirective(const OMPTargetDataDirective *D) {
   VisitOMPExecutableDirective(D);
@@ -4296,6 +4301,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
     return cxstring::createRef("OMPCancellationPointDirective");
   case CXCursor_OMPTargetDirective:
     return cxstring::createRef("OMPTargetDirective");
+  case CXCursor_OMPDeclareTargetDirective:
+    return cxstring::createRef("OMPDeclareTargetDirective");
   case CXCursor_OMPTargetDataDirective:
     return cxstring::createRef("OMPTargetDataDirective");
   case CXCursor_OMPTargetUpdateDirective:
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index 73b05cd..4cf3726 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
   case Stmt::OMPTargetDirectiveClass:
     K = CXCursor_OMPTargetDirective;
     break;
+  case Stmt::OMPDeclareTargetDirectiveClass:
+    K = CXCursor_OMPDeclareTargetDirective;
+    break;
   case Stmt::OMPTargetDataDirectiveClass:
     K = CXCursor_OMPTargetDataDirective;
     break;


More information about the cfe-dev mailing list