[flang-commits] [llvm] [clang-tools-extra] [flang] [clang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

Yi Wu via flang-commits flang-commits at lists.llvm.org
Thu Dec 21 11:42:39 PST 2023


================
@@ -411,6 +412,48 @@ RT_API_ATTRS void ShallowCopy(const Descriptor &to, const Descriptor &from,
     bool toIsContiguous, bool fromIsContiguous);
 RT_API_ATTRS void ShallowCopy(const Descriptor &to, const Descriptor &from);
 
+RT_API_ATTRS const char *EnsureNullTerminated(
+    const char *str, size_t length, Terminator &terminator);
+
+RT_API_ATTRS std::size_t LengthWithoutTrailingSpaces(const Descriptor &d);
+
+// Returns the length of the \p string. Assumes \p string is valid.
+RT_API_ATTRS std::int64_t StringLength(const char *string);
+
+// Assumes Descriptor \p value is not nullptr.
+RT_API_ATTRS bool IsValidCharDescriptor(const Descriptor *value);
+
+// Assumes Descriptor \p intVal is not nullptr.
+RT_API_ATTRS bool IsValidIntDescriptor(const Descriptor *intVal);
+
+// Assume Descriptor \p value is valid: pass IsValidCharDescriptor check.
+RT_API_ATTRS void FillWithSpaces(
+    const Descriptor &value, std::size_t offset = 0);
+
+RT_API_ATTRS std::int32_t CopyToDescriptor(const Descriptor &value,
+    const char *rawValue, std::int64_t rawValueLength, const Descriptor *errmsg,
+    std::size_t offset = 0);
+
+void CopyCharToDescriptor(
----------------
yi-wu-arm wrote:

add comment.
```cpp
// Copy a null-terminated character array \p rawValue to descriptor \p value.
// The copy starts at the given \p offset, if not present then start at 0.
// If descriptor `errmsg` is provided, error messages will be stored to it.
// Returns stats specified in standard.
```
the returned stats code is only used in `command.cpp` but functionality of copying is used in both `command.cpp` and `execute.cpp`

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


More information about the flang-commits mailing list