Skip to content

Commit 7bbb65b

Browse files
committed
[llvm-objcopy][NFC] fix style issues reported by clang-format.
1 parent 95429b8 commit 7bbb65b

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

llvm/tools/llvm-objcopy/COFF/Object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace coff {
2626

2727
struct Relocation {
2828
Relocation() = default;
29-
Relocation(const object::coff_relocation& R) : Reloc(R) {}
29+
Relocation(const object::coff_relocation &R) : Reloc(R) {}
3030

3131
object::coff_relocation Reloc;
3232
size_t Target = 0;

llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,9 @@ findBuildID(const CopyConfig &Config, const object::ELFFile<ELFT> &In) {
184184
return createFileError(Config.InputFilename, std::move(Err));
185185
}
186186

187-
return createFileError(
188-
Config.InputFilename,
189-
createStringError(llvm::errc::invalid_argument,
190-
"could not find build ID"));
187+
return createFileError(Config.InputFilename,
188+
createStringError(llvm::errc::invalid_argument,
189+
"could not find build ID"));
191190
}
192191

193192
static Expected<ArrayRef<uint8_t>>
@@ -205,7 +204,8 @@ findBuildID(const CopyConfig &Config, const object::ELFObjectFileBase &In) {
205204
}
206205

207206
template <class... Ts>
208-
static Error makeStringError(std::error_code EC, const Twine &Msg, Ts &&... Args) {
207+
static Error makeStringError(std::error_code EC, const Twine &Msg,
208+
Ts &&... Args) {
209209
std::string FullMsg = (EC.message() + ": " + Msg).str();
210210
return createStringError(EC, FullMsg.c_str(), std::forward<Ts>(Args)...);
211211
}
@@ -318,20 +318,20 @@ static bool isCompressable(const SectionBase &Sec) {
318318

319319
static Error replaceDebugSections(
320320
Object &Obj, SectionPred &RemovePred,
321-
function_ref<bool(const SectionBase &)> shouldReplace,
322-
function_ref<Expected<SectionBase *>(const SectionBase *)> addSection) {
321+
function_ref<bool(const SectionBase &)> ShouldReplace,
322+
function_ref<Expected<SectionBase *>(const SectionBase *)> AddSection) {
323323
// Build a list of the debug sections we are going to replace.
324324
// We can't call `AddSection` while iterating over sections,
325325
// because it would mutate the sections array.
326326
SmallVector<SectionBase *, 13> ToReplace;
327327
for (auto &Sec : Obj.sections())
328-
if (shouldReplace(Sec))
328+
if (ShouldReplace(Sec))
329329
ToReplace.push_back(&Sec);
330330

331331
// Build a mapping from original section to a new one.
332332
DenseMap<SectionBase *, SectionBase *> FromTo;
333333
for (SectionBase *S : ToReplace) {
334-
Expected<SectionBase *> NewSection = addSection(S);
334+
Expected<SectionBase *> NewSection = AddSection(S);
335335
if (!NewSection)
336336
return NewSection.takeError();
337337

@@ -344,8 +344,8 @@ static Error replaceDebugSections(
344344
for (auto &Sec : Obj.sections())
345345
Sec.replaceSectionReferences(FromTo);
346346

347-
RemovePred = [shouldReplace, RemovePred](const SectionBase &Sec) {
348-
return shouldReplace(Sec) || RemovePred(Sec);
347+
RemovePred = [ShouldReplace, RemovePred](const SectionBase &Sec) {
348+
return ShouldReplace(Sec) || RemovePred(Sec);
349349
};
350350

351351
return Error::success();
@@ -792,7 +792,7 @@ Error executeObjcopyOnIHex(const CopyConfig &Config, MemoryBuffer &In,
792792
return Obj.takeError();
793793

794794
const ElfType OutputElfType =
795-
getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
795+
getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
796796
if (Error E = handleArgs(Config, **Obj, Reader, OutputElfType))
797797
return E;
798798
return writeOutput(Config, **Obj, Out, OutputElfType);

llvm/tools/llvm-objcopy/ELF/Object.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ template <class ELFT> void ELFWriter<ELFT>::writePhdr(const Segment &Seg) {
5151
}
5252

5353
Error SectionBase::removeSectionReferences(
54-
bool AllowBrokenLinks,
55-
function_ref<bool(const SectionBase *)> ToRemove) {
54+
bool, function_ref<bool(const SectionBase *)>) {
5655
return Error::success();
5756
}
5857

59-
Error SectionBase::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) {
58+
Error SectionBase::removeSymbols(function_ref<bool(const Symbol &)>) {
6059
return Error::success();
6160
}
6261

@@ -751,8 +750,7 @@ void SymbolTableSection::addSymbol(Twine Name, uint8_t Bind, uint8_t Type,
751750
}
752751

753752
Error SymbolTableSection::removeSectionReferences(
754-
bool AllowBrokenLinks,
755-
function_ref<bool(const SectionBase *)> ToRemove) {
753+
bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) {
756754
if (ToRemove(SectionIndexTable))
757755
SectionIndexTable = nullptr;
758756
if (ToRemove(SymbolNames)) {
@@ -896,8 +894,7 @@ Error SymbolTableSection::accept(MutableSectionVisitor &Visitor) {
896894
}
897895

898896
Error RelocationSection::removeSectionReferences(
899-
bool AllowBrokenLinks,
900-
function_ref<bool(const SectionBase *)> ToRemove) {
897+
bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) {
901898
if (ToRemove(Symbols)) {
902899
if (!AllowBrokenLinks)
903900
return createStringError(
@@ -962,7 +959,7 @@ void RelocSectionWithSymtabBase<SymTabType>::finalize() {
962959
}
963960

964961
template <class ELFT>
965-
static void setAddend(Elf_Rel_Impl<ELFT, false> &Rel, uint64_t Addend) {}
962+
static void setAddend(Elf_Rel_Impl<ELFT, false> &, uint64_t) {}
966963

967964
template <class ELFT>
968965
static void setAddend(Elf_Rel_Impl<ELFT, true> &Rela, uint64_t Addend) {
@@ -1607,7 +1604,7 @@ Error ELFBuilder<ELFT>::initSymbolTable(SymbolTableSection *SymTab) {
16071604
}
16081605

16091606
template <class ELFT>
1610-
static void getAddend(uint64_t &ToSet, const Elf_Rel_Impl<ELFT, false> &Rel) {}
1607+
static void getAddend(uint64_t &, const Elf_Rel_Impl<ELFT, false> &) {}
16111608

16121609
template <class ELFT>
16131610
static void getAddend(uint64_t &ToSet, const Elf_Rel_Impl<ELFT, true> &Rela) {
@@ -2099,8 +2096,8 @@ ELFWriter<ELFT>::ELFWriter(Object &Obj, Buffer &Buf, bool WSH,
20992096
: Writer(Obj, Buf), WriteSectionHeaders(WSH && Obj.HadShdrs),
21002097
OnlyKeepDebug(OnlyKeepDebug) {}
21012098

2102-
Error Object::removeSections(bool AllowBrokenLinks,
2103-
std::function<bool(const SectionBase &)> ToRemove) {
2099+
Error Object::removeSections(
2100+
bool AllowBrokenLinks, std::function<bool(const SectionBase &)> ToRemove) {
21042101

21052102
auto Iter = std::stable_partition(
21062103
std::begin(Sections), std::end(Sections), [=](const SecPtr &Sec) {
@@ -2136,8 +2133,8 @@ Error Object::removeSections(bool AllowBrokenLinks,
21362133
// a live section critically depends on a section being removed somehow
21372134
// (e.g. the removed section is referenced by a relocation).
21382135
for (auto &KeepSec : make_range(std::begin(Sections), Iter)) {
2139-
if (Error E = KeepSec->removeSectionReferences(AllowBrokenLinks,
2140-
[&RemoveSections](const SectionBase *Sec) {
2136+
if (Error E = KeepSec->removeSectionReferences(
2137+
AllowBrokenLinks, [&RemoveSections](const SectionBase *Sec) {
21412138
return RemoveSections.find(Sec) != RemoveSections.end();
21422139
}))
21432140
return E;
@@ -2623,8 +2620,8 @@ Error IHexWriter::checkSection(const SectionBase &Sec) {
26232620
if (addressOverflows32bit(Addr) || addressOverflows32bit(Addr + Sec.Size - 1))
26242621
return createStringError(
26252622
errc::invalid_argument,
2626-
"Section '%s' address range [0x%llx, 0x%llx] is not 32 bit", Sec.Name.c_str(),
2627-
Addr, Addr + Sec.Size - 1);
2623+
"Section '%s' address range [0x%llx, 0x%llx] is not 32 bit",
2624+
Sec.Name.c_str(), Addr, Addr + Sec.Size - 1);
26282625
return Error::success();
26292626
}
26302627

llvm/tools/llvm-objcopy/ELF/Object.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ class Section : public SectionBase {
484484

485485
Error accept(SectionVisitor &Visitor) const override;
486486
Error accept(MutableSectionVisitor &Visitor) override;
487-
Error removeSectionReferences(bool AllowBrokenLinks,
487+
Error removeSectionReferences(
488+
bool AllowBrokenLinks,
488489
function_ref<bool(const SectionBase *)> ToRemove) override;
489490
Error initialize(SectionTableRef SecTable) override;
490491
void finalize() override;
@@ -647,13 +648,13 @@ class SectionIndexSection : public SectionBase {
647648
virtual ~SectionIndexSection() {}
648649
void addIndex(uint32_t Index) {
649650
assert(Size > 0);
650-
Indexes.push_back(Index);
651+
Indexes.push_back(Index);
651652
}
652653

653654
void reserve(size_t NumSymbols) {
654655
Indexes.reserve(NumSymbols);
655656
Size = NumSymbols * 4;
656-
}
657+
}
657658
void setSymTab(SymbolTableSection *SymTab) { Symbols = SymTab; }
658659
Error initialize(SectionTableRef SecTable) override;
659660
void finalize() override;
@@ -700,7 +701,8 @@ class SymbolTableSection : public SectionBase {
700701
Expected<Symbol *> getSymbolByIndex(uint32_t Index);
701702
void updateSymbols(function_ref<void(Symbol &)> Callable);
702703

703-
Error removeSectionReferences(bool AllowBrokenLinks,
704+
Error removeSectionReferences(
705+
bool AllowBrokenLinks,
704706
function_ref<bool(const SectionBase *)> ToRemove) override;
705707
Error initialize(SectionTableRef SecTable) override;
706708
void finalize() override;
@@ -770,7 +772,8 @@ class RelocationSection
770772
void addRelocation(Relocation Rel) { Relocations.push_back(Rel); }
771773
Error accept(SectionVisitor &Visitor) const override;
772774
Error accept(MutableSectionVisitor &Visitor) override;
773-
Error removeSectionReferences(bool AllowBrokenLinks,
775+
Error removeSectionReferences(
776+
bool AllowBrokenLinks,
774777
function_ref<bool(const SectionBase *)> ToRemove) override;
775778
Error removeSymbols(function_ref<bool(const Symbol &)> ToRemove) override;
776779
void markSymbols() override;

0 commit comments

Comments
 (0)