[flang-commits] [flang] [flang] Add GETCWD runtime and lowering intrinsics implementation (PR #92746)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon May 20 08:27:08 PDT 2024


================
@@ -239,4 +241,22 @@ std::int32_t RTNAME(GetEnvVariable)(const Descriptor &name,
   return StatOk;
 }
 
+std::int32_t RTNAME(GetCwd)(
+    const Descriptor &cwd, const char *sourceFile, int line) {
+  Terminator terminator{sourceFile, line};
+
+  RUNTIME_CHECK(terminator, IsValidCharDescriptor(&cwd));
+
+  char *buf = getcwd(nullptr, 0);
+  if (!buf) {
+    return StatMissingCurrentWorkDirectory;
+  }
+
+  std::int64_t strLen = StringLength(buf);
----------------
klausler wrote:

Use braced initialization in the runtime.  It is safer, especially with integer types.

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


More information about the flang-commits mailing list