Skip to content

Commit 86fa4b2

Browse files
authored
[readtapi] Swap anon namespaces in favor of annotating static, NFC (#75078)
1 parent 07919cf commit 86fa4b2

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

llvm/tools/llvm-readtapi/llvm-readtapi.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,31 @@ class TAPIOptTable : public opt::GenericOptTable {
5656
}
5757
};
5858

59+
struct Context {
60+
std::vector<std::string> Inputs;
61+
std::unique_ptr<llvm::raw_fd_stream> OutStream;
62+
FileType WriteFT = FileType::TBD_V5;
63+
bool Compact = false;
64+
Architecture Arch = AK_unknown;
65+
};
66+
5967
// Use unique exit code to differentiate failures not directly caused from
6068
// TextAPI operations. This is used for wrapping `compare` operations in
6169
// automation and scripting.
6270
const int NON_TAPI_EXIT_CODE = 2;
6371
const std::string TOOLNAME = "llvm-readtapi";
6472
ExitOnError ExitOnErr;
73+
} // anonymous namespace
6574

6675
// Handle error reporting in cases where `ExitOnError` is not used.
67-
void reportError(Twine Message, int ExitCode = EXIT_FAILURE) {
76+
static void reportError(Twine Message, int ExitCode = EXIT_FAILURE) {
6877
errs() << TOOLNAME << ": error: " << Message << "\n";
6978
errs().flush();
7079
exit(ExitCode);
7180
}
7281

73-
struct Context {
74-
std::vector<std::string> Inputs;
75-
std::unique_ptr<llvm::raw_fd_stream> OutStream;
76-
FileType WriteFT = FileType::TBD_V5;
77-
bool Compact = false;
78-
Architecture Arch = AK_unknown;
79-
};
80-
81-
std::unique_ptr<InterfaceFile> getInterfaceFile(const StringRef Filename,
82-
bool ResetBanner = true) {
82+
static std::unique_ptr<InterfaceFile>
83+
getInterfaceFile(const StringRef Filename, bool ResetBanner = true) {
8384
ExitOnErr.setBanner(TOOLNAME + ": error: '" + Filename.str() + "' ");
8485
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
8586
MemoryBuffer::getFile(Filename);
@@ -94,7 +95,7 @@ std::unique_ptr<InterfaceFile> getInterfaceFile(const StringRef Filename,
9495
return std::move(*IF);
9596
}
9697

97-
bool handleCompareAction(const Context &Ctx) {
98+
static bool handleCompareAction(const Context &Ctx) {
9899
if (Ctx.Inputs.size() != 2)
99100
reportError("compare only supports two input files",
100101
/*ExitCode=*/NON_TAPI_EXIT_CODE);
@@ -109,8 +110,8 @@ bool handleCompareAction(const Context &Ctx) {
109110
return DiffEngine(LeftIF.get(), RightIF.get()).compareFiles(OS);
110111
}
111112

112-
bool handleWriteAction(const Context &Ctx,
113-
std::unique_ptr<InterfaceFile> Out = nullptr) {
113+
static bool handleWriteAction(const Context &Ctx,
114+
std::unique_ptr<InterfaceFile> Out = nullptr) {
114115
if (!Out) {
115116
if (Ctx.Inputs.size() != 1)
116117
reportError("write only supports one input file");
@@ -121,7 +122,7 @@ bool handleWriteAction(const Context &Ctx,
121122
return EXIT_SUCCESS;
122123
}
123124

124-
bool handleMergeAction(const Context &Ctx) {
125+
static bool handleMergeAction(const Context &Ctx) {
125126
if (Ctx.Inputs.size() < 2)
126127
reportError("merge requires at least two input files");
127128

@@ -144,8 +145,8 @@ bool handleMergeAction(const Context &Ctx) {
144145
using IFOperation =
145146
std::function<llvm::Expected<std::unique_ptr<InterfaceFile>>(
146147
const llvm::MachO::InterfaceFile &, Architecture)>;
147-
bool handleSingleFileAction(const Context &Ctx, const StringRef Action,
148-
IFOperation act) {
148+
static bool handleSingleFileAction(const Context &Ctx, const StringRef Action,
149+
IFOperation act) {
149150
if (Ctx.Inputs.size() != 1)
150151
reportError(Action + " only supports one input file");
151152
if (Ctx.Arch == AK_unknown)
@@ -159,8 +160,6 @@ bool handleSingleFileAction(const Context &Ctx, const StringRef Action,
159160
return handleWriteAction(Ctx, std::move(*OutIF));
160161
}
161162

162-
} // anonymous namespace
163-
164163
int main(int Argc, char **Argv) {
165164
InitLLVM X(Argc, Argv);
166165
BumpPtrAllocator A;

0 commit comments

Comments
 (0)