Skip to content

Commit 75c86c9

Browse files
committed
Support: Make VarStreamArrayIterator iterate over const values
VarStreamArrayIterator returns a reference to a just-computed internal value. Change it to iterate over `const ValueType` to avoid allowing clients to mutate the internal state, and to drop the non-`const`-qualified operator*(). The removed operator*() was from 175d70e to get iterator_facade_base::operator->() working, and this fixes the root cause instead: setting `T` to `const ValueType` causes iterator_facade_base to infer `PointerT` as `const ValueType*`. Ironically, this is the last blocker for removing the const-incorrect overload of `iterator_facade_base::operator->()`, whose presence triggered adding the workaround in the first place :). Differential Revision: https://reviews.llvm.org/D113797
1 parent 3129b33 commit 75c86c9

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

llvm/include/llvm/Support/BinaryStreamArray.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class VarStreamArray {
153153
template <typename ValueType, typename Extractor>
154154
class VarStreamArrayIterator
155155
: public iterator_facade_base<VarStreamArrayIterator<ValueType, Extractor>,
156-
std::forward_iterator_tag, ValueType> {
156+
std::forward_iterator_tag, const ValueType> {
157157
typedef VarStreamArrayIterator<ValueType, Extractor> IterType;
158158
typedef VarStreamArray<ValueType, Extractor> ArrayType;
159159

@@ -197,11 +197,6 @@ class VarStreamArrayIterator
197197
return ThisValue;
198198
}
199199

200-
ValueType &operator*() {
201-
assert(Array && !HasError);
202-
return ThisValue;
203-
}
204-
205200
IterType &operator+=(unsigned N) {
206201
for (unsigned I = 0; I < N; ++I) {
207202
// We are done with the current record, discard it so that we are

llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static void explainDbiModiSubstreamOffset(LinePrinter &P, DbiStream &Dbi,
373373
++Index;
374374
}
375375

376-
DbiModuleDescriptor &Descriptor = *Prev;
376+
const DbiModuleDescriptor &Descriptor = *Prev;
377377
P.formatLine("which contains the descriptor for module {0} ({1}).", Index,
378378
Descriptor.getModuleName());
379379
}

0 commit comments

Comments
 (0)