From 85f626732e9b6e6eef3080953ca672e5c97f0469 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Wed, 27 Aug 2025 16:46:44 -0700 Subject: [PATCH] [flang][runtime][NFC] Clean up Fortran::common::optional<> usage When somebody replaced uses of std::optional<> in the runtime with a new optional<> defined locally, many needless top-level Fortran:: namespace qualifiers were added, which are inconsistent with namespace usage in the runtime. Clean them up. --- .../include/flang-rt/runtime/connection.h | 14 +-- .../include/flang-rt/runtime/environment.h | 2 +- flang-rt/include/flang-rt/runtime/file.h | 9 +- .../flang-rt/runtime/format-implementation.h | 14 +-- flang-rt/include/flang-rt/runtime/format.h | 8 +- flang-rt/include/flang-rt/runtime/io-stmt.h | 112 +++++++++--------- .../flang-rt/runtime/random-templates.h | 2 +- flang-rt/include/flang-rt/runtime/tools.h | 23 ++-- flang-rt/include/flang-rt/runtime/type-code.h | 2 +- flang-rt/include/flang-rt/runtime/type-info.h | 2 +- flang-rt/include/flang-rt/runtime/utf.h | 2 +- flang-rt/lib/runtime/descriptor-io.cpp | 8 +- flang-rt/lib/runtime/edit-input.cpp | 22 ++-- flang-rt/lib/runtime/environment.cpp | 5 +- flang-rt/lib/runtime/io-api-common.h | 2 +- flang-rt/lib/runtime/io-api.cpp | 10 +- flang-rt/lib/runtime/io-stmt.cpp | 34 +++--- flang-rt/lib/runtime/misc-intrinsic.cpp | 4 +- flang-rt/lib/runtime/namelist.cpp | 19 ++- flang-rt/lib/runtime/pseudo-unit.cpp | 20 ++-- flang-rt/lib/runtime/random.cpp | 2 +- flang-rt/lib/runtime/type-code.cpp | 4 +- flang-rt/lib/runtime/type-info.cpp | 6 +- flang-rt/lib/runtime/unit-map.cpp | 2 +- flang-rt/lib/runtime/unit.h | 21 ++-- flang-rt/lib/runtime/utf.cpp | 6 +- 26 files changed, 171 insertions(+), 184 deletions(-) diff --git a/flang-rt/include/flang-rt/runtime/connection.h b/flang-rt/include/flang-rt/runtime/connection.h index 601669942cdd6..4c1d6a4b1140c 100644 --- a/flang-rt/include/flang-rt/runtime/connection.h +++ b/flang-rt/include/flang-rt/runtime/connection.h @@ -26,10 +26,10 @@ enum class Access { Sequential, Direct, Stream }; // established in an OPEN statement. struct ConnectionAttributes { Access access{Access::Sequential}; // ACCESS='SEQUENTIAL', 'DIRECT', 'STREAM' - Fortran::common::optional isUnformatted; // FORM='UNFORMATTED' if true + common::optional isUnformatted; // FORM='UNFORMATTED' if true bool isUTF8{false}; // ENCODING='UTF-8' unsigned char internalIoCharKind{0}; // 0->external, 1/2/4->internal - Fortran::common::optional openRecl; // RECL= on OPEN + common::optional openRecl; // RECL= on OPEN RT_API_ATTRS bool IsRecordFile() const { // Formatted stream files are viewed as having records, at least on input @@ -82,15 +82,14 @@ struct ConnectionState : public ConnectionAttributes { unterminatedRecord = false; } - RT_API_ATTRS Fortran::common::optional - EffectiveRecordLength() const { + RT_API_ATTRS common::optional EffectiveRecordLength() const { // When an input record is longer than an explicit RECL= from OPEN // it is effectively truncated on input. return openRecl && recordLength && *openRecl < *recordLength ? openRecl : recordLength; } - Fortran::common::optional recordLength; + common::optional recordLength; std::int64_t currentRecordNumber{1}; // 1 is first @@ -106,12 +105,11 @@ struct ConnectionState : public ConnectionAttributes { std::int64_t furthestPositionInRecord{0}; // max(position+bytes) // Set at end of non-advancing I/O data transfer - Fortran::common::optional - leftTabLimit; // offset in current record + common::optional leftTabLimit; // offset in current record // currentRecordNumber value captured after ENDFILE/REWIND/BACKSPACE statement // or an end-of-file READ condition on a sequential access file - Fortran::common::optional endfileRecordNumber; + common::optional endfileRecordNumber; // Mutable modes set at OPEN() that can be overridden in READ/WRITE & FORMAT MutableModes modes; // BLANK=, DECIMAL=, SIGN=, ROUND=, PAD=, DELIM=, kP diff --git a/flang-rt/include/flang-rt/runtime/environment.h b/flang-rt/include/flang-rt/runtime/environment.h index e579f6012ce86..b60778a616fab 100644 --- a/flang-rt/include/flang-rt/runtime/environment.h +++ b/flang-rt/include/flang-rt/runtime/environment.h @@ -31,7 +31,7 @@ RT_OFFLOAD_VAR_GROUP_END // External unformatted I/O data conversions enum class Convert { Unknown, Native, LittleEndian, BigEndian, Swap }; -RT_API_ATTRS Fortran::common::optional GetConvertFromString( +RT_API_ATTRS common::optional GetConvertFromString( const char *, std::size_t); struct ExecutionEnvironment { diff --git a/flang-rt/include/flang-rt/runtime/file.h b/flang-rt/include/flang-rt/runtime/file.h index 6e35fe89b5341..468a759214b85 100644 --- a/flang-rt/include/flang-rt/runtime/file.h +++ b/flang-rt/include/flang-rt/runtime/file.h @@ -37,11 +37,10 @@ class OpenFile { void set_mayAsynchronous(bool yes) { mayAsynchronous_ = yes; } bool isTerminal() const { return isTerminal_; } bool isWindowsTextFile() const { return isWindowsTextFile_; } - Fortran::common::optional knownSize() const { return knownSize_; } + common::optional knownSize() const { return knownSize_; } bool IsConnected() const { return fd_ >= 0; } - void Open(OpenStatus, Fortran::common::optional, Position, - IoErrorHandler &); + void Open(OpenStatus, common::optional, Position, IoErrorHandler &); void Predefine(int fd); void Close(CloseStatus, IoErrorHandler &); @@ -95,10 +94,10 @@ class OpenFile { bool mayWrite_{false}; bool mayPosition_{false}; bool mayAsynchronous_{false}; - Fortran::common::optional + common::optional openPosition_; // from Open(); reset after positioning FileOffset position_{0}; - Fortran::common::optional knownSize_; + common::optional knownSize_; bool isTerminal_{false}; bool isWindowsTextFile_{false}; // expands LF to CR+LF on write diff --git a/flang-rt/include/flang-rt/runtime/format-implementation.h b/flang-rt/include/flang-rt/runtime/format-implementation.h index 85dc922bc31bc..580e04f335aec 100644 --- a/flang-rt/include/flang-rt/runtime/format-implementation.h +++ b/flang-rt/include/flang-rt/runtime/format-implementation.h @@ -302,7 +302,7 @@ RT_API_ATTRS int FormatControl::CueUpNextDataEdit( } } while (true) { - Fortran::common::optional repeat; + common::optional repeat; bool unlimited{false}; auto maybeReversionPoint{offset_}; CharType ch{GetNextChar(context)}; @@ -498,8 +498,8 @@ RT_API_ATTRS int FormatControl::CueUpNextDataEdit( // Returns the next data edit descriptor template -RT_API_ATTRS Fortran::common::optional -FormatControl::GetNextDataEdit(Context &context, int maxRepeat) { +RT_API_ATTRS common::optional FormatControl::GetNextDataEdit( + Context &context, int maxRepeat) { int repeat{CueUpNextDataEdit(context)}; auto start{offset_}; DataEdit edit; @@ -530,7 +530,7 @@ FormatControl::GetNextDataEdit(Context &context, int maxRepeat) { } if (edit.ioTypeChars >= edit.maxIoTypeChars) { ReportBadFormat(context, "Excessive DT'iotype' in FORMAT", start); - return Fortran::common::nullopt; + return common::nullopt; } edit.ioType[edit.ioTypeChars++] = ch; if (ch == quote) { @@ -539,7 +539,7 @@ FormatControl::GetNextDataEdit(Context &context, int maxRepeat) { } if (!ok) { ReportBadFormat(context, "Unclosed DT'iotype' in FORMAT", start); - return Fortran::common::nullopt; + return common::nullopt; } } if (PeekNext() == '(') { @@ -554,7 +554,7 @@ FormatControl::GetNextDataEdit(Context &context, int maxRepeat) { } if (edit.vListEntries >= edit.maxVListEntries) { ReportBadFormat(context, "Excessive DT(v_list) in FORMAT", start); - return Fortran::common::nullopt; + return common::nullopt; } edit.vList[edit.vListEntries++] = n; auto ch{static_cast(GetNextChar(context))}; @@ -565,7 +565,7 @@ FormatControl::GetNextDataEdit(Context &context, int maxRepeat) { } if (!ok) { ReportBadFormat(context, "Unclosed DT(v_list) in FORMAT", start); - return Fortran::common::nullopt; + return common::nullopt; } } } else { // not DT'iotype' diff --git a/flang-rt/include/flang-rt/runtime/format.h b/flang-rt/include/flang-rt/runtime/format.h index 89f815f327d4f..34e33edae546d 100644 --- a/flang-rt/include/flang-rt/runtime/format.h +++ b/flang-rt/include/flang-rt/runtime/format.h @@ -76,9 +76,9 @@ struct DataEdit { } char variation{'\0'}; // N, S, or X for EN, ES, EX; G/l for original G/list - Fortran::common::optional width; // the 'w' field; optional for A - Fortran::common::optional digits; // the 'm' or 'd' field - Fortran::common::optional expoDigits; // 'Ee' field + common::optional width; // the 'w' field; optional for A + common::optional digits; // the 'm' or 'd' field + common::optional expoDigits; // 'Ee' field MutableModes modes; int repeat{1}; @@ -116,7 +116,7 @@ template class FormatControl { // Extracts the next data edit descriptor, handling control edit descriptors // along the way. If maxRepeat==0, this is a peek at the next data edit // descriptor. - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( Context &, int maxRepeat = 1); // Emit any remaining character literals after the last data item (on output) diff --git a/flang-rt/include/flang-rt/runtime/io-stmt.h b/flang-rt/include/flang-rt/runtime/io-stmt.h index 3d1ca5091e923..adc8b742f837b 100644 --- a/flang-rt/include/flang-rt/runtime/io-stmt.h +++ b/flang-rt/include/flang-rt/runtime/io-stmt.h @@ -105,8 +105,7 @@ class IoStatementState { RT_API_ATTRS void HandleRelativePosition(std::int64_t byteOffset); RT_API_ATTRS void HandleAbsolutePosition( std::int64_t byteOffset); // for r* in list I/O - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( - int maxRepeat = 1); + RT_API_ATTRS common::optional GetNextDataEdit(int maxRepeat = 1); RT_API_ATTRS ExternalFileUnit * GetExternalFileUnit() const; // null if internal unit RT_API_ATTRS bool BeginReadingRecord(); @@ -136,7 +135,7 @@ class IoStatementState { } // Vacant after the end of the current record - RT_API_ATTRS Fortran::common::optional GetCurrentCharSlow( + RT_API_ATTRS common::optional GetCurrentCharSlow( std::size_t &byteCount); // For faster formatted input editing, this structure can be built by @@ -158,11 +157,11 @@ class IoStatementState { RT_API_ATTRS bool MustUseSlowPath() const { return at_ == nullptr; } - RT_API_ATTRS Fortran::common::optional Next() const { + RT_API_ATTRS common::optional Next() const { if (at_ && at_ < limit_) { return *at_; } else { - return Fortran::common::nullopt; + return common::nullopt; } } RT_API_ATTRS void NextRecord(IoStatementState &io) { @@ -199,14 +198,14 @@ class IoStatementState { RT_API_ATTRS FastAsciiField GetUpcomingFastAsciiField(); - RT_API_ATTRS Fortran::common::optional GetCurrentChar( + RT_API_ATTRS common::optional GetCurrentChar( std::size_t &byteCount, FastAsciiField *field = nullptr) { if (field) { if (auto ch{field->Next()}) { byteCount = ch ? 1 : 0; return ch; } else if (!field->MustUseSlowPath()) { - return Fortran::common::nullopt; + return common::nullopt; } } return GetCurrentCharSlow(byteCount); @@ -218,9 +217,9 @@ class IoStatementState { // For fixed-width fields, return the number of remaining bytes. // Skip over leading blanks. - RT_API_ATTRS Fortran::common::optional CueUpInput( + RT_API_ATTRS common::optional CueUpInput( const DataEdit &edit, FastAsciiField *fastField = nullptr) { - Fortran::common::optional remaining; + common::optional remaining; if (edit.IsListDirected()) { std::size_t byteCount{0}; GetNextNonBlank(byteCount, fastField); @@ -237,9 +236,8 @@ class IoStatementState { return remaining; } - RT_API_ATTRS Fortran::common::optional SkipSpaces( - Fortran::common::optional &remaining, - FastAsciiField *fastField = nullptr) { + RT_API_ATTRS common::optional SkipSpaces( + common::optional &remaining, FastAsciiField *fastField = nullptr) { while (!remaining || *remaining > 0) { std::size_t byteCount{0}; if (auto ch{GetCurrentChar(byteCount, fastField)}) { @@ -262,13 +260,13 @@ class IoStatementState { break; } } - return Fortran::common::nullopt; + return common::nullopt; } // Acquires the next input character, respecting any applicable field width // or separator character. - RT_API_ATTRS Fortran::common::optional NextInField( - Fortran::common::optional &remaining, const DataEdit &, + RT_API_ATTRS common::optional NextInField( + common::optional &remaining, const DataEdit &, FastAsciiField *field = nullptr); // Detect and signal any end-of-record condition after input. @@ -277,7 +275,7 @@ class IoStatementState { std::size_t afterReading, const ConnectionState &); // Skips spaces, advances records, and ignores NAMELIST comments - RT_API_ATTRS Fortran::common::optional GetNextNonBlank( + RT_API_ATTRS common::optional GetNextNonBlank( std::size_t &byteCount, FastAsciiField *fastField = nullptr) { auto ch{GetCurrentChar(byteCount, fastField)}; bool inNamelist{mutableModes().inNamelist}; @@ -294,7 +292,7 @@ class IoStatementState { fastField->NextRecord(*this); } } else { - return Fortran::common::nullopt; + return common::nullopt; } ch = GetCurrentChar(byteCount, fastField); } @@ -316,47 +314,43 @@ class IoStatementState { } private: - std::variant, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper< + std::variant, + common::reference_wrapper, + common::reference_wrapper, + common::reference_wrapper< InternalFormattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< InternalFormattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< InternalListIoStatementState>, - Fortran::common::reference_wrapper< - InternalListIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper>, + common::reference_wrapper< ExternalFormattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< ExternalFormattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< ExternalListIoStatementState>, - Fortran::common::reference_wrapper< - ExternalListIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper>, + common::reference_wrapper< ExternalUnformattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< ExternalUnformattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< ChildFormattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< ChildFormattedIoStatementState>, - Fortran::common::reference_wrapper< - ChildListIoStatementState>, - Fortran::common::reference_wrapper< - ChildListIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper>, + common::reference_wrapper>, + common::reference_wrapper< ChildUnformattedIoStatementState>, - Fortran::common::reference_wrapper< + common::reference_wrapper< ChildUnformattedIoStatementState>, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper, - Fortran::common::reference_wrapper> + common::reference_wrapper, + common::reference_wrapper, + common::reference_wrapper, + common::reference_wrapper, + common::reference_wrapper, + common::reference_wrapper> u_; }; @@ -388,7 +382,7 @@ class IoStatementBase : public IoErrorHandler { RT_API_ATTRS void BackspaceRecord(); RT_API_ATTRS void HandleRelativePosition(std::int64_t); RT_API_ATTRS void HandleAbsolutePosition(std::int64_t); - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( IoStatementState &, int maxRepeat = 1); RT_API_ATTRS ExternalFileUnit *GetExternalFileUnit() const; RT_API_ATTRS bool BeginReadingRecord(); @@ -422,7 +416,7 @@ class ListDirectedStatementState public: RT_API_ATTRS bool EmitLeadingSpaceOrAdvance( IoStatementState &, std::size_t = 1, bool isCharacter = false); - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( IoStatementState &, int maxRepeat = 1); RT_API_ATTRS bool lastWasUndelimitedCharacter() const { return lastWasUndelimitedCharacter_; @@ -446,7 +440,7 @@ class ListDirectedStatementState // Skips value separators, handles repetition and null values. // Vacant when '/' appears; present with descriptor == ListDirectedNullValue // when a null value appears. - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( IoStatementState &, int maxRepeat = 1); // Each NAMELIST input item is treated like a distinct list-directed @@ -469,7 +463,7 @@ class ListDirectedStatementState private: int remaining_{0}; // for "r*" repetition - Fortran::common::optional repeatPosition_; + common::optional repeatPosition_; bool eatComma_{false}; // consume comma after previously read item bool hitSlash_{false}; // once '/' is seen, nullify further items bool realPart_{false}; @@ -524,7 +518,7 @@ class InternalFormattedIoStatementState } RT_API_ATTRS void CompleteOperation(); RT_API_ATTRS int EndIoStatement(); - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( IoStatementState &, int maxRepeat = 1) { return format_.GetNextDataEdit(*this, maxRepeat); } @@ -618,7 +612,7 @@ class ExternalFormattedIoStatementState const char *sourceFile = nullptr, int sourceLine = 0); RT_API_ATTRS void CompleteOperation(); RT_API_ATTRS int EndIoStatement(); - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( IoStatementState &, int maxRepeat = 1) { return format_.GetNextDataEdit(*this, maxRepeat); } @@ -680,7 +674,7 @@ class ChildFormattedIoStatementState : public ChildIoStatementState, RT_API_ATTRS void CompleteOperation(); RT_API_ATTRS int EndIoStatement(); RT_API_ATTRS bool AdvanceRecord(int = 1); - RT_API_ATTRS Fortran::common::optional GetNextDataEdit( + RT_API_ATTRS common::optional GetNextDataEdit( IoStatementState &, int maxRepeat = 1) { return format_.GetNextDataEdit(*this, maxRepeat); } @@ -740,15 +734,15 @@ class OpenStatementState : public ExternalIoStatementBase { private: bool wasExtant_; bool isNewUnit_; - Fortran::common::optional status_; - Fortran::common::optional position_; - Fortran::common::optional action_; + common::optional status_; + common::optional position_; + common::optional action_; Convert convert_{Convert::Unknown}; OwningPtr path_; std::size_t pathLength_{}; - Fortran::common::optional isUnformatted_; - Fortran::common::optional mustBeFormatted_; - Fortran::common::optional access_; + common::optional isUnformatted_; + common::optional mustBeFormatted_; + common::optional access_; }; class CloseStatementState : public ExternalIoStatementBase { diff --git a/flang-rt/include/flang-rt/runtime/random-templates.h b/flang-rt/include/flang-rt/runtime/random-templates.h index 895c5ad4fc8bb..721838c9e8027 100644 --- a/flang-rt/include/flang-rt/runtime/random-templates.h +++ b/flang-rt/include/flang-rt/runtime/random-templates.h @@ -33,7 +33,7 @@ static constexpr int rangeBits{ extern Lock lock; extern Generator generator; -extern Fortran::common::optional nextValue; +extern common::optional nextValue; // Call only with lock held static GeneratedWord GetNextValue() { diff --git a/flang-rt/include/flang-rt/runtime/tools.h b/flang-rt/include/flang-rt/runtime/tools.h index a1b96f41f4936..f26923b140474 100644 --- a/flang-rt/include/flang-rt/runtime/tools.h +++ b/flang-rt/include/flang-rt/runtime/tools.h @@ -94,8 +94,9 @@ RT_API_ATTRS void CheckConformability(const Descriptor &to, const Descriptor &x, template struct StoreIntegerAt { RT_API_ATTRS void operator()(const Fortran::runtime::Descriptor &result, std::size_t at, std::int64_t value) const { - *result.ZeroBasedIndexedElement>(at) = value; + *result.ZeroBasedIndexedElement< + Fortran::runtime::CppTypeFor>(at) = + value; } }; @@ -103,8 +104,9 @@ template struct StoreIntegerAt { template struct StoreFloatingPointAt { RT_API_ATTRS void operator()(const Fortran::runtime::Descriptor &result, std::size_t at, std::double_t value) const { - *result.ZeroBasedIndexedElement>(at) = value; + *result.ZeroBasedIndexedElement< + Fortran::runtime::CppTypeFor>(at) = + value; } }; @@ -136,7 +138,7 @@ static inline RT_API_ATTRS std::int64_t GetInt64( } } -static inline RT_API_ATTRS Fortran::common::optional GetInt64Safe( +static inline RT_API_ATTRS common::optional GetInt64Safe( const char *p, std::size_t bytes, Terminator &terminator) { switch (bytes) { case 1: @@ -154,7 +156,7 @@ static inline RT_API_ATTRS Fortran::common::optional GetInt64Safe( if (static_cast(result) == n) { return result; } - return Fortran::common::nullopt; + return common::nullopt; } default: terminator.Crash("GetInt64Safe: no case for %zd bytes", bytes); @@ -392,8 +394,7 @@ inline RT_API_ATTRS RESULT ApplyLogicalKind( } // Calculate result type of (X op Y) for *, //, DOT_PRODUCT, &c. -Fortran::common::optional< - std::pair> inline constexpr RT_API_ATTRS +common::optional> inline constexpr RT_API_ATTRS GetResultType(TypeCategory xCat, int xKind, TypeCategory yCat, int yKind) { int maxKind{std::max(xKind, yKind)}; switch (xCat) { @@ -467,18 +468,18 @@ GetResultType(TypeCategory xCat, int xKind, TypeCategory yCat, int yKind) { if (yCat == TypeCategory::Character) { return std::make_pair(TypeCategory::Character, maxKind); } else { - return Fortran::common::nullopt; + return common::nullopt; } case TypeCategory::Logical: if (yCat == TypeCategory::Logical) { return std::make_pair(TypeCategory::Logical, maxKind); } else { - return Fortran::common::nullopt; + return common::nullopt; } default: break; } - return Fortran::common::nullopt; + return common::nullopt; } // Accumulate floating-point results in (at least) double precision diff --git a/flang-rt/include/flang-rt/runtime/type-code.h b/flang-rt/include/flang-rt/runtime/type-code.h index 9416a2816fd43..c104bcf366a8d 100644 --- a/flang-rt/include/flang-rt/runtime/type-code.h +++ b/flang-rt/include/flang-rt/runtime/type-code.h @@ -54,7 +54,7 @@ class TypeCode { return IsValid() && !IsDerived(); } - RT_API_ATTRS Fortran::common::optional> + RT_API_ATTRS common::optional> GetCategoryAndKind() const; RT_API_ATTRS bool operator==(TypeCode that) const { diff --git a/flang-rt/include/flang-rt/runtime/type-info.h b/flang-rt/include/flang-rt/runtime/type-info.h index e0fbcd3cbfa06..f7849556488b2 100644 --- a/flang-rt/include/flang-rt/runtime/type-info.h +++ b/flang-rt/include/flang-rt/runtime/type-info.h @@ -39,7 +39,7 @@ class Value { LenParameter = 3 }; RT_API_ATTRS Genre genre() const { return genre_; } - RT_API_ATTRS Fortran::common::optional GetValue( + RT_API_ATTRS common::optional GetValue( const Descriptor *) const; private: diff --git a/flang-rt/include/flang-rt/runtime/utf.h b/flang-rt/include/flang-rt/runtime/utf.h index b5add823124fc..a419c2094c2ff 100644 --- a/flang-rt/include/flang-rt/runtime/utf.h +++ b/flang-rt/include/flang-rt/runtime/utf.h @@ -63,7 +63,7 @@ RT_API_ATTRS std::size_t MeasurePreviousUTF8Bytes( // Ensure that all bytes are present in sequence in the input buffer // before calling; use MeasureUTF8Bytes(first byte) to count them. -RT_API_ATTRS Fortran::common::optional DecodeUTF8(const char *); +RT_API_ATTRS common::optional DecodeUTF8(const char *); // Ensure that at least maxUTF8Bytes remain in the output // buffer before calling. diff --git a/flang-rt/lib/runtime/descriptor-io.cpp b/flang-rt/lib/runtime/descriptor-io.cpp index a60d0b90da467..6d9805f42212c 100644 --- a/flang-rt/lib/runtime/descriptor-io.cpp +++ b/flang-rt/lib/runtime/descriptor-io.cpp @@ -42,7 +42,7 @@ inline RT_API_ATTRS A &ExtractElement(IoStatementState &io, } // Defined formatted I/O (maybe) -static RT_API_ATTRS Fortran::common::optional DefinedFormattedIo( +static RT_API_ATTRS common::optional DefinedFormattedIo( IoStatementState &io, const Descriptor &descriptor, const typeInfo::DerivedType &derived, const typeInfo::SpecialBinding &special, @@ -50,7 +50,7 @@ static RT_API_ATTRS Fortran::common::optional DefinedFormattedIo( // Look at the next data edit descriptor. If this is list-directed I/O, the // "maxRepeat=0" argument will prevent the input from advancing over an // initial '(' that shouldn't be consumed now as the start of a real part. - Fortran::common::optional peek{io.GetNextDataEdit(/*maxRepeat=*/0)}; + common::optional peek{io.GetNextDataEdit(/*maxRepeat=*/0)}; if (peek && (peek->descriptor == DataEdit::DefinedDerivedType || peek->descriptor == DataEdit::ListDirected || @@ -107,7 +107,7 @@ static RT_API_ATTRS Fortran::common::optional DefinedFormattedIo( std::int32_t unit{external->unitNumber()}; std::int32_t ioStat{IostatOk}; char ioMsg[100]; - Fortran::common::optional startPos; + common::optional startPos; if (edit.descriptor == DataEdit::DefinedDerivedType && special.which() == typeInfo::SpecialBinding::Which::ReadFormatted) { // DT is an edit descriptor, so everything that the child @@ -174,7 +174,7 @@ static RT_API_ATTRS Fortran::common::optional DefinedFormattedIo( // There's a defined I/O subroutine, but there's a FORMAT present and // it does not have a DT data edit descriptor, so apply default formatting // to the components of the derived type as usual. - return Fortran::common::nullopt; + return common::nullopt; } } diff --git a/flang-rt/lib/runtime/edit-input.cpp b/flang-rt/lib/runtime/edit-input.cpp index 1bfc16cbc966d..7de5ec35d41c7 100644 --- a/flang-rt/lib/runtime/edit-input.cpp +++ b/flang-rt/lib/runtime/edit-input.cpp @@ -52,9 +52,9 @@ template static RT_API_ATTRS bool EditBOZInput( IoStatementState &io, const DataEdit &edit, void *n, std::size_t bytes) { // Skip leading white space & zeroes - Fortran::common::optional remaining{io.CueUpInput(edit)}; + common::optional remaining{io.CueUpInput(edit)}; auto start{io.GetConnectionState().positionInRecord}; - Fortran::common::optional next{io.NextInField(remaining, edit)}; + common::optional next{io.NextInField(remaining, edit)}; if (next.value_or('?') == '0') { do { start = io.GetConnectionState().positionInRecord; @@ -154,8 +154,8 @@ static RT_API_ATTRS bool EditBOZInput( // Prepares input from a field, and returns the sign, if any, else '\0'. static RT_API_ATTRS char ScanNumericPrefix(IoStatementState &io, - const DataEdit &edit, Fortran::common::optional &next, - Fortran::common::optional &remaining, + const DataEdit &edit, common::optional &next, + common::optional &remaining, IoStatementState::FastAsciiField *fastField = nullptr) { remaining = io.CueUpInput(edit, fastField); next = io.NextInField(remaining, edit, fastField); @@ -202,8 +202,8 @@ RT_API_ATTRS bool EditIntegerInput(IoStatementState &io, const DataEdit &edit, edit.descriptor); return false; } - Fortran::common::optional remaining; - Fortran::common::optional next; + common::optional remaining; + common::optional next; auto fastField{io.GetUpcomingFastAsciiField()}; char sign{ScanNumericPrefix(io, edit, next, remaining, &fastField)}; if (sign == '-' && !isSigned) { @@ -318,10 +318,10 @@ struct ScannedRealInput { }; static RT_API_ATTRS ScannedRealInput ScanRealInput( char *buffer, int bufferSize, IoStatementState &io, const DataEdit &edit) { - Fortran::common::optional remaining; - Fortran::common::optional next; + common::optional remaining; + common::optional next; int got{0}; - Fortran::common::optional radixPointOffset; + common::optional radixPointOffset; // The following lambda definition violates the conding style, // but cuda-11.8 nvcc hits an internal error with the brace initialization. auto Put = [&](char ch) -> void { @@ -938,8 +938,8 @@ RT_API_ATTRS bool EditLogicalInput( edit.descriptor); return false; } - Fortran::common::optional remaining{io.CueUpInput(edit)}; - Fortran::common::optional next{io.NextInField(remaining, edit)}; + common::optional remaining{io.CueUpInput(edit)}; + common::optional next{io.NextInField(remaining, edit)}; if (next && *next == '.') { // skip optional period next = io.NextInField(remaining, edit); } diff --git a/flang-rt/lib/runtime/environment.cpp b/flang-rt/lib/runtime/environment.cpp index 0f0564403c0e2..be32c880163c6 100644 --- a/flang-rt/lib/runtime/environment.cpp +++ b/flang-rt/lib/runtime/environment.cpp @@ -52,8 +52,7 @@ static void SetEnvironmentDefaults(const EnvironmentDefaultList *envDefaults) { } RT_OFFLOAD_API_GROUP_BEGIN -Fortran::common::optional GetConvertFromString( - const char *x, std::size_t n) { +common::optional GetConvertFromString(const char *x, std::size_t n) { static const char *keywords[]{ "UNKNOWN", "NATIVE", "LITTLE_ENDIAN", "BIG_ENDIAN", "SWAP", nullptr}; switch (IdentifyValue(x, n, keywords)) { @@ -68,7 +67,7 @@ Fortran::common::optional GetConvertFromString( case 4: return Convert::Swap; default: - return Fortran::common::nullopt; + return common::nullopt; } } RT_OFFLOAD_API_GROUP_END diff --git a/flang-rt/lib/runtime/io-api-common.h b/flang-rt/lib/runtime/io-api-common.h index b91ff9ff16863..ad6e79d747242 100644 --- a/flang-rt/lib/runtime/io-api-common.h +++ b/flang-rt/lib/runtime/io-api-common.h @@ -31,7 +31,7 @@ static inline RT_API_ATTRS Cookie NoopUnit(const Terminator &terminator, } static inline RT_API_ATTRS ExternalFileUnit *GetOrCreateUnit(int unitNumber, - Direction direction, Fortran::common::optional isUnformatted, + Direction direction, common::optional isUnformatted, const Terminator &terminator, Cookie &errorCookie) { IoErrorHandler handler{terminator}; handler.HasIoStat(); diff --git a/flang-rt/lib/runtime/io-api.cpp b/flang-rt/lib/runtime/io-api.cpp index c7c15e77c0770..da324f392e008 100644 --- a/flang-rt/lib/runtime/io-api.cpp +++ b/flang-rt/lib/runtime/io-api.cpp @@ -386,8 +386,8 @@ Cookie IODEF(BeginEndfile)( Terminator terminator{sourceFile, sourceLine}; Cookie errorCookie{nullptr}; if (ExternalFileUnit * - unit{GetOrCreateUnit(unitNumber, Direction::Output, - Fortran::common::nullopt, terminator, errorCookie)}) { + unit{GetOrCreateUnit(unitNumber, Direction::Output, common::nullopt, + terminator, errorCookie)}) { if (ChildIo * child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, @@ -406,8 +406,8 @@ Cookie IODEF(BeginRewind)( Terminator terminator{sourceFile, sourceLine}; Cookie errorCookie{nullptr}; if (ExternalFileUnit * - unit{GetOrCreateUnit(unitNumber, Direction::Input, - Fortran::common::nullopt, terminator, errorCookie)}) { + unit{GetOrCreateUnit(unitNumber, Direction::Input, common::nullopt, + terminator, errorCookie)}) { if (ChildIo * child{unit->GetChildIo()}) { return &child->BeginIoStatement( IostatBadOpOnChildUnit, nullptr /* no unit */, sourceFile, @@ -732,7 +732,7 @@ bool IODEF(SetAction)(Cookie cookie, const char *keyword, std::size_t length) { io.GetIoErrorHandler().Crash( "SetAction() called after GetNewUnit() for an OPEN statement"); } - Fortran::common::optional action; + common::optional action; static const char *keywords[]{"READ", "WRITE", "READWRITE", nullptr}; switch (IdentifyValue(keyword, length, keywords)) { case 0: diff --git a/flang-rt/lib/runtime/io-stmt.cpp b/flang-rt/lib/runtime/io-stmt.cpp index 28149090eb169..3260c8f83edb9 100644 --- a/flang-rt/lib/runtime/io-stmt.cpp +++ b/flang-rt/lib/runtime/io-stmt.cpp @@ -46,9 +46,9 @@ bool IoStatementBase::Receive(char *, std::size_t, std::size_t) { return false; } -Fortran::common::optional IoStatementBase::GetNextDataEdit( +common::optional IoStatementBase::GetNextDataEdit( IoStatementState &, int) { - return Fortran::common::nullopt; + return common::nullopt; } bool IoStatementBase::BeginReadingRecord() { return true; } @@ -532,7 +532,7 @@ int ExternalFormattedIoStatementState::EndIoStatement() { return ExternalIoStatementState::EndIoStatement(); } -Fortran::common::optional IoStatementState::GetNextDataEdit(int n) { +common::optional IoStatementState::GetNextDataEdit(int n) { return common::visit( [&](auto &x) { return x.get().GetNextDataEdit(*this, n); }, u_); } @@ -618,13 +618,13 @@ ExternalFileUnit *IoStatementState::GetExternalFileUnit() const { [](auto &x) { return x.get().GetExternalFileUnit(); }, u_); } -Fortran::common::optional IoStatementState::GetCurrentCharSlow( +common::optional IoStatementState::GetCurrentCharSlow( std::size_t &byteCount) { const char *p{nullptr}; std::size_t bytes{GetNextInputBytes(p)}; if (bytes == 0) { byteCount = 0; - return Fortran::common::nullopt; + return common::nullopt; } else { const ConnectionState &connection{GetConnectionState()}; if (connection.isUTF8) { @@ -661,8 +661,8 @@ IoStatementState::FastAsciiField IoStatementState::GetUpcomingFastAsciiField() { return FastAsciiField{connection}; } -Fortran::common::optional IoStatementState::NextInField( - Fortran::common::optional &remaining, const DataEdit &edit, +common::optional IoStatementState::NextInField( + common::optional &remaining, const DataEdit &edit, FastAsciiField *field) { std::size_t byteCount{0}; if (!remaining) { // Stream, list-directed, NAMELIST, &c. @@ -680,21 +680,21 @@ Fortran::common::optional IoStatementState::NextInField( case '"': case '*': case '\n': // for stream access - return Fortran::common::nullopt; + return common::nullopt; case '&': case '$': if (edit.IsNamelist()) { - return Fortran::common::nullopt; + return common::nullopt; } break; case ',': if (!(edit.modes.editingFlags & decimalComma)) { - return Fortran::common::nullopt; + return common::nullopt; } break; case ';': if (edit.modes.editingFlags & decimalComma) { - return Fortran::common::nullopt; + return common::nullopt; } break; default: @@ -712,7 +712,7 @@ Fortran::common::optional IoStatementState::NextInField( } else if (*remaining > 0) { if (auto next{GetCurrentChar(byteCount, field)}) { if (byteCount > static_cast(*remaining)) { - return Fortran::common::nullopt; + return common::nullopt; } *remaining -= byteCount; if (field) { @@ -726,10 +726,10 @@ Fortran::common::optional IoStatementState::NextInField( if (CheckForEndOfRecord(0, field ? field->connection() : GetConnectionState())) { // do padding --*remaining; - return Fortran::common::optional{' '}; + return common::optional{' '}; } } - return Fortran::common::nullopt; + return common::nullopt; } bool IoStatementState::CheckForEndOfRecord( @@ -821,7 +821,7 @@ bool ListDirectedStatementState::EmitLeadingSpaceOrAdvance( return true; } -Fortran::common::optional +common::optional ListDirectedStatementState::GetNextDataEdit( IoStatementState &io, int maxRepeat) { DataEdit edit; @@ -838,7 +838,7 @@ int ListDirectedStatementState::EndIoStatement() { return IostatOk; } -Fortran::common::optional +common::optional ListDirectedStatementState::GetNextDataEdit( IoStatementState &io, int maxRepeat) { // N.B. list-directed transfers cannot be nonadvancing (C1221) @@ -891,7 +891,7 @@ ListDirectedStatementState::GetNextDataEdit( } eatComma_ = true; if (!ch) { - return Fortran::common::nullopt; + return common::nullopt; } if (*ch == '/') { hitSlash_ = true; diff --git a/flang-rt/lib/runtime/misc-intrinsic.cpp b/flang-rt/lib/runtime/misc-intrinsic.cpp index a8797f48fa667..02862918a3457 100644 --- a/flang-rt/lib/runtime/misc-intrinsic.cpp +++ b/flang-rt/lib/runtime/misc-intrinsic.cpp @@ -19,7 +19,7 @@ namespace Fortran::runtime { static RT_API_ATTRS void TransferImpl(Descriptor &result, const Descriptor &source, const Descriptor &mold, const char *sourceFile, - int line, Fortran::common::optional resultExtent) { + int line, common::optional resultExtent) { int rank{resultExtent.has_value() ? 1 : 0}; std::size_t elementBytes{mold.ElementBytes()}; result.Establish(mold.type(), elementBytes, nullptr, rank, nullptr, @@ -91,7 +91,7 @@ void RTDEF(Rename)(const Descriptor &path1, const Descriptor &path2, void RTDEF(Transfer)(Descriptor &result, const Descriptor &source, const Descriptor &mold, const char *sourceFile, int line) { - Fortran::common::optional elements; + common::optional elements; if (mold.rank() > 0) { if (std::size_t sourceElementBytes{ source.Elements() * source.ElementBytes()}) { diff --git a/flang-rt/lib/runtime/namelist.cpp b/flang-rt/lib/runtime/namelist.cpp index 44a8fe2de3cc0..79dbe4b822921 100644 --- a/flang-rt/lib/runtime/namelist.cpp +++ b/flang-rt/lib/runtime/namelist.cpp @@ -125,11 +125,11 @@ static RT_API_ATTRS bool GetLowerCaseName(IoStatementState &io, char buffer[], return false; } -static RT_API_ATTRS Fortran::common::optional GetSubscriptValue( +static RT_API_ATTRS common::optional GetSubscriptValue( IoStatementState &io) { - Fortran::common::optional value; + common::optional value; std::size_t byteCount{0}; - Fortran::common::optional ch{io.GetCurrentChar(byteCount)}; + common::optional ch{io.GetCurrentChar(byteCount)}; bool negate{ch && *ch == '-'}; if ((ch && *ch == '+') || negate) { io.HandleRelativePosition(byteCount); @@ -146,7 +146,7 @@ static RT_API_ATTRS Fortran::common::optional GetSubscriptValue( if (overflow) { io.GetIoErrorHandler().SignalError( "NAMELIST input subscript value overflow"); - return Fortran::common::nullopt; + return common::nullopt; } if (negate) { if (value) { @@ -168,7 +168,7 @@ static RT_API_ATTRS bool HandleSubscripts(IoStatementState &io, std::size_t contiguousStride{source.ElementBytes()}; bool ok{true}; std::size_t byteCount{0}; - Fortran::common::optional ch{io.GetNextNonBlank(byteCount)}; + common::optional ch{io.GetNextNonBlank(byteCount)}; char32_t comma{GetComma(io)}; for (; ch && *ch != ')'; ++j) { SubscriptValue dimLower{0}, dimUpper{0}, dimStride{0}; @@ -300,9 +300,9 @@ static RT_API_ATTRS bool HandleSubstring( SubscriptValue chars{static_cast(desc.ElementBytes()) / kind}; // Allow for blanks in substring bounds; they're nonstandard, but not // ambiguous within the parentheses. - Fortran::common::optional lower, upper; + common::optional lower, upper; std::size_t byteCount{0}; - Fortran::common::optional ch{io.GetNextNonBlank(byteCount)}; + common::optional ch{io.GetNextNonBlank(byteCount)}; if (ch) { if (*ch == ':') { lower = 1; @@ -364,8 +364,7 @@ static RT_API_ATTRS bool HandleComponent(IoStatementState &io, Descriptor &desc, // If base and component are both arrays, the component name // must be followed by subscripts; process them now. std::size_t byteCount{0}; - if (Fortran::common::optional next{ - io.GetNextNonBlank(byteCount)}; + if (common::optional next{io.GetNextNonBlank(byteCount)}; next && *next == '(') { io.HandleRelativePosition(byteCount); // skip over '(' StaticDescriptor staticDesc; @@ -454,7 +453,7 @@ bool IODEF(InputNamelist)(Cookie cookie, const NamelistGroup &group) { RUNTIME_CHECK(handler, listInput != nullptr); // Find this namelist group's header in the input io.BeginReadingRecord(); - Fortran::common::optional next; + common::optional next; char name[nameBufferSize]; RUNTIME_CHECK(handler, group.groupName != nullptr); char32_t comma{GetComma(io)}; diff --git a/flang-rt/lib/runtime/pseudo-unit.cpp b/flang-rt/lib/runtime/pseudo-unit.cpp index 74ce101e25fe4..e9187c7e7dd56 100644 --- a/flang-rt/lib/runtime/pseudo-unit.cpp +++ b/flang-rt/lib/runtime/pseudo-unit.cpp @@ -35,8 +35,7 @@ ExternalFileUnit *ExternalFileUnit::LookUpOrCreate( } ExternalFileUnit *ExternalFileUnit::LookUpOrCreateAnonymous(int unit, - Direction direction, Fortran::common::optional, - IoErrorHandler &handler) { + Direction direction, common::optional, IoErrorHandler &handler) { if (direction != Direction::Output) { handler.Crash("ExternalFileUnit only supports output IO"); } @@ -59,14 +58,14 @@ ExternalFileUnit &ExternalFileUnit::NewUnit(const Terminator &, bool) { Terminator{__FILE__, __LINE__}.Crash("%s: unsupported", RT_PRETTY_FUNCTION); } -bool ExternalFileUnit::OpenUnit(Fortran::common::optional status, - Fortran::common::optional, Position, OwningPtr &&, - std::size_t, Convert, IoErrorHandler &handler) { +bool ExternalFileUnit::OpenUnit(common::optional status, + common::optional, Position, OwningPtr &&, std::size_t, + Convert, IoErrorHandler &handler) { handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION); } -bool ExternalFileUnit::OpenAnonymousUnit(Fortran::common::optional, - Fortran::common::optional, Position, Convert convert, +bool ExternalFileUnit::OpenAnonymousUnit(common::optional, + common::optional, Position, Convert convert, IoErrorHandler &handler) { handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION); } @@ -105,13 +104,12 @@ void PseudoOpenFile::set_mayAsynchronous(bool yes) { } } -Fortran::common::optional -PseudoOpenFile::knownSize() const { +common::optional PseudoOpenFile::knownSize() const { Terminator{__FILE__, __LINE__}.Crash("unsupported"); } -void PseudoOpenFile::Open(OpenStatus, Fortran::common::optional, - Position, IoErrorHandler &handler) { +void PseudoOpenFile::Open( + OpenStatus, common::optional, Position, IoErrorHandler &handler) { handler.Crash("%s: unsupported", RT_PRETTY_FUNCTION); } diff --git a/flang-rt/lib/runtime/random.cpp b/flang-rt/lib/runtime/random.cpp index dc74f2725ed51..ee00196f6b20d 100644 --- a/flang-rt/lib/runtime/random.cpp +++ b/flang-rt/lib/runtime/random.cpp @@ -28,7 +28,7 @@ namespace Fortran::runtime::random { Lock lock; Generator generator; -Fortran::common::optional nextValue; +common::optional nextValue; extern "C" { diff --git a/flang-rt/lib/runtime/type-code.cpp b/flang-rt/lib/runtime/type-code.cpp index 8cfec9a4ec2fb..9ecde012e7d13 100644 --- a/flang-rt/lib/runtime/type-code.cpp +++ b/flang-rt/lib/runtime/type-code.cpp @@ -131,7 +131,7 @@ RT_API_ATTRS TypeCode::TypeCode(TypeCategory f, int kind) { } } -RT_API_ATTRS Fortran::common::optional> +RT_API_ATTRS common::optional> TypeCode::GetCategoryAndKind() const { switch (raw_) { case CFI_type_signed_char: @@ -233,7 +233,7 @@ TypeCode::GetCategoryAndKind() const { case CFI_type_uint128_t: return std::make_pair(TypeCategory::Unsigned, 16); default: - return Fortran::common::nullopt; + return common::nullopt; } } diff --git a/flang-rt/lib/runtime/type-info.cpp b/flang-rt/lib/runtime/type-info.cpp index 50123f4cf321c..70e0f611ec6d2 100644 --- a/flang-rt/lib/runtime/type-info.cpp +++ b/flang-rt/lib/runtime/type-info.cpp @@ -15,7 +15,7 @@ namespace Fortran::runtime::typeInfo { RT_OFFLOAD_API_GROUP_BEGIN -RT_API_ATTRS Fortran::common::optional Value::GetValue( +RT_API_ATTRS common::optional Value::GetValue( const Descriptor *descriptor) const { switch (genre_) { case Genre::Explicit: @@ -26,9 +26,9 @@ RT_API_ATTRS Fortran::common::optional Value::GetValue( return addendum->LenParameterValue(value_); } } - return Fortran::common::nullopt; + return common::nullopt; default: - return Fortran::common::nullopt; + return common::nullopt; } } diff --git a/flang-rt/lib/runtime/unit-map.cpp b/flang-rt/lib/runtime/unit-map.cpp index 41a03f3319d64..8fb0e8fd3f8f7 100644 --- a/flang-rt/lib/runtime/unit-map.cpp +++ b/flang-rt/lib/runtime/unit-map.cpp @@ -30,7 +30,7 @@ void UnitMap::Initialize() { ExternalFileUnit &UnitMap::NewUnit(const Terminator &terminator) { CriticalSection critical{lock_}; Initialize(); - Fortran::common::optional n{freeNewUnits_.PopValue()}; + common::optional n{freeNewUnits_.PopValue()}; if (!n) { n = emergencyNewUnit_++; } diff --git a/flang-rt/lib/runtime/unit.h b/flang-rt/lib/runtime/unit.h index db7cdc315184a..5ea52d1907f61 100644 --- a/flang-rt/lib/runtime/unit.h +++ b/flang-rt/lib/runtime/unit.h @@ -71,10 +71,10 @@ class PseudoOpenFile { // at the end of IO statement. RT_API_ATTRS bool isTerminal() const { return true; } RT_API_ATTRS bool isWindowsTextFile() const { return false; } - RT_API_ATTRS Fortran::common::optional knownSize() const; + RT_API_ATTRS common::optional knownSize() const; RT_API_ATTRS bool IsConnected() const { return false; } - RT_API_ATTRS void Open(OpenStatus, Fortran::common::optional, - Position, IoErrorHandler &); + RT_API_ATTRS void Open( + OpenStatus, common::optional, Position, IoErrorHandler &); RT_API_ATTRS void Predefine(int fd) {} RT_API_ATTRS void Close(CloseStatus, IoErrorHandler &); RT_API_ATTRS std::size_t Read(FileOffset, char *, std::size_t minBytes, @@ -127,8 +127,7 @@ class ExternalFileUnit : public ConnectionState, static RT_API_ATTRS ExternalFileUnit *LookUpOrCreate( int unit, const Terminator &, bool &wasExtant); static RT_API_ATTRS ExternalFileUnit *LookUpOrCreateAnonymous(int unit, - Direction, Fortran::common::optional isUnformatted, - IoErrorHandler &); + Direction, common::optional isUnformatted, IoErrorHandler &); static RT_API_ATTRS ExternalFileUnit *LookUp( const char *path, std::size_t pathLen); static RT_API_ATTRS ExternalFileUnit &CreateNew(int unit, const Terminator &); @@ -139,11 +138,11 @@ class ExternalFileUnit : public ConnectionState, static RT_API_ATTRS void FlushAll(IoErrorHandler &); // Returns true if an existing unit was closed - RT_API_ATTRS bool OpenUnit(Fortran::common::optional, - Fortran::common::optional, Position, OwningPtr &&path, + RT_API_ATTRS bool OpenUnit(common::optional, + common::optional, Position, OwningPtr &&path, std::size_t pathLength, Convert, IoErrorHandler &); - RT_API_ATTRS bool OpenAnonymousUnit(Fortran::common::optional, - Fortran::common::optional, Position, Convert, IoErrorHandler &); + RT_API_ATTRS bool OpenAnonymousUnit(common::optional, + common::optional, Position, Convert, IoErrorHandler &); RT_API_ATTRS void CloseUnit(CloseStatus, IoErrorHandler &); RT_API_ATTRS void DestroyClosed(); @@ -254,7 +253,7 @@ class ExternalFileUnit : public ConnectionState, u_; // Points to the active alternative (if any) in u_ for use as a Cookie - Fortran::common::optional io_; + common::optional io_; // A stack of child I/O pseudo-units for defined I/O that have this // unit number. @@ -298,7 +297,7 @@ class ChildIo { ChildUnformattedIoStatementState, InquireUnitState, ErroneousIoStatementState, ExternalMiscIoStatementState> u_; - Fortran::common::optional io_; + common::optional io_; }; RT_OFFLOAD_API_GROUP_END diff --git a/flang-rt/lib/runtime/utf.cpp b/flang-rt/lib/runtime/utf.cpp index ef9df49f24f66..4e4da72eefa3a 100644 --- a/flang-rt/lib/runtime/utf.cpp +++ b/flang-rt/lib/runtime/utf.cpp @@ -56,7 +56,7 @@ std::size_t MeasurePreviousUTF8Bytes(const char *end, std::size_t limit) { } // Non-minimal encodings are accepted. -Fortran::common::optional DecodeUTF8(const char *p0) { +common::optional DecodeUTF8(const char *p0) { const std::uint8_t *p{reinterpret_cast(p0)}; std::size_t bytes{MeasureUTF8Bytes(*p0)}; if (bytes == 1) { @@ -66,7 +66,7 @@ Fortran::common::optional DecodeUTF8(const char *p0) { for (std::size_t j{1}; j < bytes; ++j) { std::uint8_t next{p[j]}; if (next < 0x80 || next > 0xbf) { - return Fortran::common::nullopt; + return common::nullopt; } result = (result << 6) | (next & 0x3f); } @@ -74,7 +74,7 @@ Fortran::common::optional DecodeUTF8(const char *p0) { return static_cast(result); } } - return Fortran::common::nullopt; + return common::nullopt; } std::size_t EncodeUTF8(char *p0, char32_t ucs) {