#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ArchiveWriter.h"
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h"
#include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#else
#include <io.h>
#endif
#ifdef _WIN32
#include "llvm/Support/Windows/WindowsSupport.h"
#endif
usingnamespacellvm;
usingnamespacellvm::object;
static StringRef ToolName;
static StringRef Stem;
static void printRanLibHelp(StringRef ToolName) { … }
static void printArHelp(StringRef ToolName) { … }
static void printHelpMessage() { … }
static unsigned MRILineNumber;
static bool ParsingMRIScript;
[[noreturn]] static void badUsage(Twine Error) { … }
[[noreturn]] static void fail(Twine Error) { … }
static void failIfError(std::error_code EC, Twine Context = "") { … }
static void failIfError(Error E, Twine Context = "") { … }
static void warn(Twine Message) { … }
static SmallVector<const char *, 256> PositionalArgs;
static bool MRI;
namespace {
enum Format { … };
}
static Format FormatType = …;
static std::string Options;
enum ArchiveOperation { … };
enum class BitModeTy { … };
static BitModeTy BitMode = …;
static bool AddAfter = …;
static bool AddBefore = …;
static bool Create = …;
static bool OriginalDates = …;
static bool DisplayMemberOffsets = …;
static bool CompareFullPath = …;
static bool OnlyUpdate = …;
static bool Verbose = …;
static SymtabWritingMode Symtab = …;
static bool Deterministic = …;
static bool Thin = …;
static bool AddLibrary = …;
static std::string RelPos;
static int CountParam = …;
static std::string ArchiveName;
static std::string OutputDir;
static std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
static std::vector<std::unique_ptr<object::Archive>> Archives;
static std::vector<StringRef> Members;
static BumpPtrAllocator Alloc;
static void getRelPos() { … }
static void getCountParam() { … }
static void getArchive() { … }
static object::Archive &readLibrary(const Twine &Library) { … }
static void runMRIScript();
static ArchiveOperation parseCommandLine() { … }
static void doPrint(StringRef Name, const object::Archive::Child &C) { … }
static void printMode(unsigned mode) { … }
static void doDisplayTable(StringRef Name, const object::Archive::Child &C) { … }
static std::string normalizePath(StringRef Path) { … }
static bool comparePaths(StringRef Path1, StringRef Path2) { … }
static void doExtract(StringRef Name, const object::Archive::Child &C) { … }
static bool shouldCreateArchive(ArchiveOperation Op) { … }
static bool isValidInBitMode(Binary &Bin) { … }
Expected<std::unique_ptr<Binary>> getAsBinary(const NewArchiveMember &NM,
LLVMContext *Context) { … }
Expected<std::unique_ptr<Binary>> getAsBinary(const Archive::Child &C,
LLVMContext *Context) { … }
template <class A> static bool isValidInBitMode(const A &Member) { … }
static void warnInvalidObjectForFileMode(Twine Name) { … }
static void performReadOperation(ArchiveOperation Operation,
object::Archive *OldArchive) { … }
static void addChildMember(std::vector<NewArchiveMember> &Members,
const object::Archive::Child &M,
bool FlattenArchive = false) { … }
static NewArchiveMember getArchiveMember(StringRef FileName) { … }
static void addMember(std::vector<NewArchiveMember> &Members,
NewArchiveMember &NM) { … }
static void addMember(std::vector<NewArchiveMember> &Members,
StringRef FileName, bool FlattenArchive = false) { … }
enum InsertAction { … };
static InsertAction computeInsertAction(ArchiveOperation Operation,
const object::Archive::Child &Member,
StringRef Name,
std::vector<StringRef>::iterator &Pos,
StringMap<int> &MemberCount) { … }
static std::vector<NewArchiveMember>
computeNewArchiveMembers(ArchiveOperation Operation,
object::Archive *OldArchive) { … }
static void performWriteOperation(ArchiveOperation Operation,
object::Archive *OldArchive,
std::unique_ptr<MemoryBuffer> OldArchiveBuf,
std::vector<NewArchiveMember> *NewMembersP) { … }
static void createSymbolTable(object::Archive *OldArchive) { … }
static void performOperation(ArchiveOperation Operation,
object::Archive *OldArchive,
std::unique_ptr<MemoryBuffer> OldArchiveBuf,
std::vector<NewArchiveMember> *NewMembers) { … }
static int performOperation(ArchiveOperation Operation) { … }
static void runMRIScript() { … }
static bool handleGenericOption(StringRef arg) { … }
static BitModeTy getBitMode(const char *RawBitMode) { … }
static const char *matchFlagWithArg(StringRef Expected,
ArrayRef<const char *>::iterator &ArgIt,
ArrayRef<const char *> Args) { … }
static cl::TokenizerCallback getRspQuoting(ArrayRef<const char *> ArgsArr) { … }
static int ar_main(int argc, char **argv) { … }
static int ranlib_main(int argc, char **argv) { … }
int llvm_ar_main(int argc, char **argv, const llvm::ToolContext &) { … }