diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-11-01 21:16:06 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-11-01 21:16:06 +0000 |
commit | 0ad18f888ed464b28e947dbc92ea4d6764caf128 (patch) | |
tree | e08ca9eaa5cca60913b7179a09b084e1c2429437 /llvm/tools/llvm-objcopy/llvm-objcopy.cpp | |
parent | 4e56ba271e808f5d93184440ee9345133697d749 (diff) | |
download | bcm5719-llvm-0ad18f888ed464b28e947dbc92ea4d6764caf128.tar.gz bcm5719-llvm-0ad18f888ed464b28e947dbc92ea4d6764caf128.zip |
[dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317123
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 7f55a434b33..f3e9c7750a6 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -1,4 +1,4 @@ -//===- llvm-objcopy.cpp -----------------------------------------*- C++ -*-===// +//===- llvm-objcopy.cpp ---------------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -6,17 +6,37 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + #include "llvm-objcopy.h" #include "Object.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" +#include "llvm/BinaryFormat/ELF.h" +#include "llvm/Object/Binary.h" +#include "llvm/Object/ELFObjectFile.h" +#include "llvm/Object/ELFTypes.h" +#include "llvm/Object/Error.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileOutputBuffer.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" -#include "llvm/Support/ToolOutputFile.h" - +#include "llvm/Support/raw_ostream.h" +#include <algorithm> +#include <cassert> +#include <cstdlib> +#include <functional> +#include <iterator> #include <memory> #include <string> #include <system_error> +#include <utility> using namespace llvm; using namespace object; @@ -39,7 +59,7 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, std::error_code EC) { exit(1); } -LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, llvm::Error E) { +LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) { assert(E); std::string Buf; raw_string_ostream OS(Buf); @@ -48,22 +68,23 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, llvm::Error E) { errs() << ToolName << ": '" << File << "': " << Buf; exit(1); } -} -cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input>")); -cl::opt<std::string> OutputFilename(cl::Positional, cl::desc("<output>"), +} // end namespace llvm + +static cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input>")); +static cl::opt<std::string> OutputFilename(cl::Positional, cl::desc("<output>"), cl::init("-")); -cl::opt<std::string> +static cl::opt<std::string> OutputFormat("O", cl::desc("set output format to one of the following:" "\n\tbinary")); -cl::list<std::string> ToRemove("remove-section", - cl::desc("Remove a specific section")); -cl::alias ToRemoveA("R", cl::desc("Alias for remove-section"), - cl::aliasopt(ToRemove)); -cl::opt<bool> StripSections("strip-sections", - cl::desc("Remove all section headers")); - -typedef std::function<bool(const SectionBase &Sec)> SectionPred; +static cl::list<std::string> ToRemove("remove-section", + cl::desc("Remove a specific section")); +static cl::alias ToRemoveA("R", cl::desc("Alias for remove-section"), + cl::aliasopt(ToRemove)); +static cl::opt<bool> StripSections("strip-sections", + cl::desc("Remove all section headers")); + +using SectionPred = std::function<bool(const SectionBase &Sec)>; void CopyBinary(const ELFObjectFile<ELF64LE> &ObjFile) { std::unique_ptr<FileOutputBuffer> Buffer; |