[flang] [llvm] [flang] implement `split` for fortran 2023 (PR #161484)

Connector Switch via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 19:48:18 PDT 2025


================
@@ -570,6 +570,35 @@ static RT_API_ATTRS void MaxMin(Descriptor &accumulator, const Descriptor &x,
   }
 }
 
+template <typename CHAR>
+inline RT_API_ATTRS std::size_t Split(const CHAR *x, std::size_t xLen,
+    const CHAR *set, std::size_t setLen, std::size_t pos, bool back,
+    const char *sourceFile, int sourceLine) {
+  Terminator terminator{sourceFile, sourceLine};
+
+  if (!back) {
+    RUNTIME_CHECK(terminator, pos <= xLen);
+    for (std::size_t i{pos + 1}; i <= xLen; ++i) {
+      for (std::size_t j{0}; j < setLen; ++j) {
----------------
c8ef wrote:

Yes, it has the same time complexity as the fallback implementations for scan/verify. 
I noticed that the specialized version of scan/verify for char is not being used here. I'm not sure if this is intentional or accidental. If it's accidental, #161767 will partially address this.

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


More information about the llvm-commits mailing list