[Openmp-commits] [clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation directive and "looprange" clause (PR #139293)

Alexey Bataev via Openmp-commits openmp-commits at lists.llvm.org
Mon Sep 1 07:59:35 PDT 2025


================
@@ -6582,4 +6740,40 @@ class OMPAssumeDirective final : public OMPExecutableDirective {
 
 } // end namespace clang
 
+namespace llvm {
+// Allow a Stmt* be casted correctly to an OMPLoopTransformationDirective*.
+// The default routines would just use a C-style cast which won't work well
+// for the multiple inheritance here. We have to use a static cast from the
+// corresponding subclass.
+template <>
+struct CastInfo<clang::OMPLoopTransformationDirective, clang::Stmt *>
+    : public NullableValueCastFailed<clang::OMPLoopTransformationDirective *>,
+      public DefaultDoCastIfPossible<
+          clang::OMPLoopTransformationDirective *, clang::Stmt *,
+          CastInfo<clang::OMPLoopTransformationDirective, clang::Stmt *>> {
+  static bool isPossible(const clang::Stmt *T) {
+    return clang::OMPLoopTransformationDirective::classof(T);
+  }
+
+  static clang::OMPLoopTransformationDirective *doCast(clang::Stmt *T) {
+    if (auto *D =
+            dyn_cast<clang::OMPCanonicalLoopNestTransformationDirective>(T)) {
+      return static_cast<clang::OMPLoopTransformationDirective *>(D);
+    }
+    if (auto *D =
+            dyn_cast<clang::OMPCanonicalLoopSequenceTransformationDirective>(
+                T)) {
+      return static_cast<clang::OMPLoopTransformationDirective *>(D);
+    }
----------------
alexey-bataev wrote:

Drop braces

https://github.com/llvm/llvm-project/pull/139293


More information about the Openmp-commits mailing list