[llvm] 86fa4b2 - [readtapi] Swap anon namespaces in favor of annotating `static`, NFC (#75078)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 13:33:40 PST 2023
Author: Cyndy Ishida
Date: 2023-12-11T13:33:36-08:00
New Revision: 86fa4b2c46191fe6be88e38bb46487472f6892c9
URL: https://github.com/llvm/llvm-project/commit/86fa4b2c46191fe6be88e38bb46487472f6892c9
DIFF: https://github.com/llvm/llvm-project/commit/86fa4b2c46191fe6be88e38bb46487472f6892c9.diff
LOG: [readtapi] Swap anon namespaces in favor of annotating `static`, NFC (#75078)
Added:
Modified:
llvm/tools/llvm-readtapi/llvm-readtapi.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
index cb2b36072a552b..64eff70dbfc75d 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
diff erentiate 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