summaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-12-25 22:30:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-12-25 22:30:44 +0000
commit77fc4c146f0870ffb09c1afb823ccbe742c5e6ff (patch)
tree5c0eb39553003b9c75a901af6bc4ddabd6f2f28c /llvm/lib/ObjectYAML
parentf65dcba83ce5035ab88a85fe17628b447eb56e1b (diff)
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r--llvm/lib/ObjectYAML/COFFEmitter.cpp12
-rw-r--r--llvm/lib/ObjectYAML/ELFYAML.cpp48
-rw-r--r--llvm/lib/ObjectYAML/XCOFFEmitter.cpp10
-rw-r--r--llvm/lib/ObjectYAML/YAML.cpp5
4 files changed, 34 insertions, 41 deletions
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 66ad16db1ba4..d884e2fd55cd 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -64,11 +64,7 @@ struct COFFParser {
}
bool parseSections() {
- for (std::vector<COFFYAML::Section>::iterator i = Obj.Sections.begin(),
- e = Obj.Sections.end();
- i != e; ++i) {
- COFFYAML::Section &Sec = *i;
-
+ for (COFFYAML::Section &Sec : Obj.Sections) {
// If the name is less than 8 bytes, store it in place, otherwise
// store it in the string table.
StringRef Name = Sec.Name;
@@ -103,11 +99,7 @@ struct COFFParser {
}
bool parseSymbols() {
- for (std::vector<COFFYAML::Symbol>::iterator i = Obj.Symbols.begin(),
- e = Obj.Symbols.end();
- i != e; ++i) {
- COFFYAML::Symbol &Sym = *i;
-
+ for (COFFYAML::Symbol &Sym : Obj.Symbols) {
// If the name is less than 8 bytes, store it in place, otherwise
// store it in the string table.
StringRef Name = Sym.Name;
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index e0dde4433d24..9b9266998ea6 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -464,29 +464,31 @@ void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
BCaseMask(EF_MIPS_ARCH_64R6, EF_MIPS_ARCH);
break;
case ELF::EM_HEXAGON:
- BCase(EF_HEXAGON_MACH_V2);
- BCase(EF_HEXAGON_MACH_V3);
- BCase(EF_HEXAGON_MACH_V4);
- BCase(EF_HEXAGON_MACH_V5);
- BCase(EF_HEXAGON_MACH_V55);
- BCase(EF_HEXAGON_MACH_V60);
- BCase(EF_HEXAGON_MACH_V62);
- BCase(EF_HEXAGON_MACH_V65);
- BCase(EF_HEXAGON_MACH_V66);
- BCase(EF_HEXAGON_MACH_V67);
- BCase(EF_HEXAGON_MACH_V67T);
- BCase(EF_HEXAGON_MACH_V68);
- BCase(EF_HEXAGON_ISA_V2);
- BCase(EF_HEXAGON_ISA_V3);
- BCase(EF_HEXAGON_ISA_V4);
- BCase(EF_HEXAGON_ISA_V5);
- BCase(EF_HEXAGON_ISA_V55);
- BCase(EF_HEXAGON_ISA_V60);
- BCase(EF_HEXAGON_ISA_V62);
- BCase(EF_HEXAGON_ISA_V65);
- BCase(EF_HEXAGON_ISA_V66);
- BCase(EF_HEXAGON_ISA_V67);
- BCase(EF_HEXAGON_ISA_V68);
+ BCaseMask(EF_HEXAGON_MACH_V2, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V3, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V4, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V5, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V55, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V60, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V62, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V65, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V66, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V67, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V67T, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V68, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_MACH_V69, EF_HEXAGON_MACH);
+ BCaseMask(EF_HEXAGON_ISA_V2, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V3, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V4, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V5, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V55, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V60, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V62, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V65, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V66, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V67, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V68, EF_HEXAGON_ISA);
+ BCaseMask(EF_HEXAGON_ISA_V69, EF_HEXAGON_ISA);
break;
case ELF::EM_AVR:
BCaseMask(EF_AVR_ARCH_AVR1, EF_AVR_ARCH_MASK);
diff --git a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
index 85d1f82bfafc..cf0d058c518c 100644
--- a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
@@ -86,13 +86,13 @@ bool XCOFFWriter::nameShouldBeInStringTable(StringRef SymbolName) {
}
bool XCOFFWriter::initRelocations(uint64_t &CurrentOffset) {
- for (uint16_t I = 0, E = InitSections.size(); I < E; ++I) {
- if (!InitSections[I].Relocations.empty()) {
- InitSections[I].NumberOfRelocations = InitSections[I].Relocations.size();
- InitSections[I].FileOffsetToRelocations = CurrentOffset;
+ for (XCOFFYAML::Section &InitSection : InitSections) {
+ if (!InitSection.Relocations.empty()) {
+ InitSection.NumberOfRelocations = InitSection.Relocations.size();
+ InitSection.FileOffsetToRelocations = CurrentOffset;
uint64_t RelSize = Is64Bit ? XCOFF::RelocationSerializationSize64
: XCOFF::RelocationSerializationSize32;
- CurrentOffset += InitSections[I].NumberOfRelocations * RelSize;
+ CurrentOffset += InitSection.NumberOfRelocations * RelSize;
if (CurrentOffset > MaxRawDataSize) {
ErrHandler("maximum object size of" + Twine(MaxRawDataSize) +
"exceeded when writing relocation data");
diff --git a/llvm/lib/ObjectYAML/YAML.cpp b/llvm/lib/ObjectYAML/YAML.cpp
index 5dcb113d3395..54e8c627d5a1 100644
--- a/llvm/lib/ObjectYAML/YAML.cpp
+++ b/llvm/lib/ObjectYAML/YAML.cpp
@@ -30,9 +30,8 @@ StringRef yaml::ScalarTraits<yaml::BinaryRef>::input(StringRef Scalar, void *,
return "BinaryRef hex string must contain an even number of nybbles.";
// TODO: Can we improve YAMLIO to permit a more accurate diagnostic here?
// (e.g. a caret pointing to the offending character).
- for (unsigned I = 0, N = Scalar.size(); I != N; ++I)
- if (!llvm::isHexDigit(Scalar[I]))
- return "BinaryRef hex string must contain only hex digits.";
+ if (!llvm::all_of(Scalar, llvm::isHexDigit))
+ return "BinaryRef hex string must contain only hex digits.";
Val = yaml::BinaryRef(Scalar);
return {};
}