[llvm] [readtapi] Swap anon namespaces in favor of annotating `static`, NFC (PR #75078)
Cyndy Ishida via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 09:55:17 PST 2023
https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/75078
None
>From c48896c821be00cd97317de070d116419cbdd5e1 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida <cyndy_ishida at apple.com>
Date: Mon, 11 Dec 2023 09:51:45 -0800
Subject: [PATCH] [readtapi] Swap anon namespaces in favor of annotating
`static`, NFC
---
llvm/tools/llvm-readtapi/llvm-readtapi.cpp | 37 +++++++++++-----------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
index cb2b36072a552..64eff70dbfc75 100644
--- a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
+++ b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
@@ -56,30 +56,31 @@ class TAPIOptTable : public opt::GenericOptTable {
}
};
+struct Context {
+ std::vector<std::string> Inputs;
+ std::unique_ptr<llvm::raw_fd_stream> OutStream;
+ FileType WriteFT = FileType::TBD_V5;
+ bool Compact = false;
+ Architecture Arch = AK_unknown;
+};
+
// Use unique exit code to differentiate failures not directly caused from
// TextAPI operations. This is used for wrapping `compare` operations in
// automation and scripting.
const int NON_TAPI_EXIT_CODE = 2;
const std::string TOOLNAME = "llvm-readtapi";
ExitOnError ExitOnErr;
+} // anonymous namespace
// Handle error reporting in cases where `ExitOnError` is not used.
-void reportError(Twine Message, int ExitCode = EXIT_FAILURE) {
+static void reportError(Twine Message, int ExitCode = EXIT_FAILURE) {
errs() << TOOLNAME << ": error: " << Message << "\n";
errs().flush();
exit(ExitCode);
}
-struct Context {
- std::vector<std::string> Inputs;
- std::unique_ptr<llvm::raw_fd_stream> OutStream;
- FileType WriteFT = FileType::TBD_V5;
- bool Compact = false;
- Architecture Arch = AK_unknown;
-};
-
-std::unique_ptr<InterfaceFile> getInterfaceFile(const StringRef Filename,
- bool ResetBanner = true) {
+static std::unique_ptr<InterfaceFile>
+getInterfaceFile(const StringRef Filename, bool ResetBanner = true) {
ExitOnErr.setBanner(TOOLNAME + ": error: '" + Filename.str() + "' ");
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(Filename);
@@ -94,7 +95,7 @@ std::unique_ptr<InterfaceFile> getInterfaceFile(const StringRef Filename,
return std::move(*IF);
}
-bool handleCompareAction(const Context &Ctx) {
+static bool handleCompareAction(const Context &Ctx) {
if (Ctx.Inputs.size() != 2)
reportError("compare only supports two input files",
/*ExitCode=*/NON_TAPI_EXIT_CODE);
@@ -109,8 +110,8 @@ bool handleCompareAction(const Context &Ctx) {
return DiffEngine(LeftIF.get(), RightIF.get()).compareFiles(OS);
}
-bool handleWriteAction(const Context &Ctx,
- std::unique_ptr<InterfaceFile> Out = nullptr) {
+static bool handleWriteAction(const Context &Ctx,
+ std::unique_ptr<InterfaceFile> Out = nullptr) {
if (!Out) {
if (Ctx.Inputs.size() != 1)
reportError("write only supports one input file");
@@ -121,7 +122,7 @@ bool handleWriteAction(const Context &Ctx,
return EXIT_SUCCESS;
}
-bool handleMergeAction(const Context &Ctx) {
+static bool handleMergeAction(const Context &Ctx) {
if (Ctx.Inputs.size() < 2)
reportError("merge requires at least two input files");
@@ -144,8 +145,8 @@ bool handleMergeAction(const Context &Ctx) {
using IFOperation =
std::function<llvm::Expected<std::unique_ptr<InterfaceFile>>(
const llvm::MachO::InterfaceFile &, Architecture)>;
-bool handleSingleFileAction(const Context &Ctx, const StringRef Action,
- IFOperation act) {
+static bool handleSingleFileAction(const Context &Ctx, const StringRef Action,
+ IFOperation act) {
if (Ctx.Inputs.size() != 1)
reportError(Action + " only supports one input file");
if (Ctx.Arch == AK_unknown)
@@ -159,8 +160,6 @@ bool handleSingleFileAction(const Context &Ctx, const StringRef Action,
return handleWriteAction(Ctx, std::move(*OutIF));
}
-} // anonymous namespace
-
int main(int Argc, char **Argv) {
InitLLVM X(Argc, Argv);
BumpPtrAllocator A;
More information about the llvm-commits
mailing list