Skip to content

Commit 7689db8

Browse files
authored
[flang][runtime][NFC] Clean up Fortran::common::optional<> usage (#155728)
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.
1 parent f9e16fa commit 7689db8

26 files changed

+171
-184
lines changed

flang-rt/include/flang-rt/runtime/connection.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ enum class Access { Sequential, Direct, Stream };
2626
// established in an OPEN statement.
2727
struct ConnectionAttributes {
2828
Access access{Access::Sequential}; // ACCESS='SEQUENTIAL', 'DIRECT', 'STREAM'
29-
Fortran::common::optional<bool> isUnformatted; // FORM='UNFORMATTED' if true
29+
common::optional<bool> isUnformatted; // FORM='UNFORMATTED' if true
3030
bool isUTF8{false}; // ENCODING='UTF-8'
3131
unsigned char internalIoCharKind{0}; // 0->external, 1/2/4->internal
32-
Fortran::common::optional<std::int64_t> openRecl; // RECL= on OPEN
32+
common::optional<std::int64_t> openRecl; // RECL= on OPEN
3333

3434
RT_API_ATTRS bool IsRecordFile() const {
3535
// Formatted stream files are viewed as having records, at least on input
@@ -82,15 +82,14 @@ struct ConnectionState : public ConnectionAttributes {
8282
unterminatedRecord = false;
8383
}
8484

85-
RT_API_ATTRS Fortran::common::optional<std::int64_t>
86-
EffectiveRecordLength() const {
85+
RT_API_ATTRS common::optional<std::int64_t> EffectiveRecordLength() const {
8786
// When an input record is longer than an explicit RECL= from OPEN
8887
// it is effectively truncated on input.
8988
return openRecl && recordLength && *openRecl < *recordLength ? openRecl
9089
: recordLength;
9190
}
9291

93-
Fortran::common::optional<std::int64_t> recordLength;
92+
common::optional<std::int64_t> recordLength;
9493

9594
std::int64_t currentRecordNumber{1}; // 1 is first
9695

@@ -106,12 +105,11 @@ struct ConnectionState : public ConnectionAttributes {
106105
std::int64_t furthestPositionInRecord{0}; // max(position+bytes)
107106

108107
// Set at end of non-advancing I/O data transfer
109-
Fortran::common::optional<std::int64_t>
110-
leftTabLimit; // offset in current record
108+
common::optional<std::int64_t> leftTabLimit; // offset in current record
111109

112110
// currentRecordNumber value captured after ENDFILE/REWIND/BACKSPACE statement
113111
// or an end-of-file READ condition on a sequential access file
114-
Fortran::common::optional<std::int64_t> endfileRecordNumber;
112+
common::optional<std::int64_t> endfileRecordNumber;
115113

116114
// Mutable modes set at OPEN() that can be overridden in READ/WRITE & FORMAT
117115
MutableModes modes; // BLANK=, DECIMAL=, SIGN=, ROUND=, PAD=, DELIM=, kP

flang-rt/include/flang-rt/runtime/environment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ RT_OFFLOAD_VAR_GROUP_END
3131
// External unformatted I/O data conversions
3232
enum class Convert { Unknown, Native, LittleEndian, BigEndian, Swap };
3333

34-
RT_API_ATTRS Fortran::common::optional<Convert> GetConvertFromString(
34+
RT_API_ATTRS common::optional<Convert> GetConvertFromString(
3535
const char *, std::size_t);
3636

3737
struct ExecutionEnvironment {

flang-rt/include/flang-rt/runtime/file.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ class OpenFile {
3737
void set_mayAsynchronous(bool yes) { mayAsynchronous_ = yes; }
3838
bool isTerminal() const { return isTerminal_; }
3939
bool isWindowsTextFile() const { return isWindowsTextFile_; }
40-
Fortran::common::optional<FileOffset> knownSize() const { return knownSize_; }
40+
common::optional<FileOffset> knownSize() const { return knownSize_; }
4141

4242
bool IsConnected() const { return fd_ >= 0; }
43-
void Open(OpenStatus, Fortran::common::optional<Action>, Position,
44-
IoErrorHandler &);
43+
void Open(OpenStatus, common::optional<Action>, Position, IoErrorHandler &);
4544
void Predefine(int fd);
4645
void Close(CloseStatus, IoErrorHandler &);
4746

@@ -95,10 +94,10 @@ class OpenFile {
9594
bool mayWrite_{false};
9695
bool mayPosition_{false};
9796
bool mayAsynchronous_{false};
98-
Fortran::common::optional<Position>
97+
common::optional<Position>
9998
openPosition_; // from Open(); reset after positioning
10099
FileOffset position_{0};
101-
Fortran::common::optional<FileOffset> knownSize_;
100+
common::optional<FileOffset> knownSize_;
102101
bool isTerminal_{false};
103102
bool isWindowsTextFile_{false}; // expands LF to CR+LF on write
104103

flang-rt/include/flang-rt/runtime/format-implementation.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
302302
}
303303
}
304304
while (true) {
305-
Fortran::common::optional<int> repeat;
305+
common::optional<int> repeat;
306306
bool unlimited{false};
307307
auto maybeReversionPoint{offset_};
308308
CharType ch{GetNextChar(context)};
@@ -498,8 +498,8 @@ RT_API_ATTRS int FormatControl<CONTEXT>::CueUpNextDataEdit(
498498

499499
// Returns the next data edit descriptor
500500
template <typename CONTEXT>
501-
RT_API_ATTRS Fortran::common::optional<DataEdit>
502-
FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
501+
RT_API_ATTRS common::optional<DataEdit> FormatControl<CONTEXT>::GetNextDataEdit(
502+
Context &context, int maxRepeat) {
503503
int repeat{CueUpNextDataEdit(context)};
504504
auto start{offset_};
505505
DataEdit edit;
@@ -530,7 +530,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
530530
}
531531
if (edit.ioTypeChars >= edit.maxIoTypeChars) {
532532
ReportBadFormat(context, "Excessive DT'iotype' in FORMAT", start);
533-
return Fortran::common::nullopt;
533+
return common::nullopt;
534534
}
535535
edit.ioType[edit.ioTypeChars++] = ch;
536536
if (ch == quote) {
@@ -539,7 +539,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
539539
}
540540
if (!ok) {
541541
ReportBadFormat(context, "Unclosed DT'iotype' in FORMAT", start);
542-
return Fortran::common::nullopt;
542+
return common::nullopt;
543543
}
544544
}
545545
if (PeekNext() == '(') {
@@ -554,7 +554,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
554554
}
555555
if (edit.vListEntries >= edit.maxVListEntries) {
556556
ReportBadFormat(context, "Excessive DT(v_list) in FORMAT", start);
557-
return Fortran::common::nullopt;
557+
return common::nullopt;
558558
}
559559
edit.vList[edit.vListEntries++] = n;
560560
auto ch{static_cast<char>(GetNextChar(context))};
@@ -565,7 +565,7 @@ FormatControl<CONTEXT>::GetNextDataEdit(Context &context, int maxRepeat) {
565565
}
566566
if (!ok) {
567567
ReportBadFormat(context, "Unclosed DT(v_list) in FORMAT", start);
568-
return Fortran::common::nullopt;
568+
return common::nullopt;
569569
}
570570
}
571571
} else { // not DT'iotype'

flang-rt/include/flang-rt/runtime/format.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ struct DataEdit {
7676
}
7777

7878
char variation{'\0'}; // N, S, or X for EN, ES, EX; G/l for original G/list
79-
Fortran::common::optional<int> width; // the 'w' field; optional for A
80-
Fortran::common::optional<int> digits; // the 'm' or 'd' field
81-
Fortran::common::optional<int> expoDigits; // 'Ee' field
79+
common::optional<int> width; // the 'w' field; optional for A
80+
common::optional<int> digits; // the 'm' or 'd' field
81+
common::optional<int> expoDigits; // 'Ee' field
8282
MutableModes modes;
8383
int repeat{1};
8484

@@ -116,7 +116,7 @@ template <typename CONTEXT> class FormatControl {
116116
// Extracts the next data edit descriptor, handling control edit descriptors
117117
// along the way. If maxRepeat==0, this is a peek at the next data edit
118118
// descriptor.
119-
RT_API_ATTRS Fortran::common::optional<DataEdit> GetNextDataEdit(
119+
RT_API_ATTRS common::optional<DataEdit> GetNextDataEdit(
120120
Context &, int maxRepeat = 1);
121121

122122
// Emit any remaining character literals after the last data item (on output)

0 commit comments

Comments
 (0)