diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2018-08-13 21:30:27 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2018-08-13 21:30:27 +0000 |
commit | 6b575395d47b82f5ed5768cd115f180f5d84c042 (patch) | |
tree | b2357df9c44348ab49180bfdbb2664dc9e2547e3 | |
parent | 858162f9728c866ce7ba8826cfcc7649b2e48069 (diff) | |
download | bcm5719-llvm-6b575395d47b82f5ed5768cd115f180f5d84c042.tar.gz bcm5719-llvm-6b575395d47b82f5ed5768cd115f180f5d84c042.zip |
[llvm-objcopy] NFC: Fix minor formatting issues
llvm-svn: 339616
-rw-r--r-- | llvm/tools/llvm-objcopy/Object.h | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 62 |
2 files changed, 32 insertions, 32 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.h b/llvm/tools/llvm-objcopy/Object.h index 8b745284fb0..cabab03abd2 100644 --- a/llvm/tools/llvm-objcopy/Object.h +++ b/llvm/tools/llvm-objcopy/Object.h @@ -656,7 +656,7 @@ class ELFReader : public Reader { public: ElfType getElfType() const; std::unique_ptr<Object> create() const override; - explicit ELFReader(Binary *B) : Bin(B){}; + explicit ELFReader(Binary *B) : Bin(B) {} }; class Object { diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 8d7413f4001..73db661283a 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -216,7 +216,7 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) { } // end namespace objcopy } // end namespace llvm -static SectionFlag ParseSectionRenameFlag(StringRef SectionName) { +static SectionFlag parseSectionRenameFlag(StringRef SectionName) { return llvm::StringSwitch<SectionFlag>(SectionName) .Case("alloc", SectionFlag::SecAlloc) .Case("load", SectionFlag::SecLoad) @@ -233,7 +233,7 @@ static SectionFlag ParseSectionRenameFlag(StringRef SectionName) { .Default(SectionFlag::SecNone); } -static SectionRename ParseRenameSectionValue(StringRef FlagValue) { +static SectionRename parseRenameSectionValue(StringRef FlagValue) { if (!FlagValue.contains('=')) error("Bad format for --rename-section: missing '='"); @@ -250,7 +250,7 @@ static SectionRename ParseRenameSectionValue(StringRef FlagValue) { if (NameAndFlags.size() > 1) { SectionFlag Flags = SectionFlag::SecNone; for (size_t I = 1, Size = NameAndFlags.size(); I < Size; ++I) { - SectionFlag Flag = ParseSectionRenameFlag(NameAndFlags[I]); + SectionFlag Flag = parseSectionRenameFlag(NameAndFlags[I]); if (Flag == SectionFlag::SecNone) error("Unrecognized section flag '" + NameAndFlags[I] + "'. Flags supported for GNU compatibility: alloc, load, noload, " @@ -275,25 +275,25 @@ static SectionRename ParseRenameSectionValue(StringRef FlagValue) { return SR; } -static bool IsDebugSection(const SectionBase &Sec) { +static bool isDebugSection(const SectionBase &Sec) { return Sec.Name.startswith(".debug") || Sec.Name.startswith(".zdebug") || Sec.Name == ".gdb_index"; } -static bool IsDWOSection(const SectionBase &Sec) { +static bool isDWOSection(const SectionBase &Sec) { return Sec.Name.endswith(".dwo"); } -static bool OnlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) { +static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) { // We can't remove the section header string table. if (&Sec == Obj.SectionNames) return false; // Short of keeping the string table we want to keep everything that is a DWO // section and remove everything else. - return !IsDWOSection(Sec); + return !isDWOSection(Sec); } -static std::unique_ptr<Writer> CreateWriter(const CopyConfig &Config, +static std::unique_ptr<Writer> createWriter(const CopyConfig &Config, Object &Obj, Buffer &Buf, ElfType OutputElfType) { if (Config.OutputFormat == "binary") { @@ -317,13 +317,13 @@ static std::unique_ptr<Writer> CreateWriter(const CopyConfig &Config, llvm_unreachable("Invalid output format"); } -static void SplitDWOToFile(const CopyConfig &Config, const Reader &Reader, +static void splitDWOToFile(const CopyConfig &Config, const Reader &Reader, StringRef File, ElfType OutputElfType) { auto DWOFile = Reader.create(); DWOFile->removeSections( - [&](const SectionBase &Sec) { return OnlyKeepDWOPred(*DWOFile, Sec); }); + [&](const SectionBase &Sec) { return onlyKeepDWOPred(*DWOFile, Sec); }); FileBuffer FB(File); - auto Writer = CreateWriter(Config, *DWOFile, FB, OutputElfType); + auto Writer = createWriter(Config, *DWOFile, FB, OutputElfType); Writer->finalize(); Writer->write(); } @@ -359,11 +359,11 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename, // any previous removals. Lastly whether or not something is removed shouldn't // depend a) on the order the options occur in or b) on some opaque priority // system. The only priority is that keeps/copies overrule removes. -static void HandleArgs(const CopyConfig &Config, Object &Obj, +static void handleArgs(const CopyConfig &Config, Object &Obj, const Reader &Reader, ElfType OutputElfType) { if (!Config.SplitDWO.empty()) { - SplitDWOToFile(Config, Reader, Config.SplitDWO, OutputElfType); + splitDWOToFile(Config, Reader, Config.SplitDWO, OutputElfType); } // TODO: update or remove symbols only if there is an option that affects @@ -444,12 +444,12 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj, if (Config.StripDWO || !Config.SplitDWO.empty()) RemovePred = [RemovePred](const SectionBase &Sec) { - return IsDWOSection(Sec) || RemovePred(Sec); + return isDWOSection(Sec) || RemovePred(Sec); }; if (Config.ExtractDWO) RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { - return OnlyKeepDWOPred(Obj, Sec) || RemovePred(Sec); + return onlyKeepDWOPred(Obj, Sec) || RemovePred(Sec); }; if (Config.StripAllGNU) @@ -467,7 +467,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj, case SHT_STRTAB: return true; } - return IsDebugSection(Sec); + return isDebugSection(Sec); }; if (Config.StripSections) { @@ -478,7 +478,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj, if (Config.StripDebug) { RemovePred = [RemovePred](const SectionBase &Sec) { - return RemovePred(Sec) || IsDebugSection(Sec); + return RemovePred(Sec) || isDebugSection(Sec); }; } @@ -601,15 +601,15 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj, Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink); } -static void ExecuteElfObjcopyOnBinary(const CopyConfig &Config, Binary &Binary, +static void executeElfObjcopyOnBinary(const CopyConfig &Config, Binary &Binary, Buffer &Out) { ELFReader Reader(&Binary); std::unique_ptr<Object> Obj = Reader.create(); - HandleArgs(Config, *Obj, Reader, Reader.getElfType()); + handleArgs(Config, *Obj, Reader, Reader.getElfType()); std::unique_ptr<Writer> Writer = - CreateWriter(Config, *Obj, Out, Reader.getElfType()); + createWriter(Config, *Obj, Out, Reader.getElfType()); Writer->finalize(); Writer->write(); } @@ -643,7 +643,7 @@ static Error deepWriteArchive(StringRef ArcName, return Error::success(); } -static void ExecuteElfObjcopyOnArchive(const CopyConfig &Config, +static void executeElfObjcopyOnArchive(const CopyConfig &Config, const Archive &Ar) { std::vector<NewArchiveMember> NewArchiveMembers; Error Err = Error::success(); @@ -656,7 +656,7 @@ static void ExecuteElfObjcopyOnArchive(const CopyConfig &Config, reportError(Ar.getFileName(), ChildNameOrErr.takeError()); MemBuffer MB(ChildNameOrErr.get()); - ExecuteElfObjcopyOnBinary(Config, **ChildOrErr, MB); + executeElfObjcopyOnBinary(Config, **ChildOrErr, MB); Expected<NewArchiveMember> Member = NewArchiveMember::getOldMember(Child, true); @@ -675,23 +675,23 @@ static void ExecuteElfObjcopyOnArchive(const CopyConfig &Config, reportError(Config.OutputFilename, std::move(E)); } -static void ExecuteElfObjcopy(const CopyConfig &Config) { +static void executeElfObjcopy(const CopyConfig &Config) { Expected<OwningBinary<llvm::object::Binary>> BinaryOrErr = createBinary(Config.InputFilename); if (!BinaryOrErr) reportError(Config.InputFilename, BinaryOrErr.takeError()); if (Archive *Ar = dyn_cast<Archive>(BinaryOrErr.get().getBinary())) - return ExecuteElfObjcopyOnArchive(Config, *Ar); + return executeElfObjcopyOnArchive(Config, *Ar); FileBuffer FB(Config.OutputFilename); - ExecuteElfObjcopyOnBinary(Config, *BinaryOrErr.get().getBinary(), FB); + executeElfObjcopyOnBinary(Config, *BinaryOrErr.get().getBinary(), FB); } // ParseObjcopyOptions returns the config and sets the input arguments. If a // help flag is set then ParseObjcopyOptions will print the help messege and // exit. -static CopyConfig ParseObjcopyOptions(ArrayRef<const char *> ArgsArr) { +static CopyConfig parseObjcopyOptions(ArrayRef<const char *> ArgsArr) { ObjcopyOptTable T; unsigned MissingArgumentIndex, MissingArgumentCount; llvm::opt::InputArgList InputArgs = @@ -741,7 +741,7 @@ static CopyConfig ParseObjcopyOptions(ArrayRef<const char *> ArgsArr) { } for (auto Arg : InputArgs.filtered(OBJCOPY_rename_section)) { - SectionRename SR = ParseRenameSectionValue(StringRef(Arg->getValue())); + SectionRename SR = parseRenameSectionValue(StringRef(Arg->getValue())); if (!Config.SectionsToRename.try_emplace(SR.OriginalName, SR).second) error("Multiple renames of section " + SR.OriginalName); } @@ -786,7 +786,7 @@ static CopyConfig ParseObjcopyOptions(ArrayRef<const char *> ArgsArr) { // ParseStripOptions returns the config and sets the input arguments. If a // help flag is set then ParseStripOptions will print the help messege and // exit. -static CopyConfig ParseStripOptions(ArrayRef<const char *> ArgsArr) { +static CopyConfig parseStripOptions(ArrayRef<const char *> ArgsArr) { StripOptTable T; unsigned MissingArgumentIndex, MissingArgumentCount; llvm::opt::InputArgList InputArgs = @@ -842,8 +842,8 @@ int main(int argc, char **argv) { ToolName = argv[0]; CopyConfig Config; if (sys::path::stem(ToolName).endswith_lower("strip")) - Config = ParseStripOptions(makeArrayRef(argv + 1, argc)); + Config = parseStripOptions(makeArrayRef(argv + 1, argc)); else - Config = ParseObjcopyOptions(makeArrayRef(argv + 1, argc)); - ExecuteElfObjcopy(Config); + Config = parseObjcopyOptions(makeArrayRef(argv + 1, argc)); + executeElfObjcopy(Config); } |