aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML
diff options
context:
space:
mode:
authorJakub Kuderski <kubak@google.com>2023-03-13 20:48:38 -0400
committerJakub Kuderski <kubak@google.com>2023-03-13 20:59:06 -0400
commitb9db89fbcfdaece8656159a2a0f0a2f09cdd7db7 (patch)
treeab4257cb385d47cdc2e547d2bf0dced7bb8bb738 /llvm/lib/ObjectYAML
parent7cc4e980e0f4032fd1bc4a736a9944c59aeff726 (diff)
downloadllvm-b9db89fbcfdaece8656159a2a0f0a2f09cdd7db7.tar.gz
llvm-b9db89fbcfdaece8656159a2a0f0a2f09cdd7db7.tar.bz2
llvm-b9db89fbcfdaece8656159a2a0f0a2f09cdd7db7.zip
[ADT][NFCI] Do not use non-const lvalue-refs with enumerate in llvm/
Replace references to `enumerate` results with either const lvalue rerences or structured bindings. I did not use structured bindings everywhere as it wasn't clear to me it would improve readability. This is in preparation to the switch to `zip` semantics which won't support non-const lvalue reference to elements: https://reviews.llvm.org/D144503. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D145987
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r--llvm/lib/ObjectYAML/DWARFYAML.cpp12
-rw-r--r--llvm/lib/ObjectYAML/MinidumpEmitter.cpp4
2 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index 37116ada9901..2bddeed46413 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -59,22 +59,20 @@ Expected<DWARFYAML::Data::AbbrevTableInfo>
DWARFYAML::Data::getAbbrevTableInfoByID(uint64_t ID) const {
if (AbbrevTableInfoMap.empty()) {
uint64_t AbbrevTableOffset = 0;
- for (auto &AbbrevTable : enumerate(DebugAbbrev)) {
+ for (const auto &[Index, AbbrevTable] : enumerate(DebugAbbrev)) {
// If the abbrev table's ID isn't specified, we use the index as its ID.
- uint64_t AbbrevTableID =
- AbbrevTable.value().ID.value_or(AbbrevTable.index());
+ uint64_t AbbrevTableID = AbbrevTable.ID.value_or(Index);
auto It = AbbrevTableInfoMap.insert(
- {AbbrevTableID, AbbrevTableInfo{/*Index=*/AbbrevTable.index(),
+ {AbbrevTableID, AbbrevTableInfo{/*Index=*/Index,
/*Offset=*/AbbrevTableOffset}});
if (!It.second)
return createStringError(
errc::invalid_argument,
"the ID (%" PRIu64 ") of abbrev table with index %zu has been used "
"by abbrev table with index %" PRIu64,
- AbbrevTableID, AbbrevTable.index(), It.first->second.Index);
+ AbbrevTableID, Index, It.first->second.Index);
- AbbrevTableOffset +=
- getAbbrevTableContentByIndex(AbbrevTable.index()).size();
+ AbbrevTableOffset += getAbbrevTableContentByIndex(Index).size();
}
}
diff --git a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
index 1bda6f364b1b..24b521a9925c 100644
--- a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
+++ b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
@@ -236,8 +236,8 @@ bool yaml2minidump(MinidumpYAML::Object &Obj, raw_ostream &Out,
Obj.Header.StreamDirectoryRVA = File.allocateArray(ArrayRef(StreamDirectory));
Obj.Header.NumberOfStreams = StreamDirectory.size();
- for (auto &Stream : enumerate(Obj.Streams))
- StreamDirectory[Stream.index()] = layout(File, *Stream.value());
+ for (const auto &[Index, Stream] : enumerate(Obj.Streams))
+ StreamDirectory[Index] = layout(File, *Stream);
File.writeTo(Out);
return true;