[llvm-branch-commits] [flang][runtime] Added self-printing for InternalUnit. (PR #85181)
Peter Klausler via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Mar 14 08:49:10 PDT 2024
================
@@ -41,6 +52,26 @@ InternalDescriptorUnit<DIR>::InternalDescriptorUnit(
endfileRecordNumber = d.Elements() + 1;
}
+template <Direction DIR> void InternalDescriptorUnit<DIR>::EndIoStatement() {
+ if constexpr (DIR == Direction::Output) {
+ if (usesOwnBuffer) {
+ // Null terminate the buffer that contains just a single record.
+ Terminator terminator{__FILE__, __LINE__};
+ RUNTIME_CHECK(terminator,
+ furthestPositionInRecord <
+ static_cast<std::int64_t>(ownBufferSizeInBytes));
+ *reinterpret_cast<char *>(CurrentRecord() + furthestPositionInRecord) =
+ '\0';
+
+ // Print the buffer and deallocate memory.
+ // FIXME: this output does not match the regular unit 5 output.
+ std::printf("%s\n", descriptor().OffsetElement());
+ FreeMemory(descriptor().OffsetElement());
----------------
klausler wrote:
Why not `descriptor().Deallocate()` (and `descriptor().Allocate()`)?
https://github.com/llvm/llvm-project/pull/85181
More information about the llvm-branch-commits
mailing list