Skip to content

Commit 34c10ef

Browse files
committed
[flang][NFC] Restore I/O runtime API header name
flang/include/flang/Runtime/io-api.h was changed into io-api-consts.h, then wrapped into a new io-api.h that includes io-api-consts.h, does some redundant includes and declarations, and then declares the prototype of one function, InquiryKeywordHashDecode. Make that function static in io-stmt.cpp prior to its sole call site, then undo the renaming, to reduce confusion and redundancy.
1 parent 6aeae62 commit 34c10ef

File tree

14 files changed

+363
-400
lines changed

14 files changed

+363
-400
lines changed

flang-rt/lib/runtime/io-api.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,6 @@
3333
namespace Fortran::runtime::io {
3434
RT_EXT_API_GROUP_BEGIN
3535

36-
RT_API_ATTRS const char *InquiryKeywordHashDecode(
37-
char *buffer, std::size_t n, InquiryKeywordHash hash) {
38-
if (n < 1) {
39-
return nullptr;
40-
}
41-
char *p{buffer + n};
42-
*--p = '\0';
43-
while (hash > 1) {
44-
if (p < buffer) {
45-
return nullptr;
46-
}
47-
*--p = 'A' + (hash % 26);
48-
hash /= 26;
49-
}
50-
return hash == 1 ? p : nullptr;
51-
}
52-
5336
template <Direction DIR>
5437
RT_API_ATTRS Cookie BeginInternalArrayListIO(const Descriptor &descriptor,
5538
void ** /*scratchArea*/, std::size_t /*scratchBytes*/,

flang-rt/lib/runtime/io-stmt.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,23 @@ bool IoStatementBase::Inquire(InquiryKeywordHash, std::int64_t &) {
7979
return false;
8080
}
8181

82+
RT_API_ATTRS static const char *InquiryKeywordHashDecode(
83+
char *buffer, std::size_t n, InquiryKeywordHash hash) {
84+
if (n < 1) {
85+
return nullptr;
86+
}
87+
char *p{buffer + n};
88+
*--p = '\0';
89+
while (hash > 1) {
90+
if (p < buffer) {
91+
return nullptr;
92+
}
93+
*--p = 'A' + (hash % 26);
94+
hash /= 26;
95+
}
96+
return hash == 1 ? p : nullptr;
97+
}
98+
8299
void IoStatementBase::BadInquiryKeywordHashCrash(InquiryKeywordHash inquiry) {
83100
char buffer[16];
84101
const char *decode{InquiryKeywordHashDecode(buffer, sizeof buffer, inquiry)};

flang-rt/unittests/Runtime/ExternalIOTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "CrashHandlerFixture.h"
1414
#include "gtest/gtest.h"
1515
#include "flang-rt/runtime/descriptor.h"
16-
#include "flang/Runtime/io-api-consts.h"
16+
#include "flang/Runtime/io-api.h"
1717
#include "flang/Runtime/main.h"
1818
#include "flang/Runtime/stop.h"
1919
#include "llvm/Support/raw_ostream.h"

flang-rt/unittests/Runtime/ListInputTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "CrashHandlerFixture.h"
1010
#include "flang-rt/runtime/descriptor.h"
1111
#include "flang-rt/runtime/io-error.h"
12-
#include "flang/Runtime/io-api-consts.h"
12+
#include "flang/Runtime/io-api.h"
1313

1414
using namespace Fortran::runtime;
1515
using namespace Fortran::runtime::io;

flang-rt/unittests/Runtime/LogicalFormatTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "CrashHandlerFixture.h"
1010
#include "flang-rt/runtime/descriptor.h"
11-
#include "flang/Runtime/io-api-consts.h"
11+
#include "flang/Runtime/io-api.h"
1212
#include <algorithm>
1313
#include <array>
1414
#include <cstring>

flang-rt/unittests/Runtime/Namelist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "CrashHandlerFixture.h"
1111
#include "tools.h"
1212
#include "flang-rt/runtime/descriptor.h"
13-
#include "flang/Runtime/io-api-consts.h"
13+
#include "flang/Runtime/io-api.h"
1414
#include <algorithm>
1515
#include <cinttypes>
1616
#include <complex>

flang-rt/unittests/Runtime/NumericalFormatTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "CrashHandlerFixture.h"
1010
#include "flang-rt/runtime/descriptor.h"
11-
#include "flang/Runtime/io-api-consts.h"
11+
#include "flang/Runtime/io-api.h"
1212
#include <algorithm>
1313
#include <array>
1414
#include <cstring>

flang-rt/unittests/Runtime/RuntimeCrashTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "CrashHandlerFixture.h"
1414
#include "tools.h"
1515
#include "flang-rt/runtime/terminator.h"
16-
#include "flang/Runtime/io-api-consts.h"
16+
#include "flang/Runtime/io-api.h"
1717
#include "flang/Runtime/transformational.h"
1818
#include <gtest/gtest.h>
1919

flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "flang/Optimizer/Builder/FIRBuilder.h"
2222
#include "flang/Optimizer/Dialect/FIRDialect.h"
2323
#include "flang/Optimizer/Dialect/FIRType.h"
24-
#include "flang/Runtime/io-api-consts.h"
24+
#include "flang/Runtime/io-api.h"
2525
#include "flang/Runtime/reduce.h"
2626
#include "flang/Support/Fortran.h"
2727
#include "mlir/IR/BuiltinTypes.h"

0 commit comments

Comments
 (0)