[llvm] r339616 - [llvm-objcopy] NFC: Fix minor formatting issues
Jordan Rupprecht via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 13 14:30:27 PDT 2018
Author: rupprecht
Date: Mon Aug 13 14:30:27 2018
New Revision: 339616
URL: http://llvm.org/viewvc/llvm-project?rev=339616&view=rev
Log:
[llvm-objcopy] NFC: Fix minor formatting issues
Modified:
llvm/trunk/tools/llvm-objcopy/Object.h
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
Modified: llvm/trunk/tools/llvm-objcopy/Object.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/Object.h?rev=339616&r1=339615&r2=339616&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/Object.h (original)
+++ llvm/trunk/tools/llvm-objcopy/Object.h Mon Aug 13 14:30:27 2018
@@ -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 {
Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=339616&r1=339615&r2=339616&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Mon Aug 13 14:30:27 2018
@@ -216,7 +216,7 @@ LLVM_ATTRIBUTE_NORETURN void reportError
} // 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 ParseSectionRenameFla
.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 ParseRenameSectionV
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 ParseRenameSectionV
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> CreateWri
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
// 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
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
case SHT_STRTAB:
return true;
}
- return IsDebugSection(Sec);
+ return isDebugSection(Sec);
};
if (Config.StripSections) {
@@ -478,7 +478,7 @@ static void HandleArgs(const CopyConfig
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
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
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(c
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(c
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(Ar
}
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(Ar
// 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);
}
More information about the llvm-commits
mailing list