[Openmp-commits] [openmp] [OpenMP] Use simple VLA implementation to replace uses of actual VLA (PR #71412)

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Mon Nov 6 20:36:43 PST 2023


================
@@ -0,0 +1,42 @@
+/*
+ * kmp_utils.h -- Utilities that used internally
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+#ifndef __KMP_UTILS_H__
+#define __KMP_UTILS_H__
+
+#include <cstddef>
+
+/// A simple pure header implementation of VLA that aims to replace uses of
+/// actual VLA, which can cause compile warning.
+/// Similar to the actual VLA, we don't check boundary (for now), so we will not
+/// store the size. We can always revise it later.
+template <typename T> class SimpleVLA final {
+  T *Data = nullptr;
+
+public:
+  SimpleVLA() = delete;
+  SimpleVLA(const SimpleVLA &) = delete;
+  SimpleVLA(SimpleVLA &&) = default;
+  SimpleVLA &operator=(const SimpleVLA &) = delete;
+  SimpleVLA &operator=(SimpleVLA &&) = default;
----------------
shiltian wrote:

I removed the move functions because I don't think that is allowed by actual VLA.

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


More information about the Openmp-commits mailing list