[llvm] r271419 - [CodeView] Simplify StreamArray operator++
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 11:13:08 PDT 2016
Author: majnemer
Date: Wed Jun 1 13:13:08 2016
New Revision: 271419
URL: http://llvm.org/viewvc/llvm-project?rev=271419&view=rev
Log:
[CodeView] Simplify StreamArray operator++
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h?rev=271419&r1=271418&r2=271419&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h Wed Jun 1 13:13:08 2016
@@ -77,10 +77,7 @@ public:
auto EC = Extract(IterRef, ThisLen, ThisValue);
if (EC) {
consumeError(std::move(EC));
- this->Array = nullptr;
- HasError = true;
- if (HadError)
- *HadError = true;
+ markError();
}
}
VarStreamArrayIterator() : Array(nullptr), IterRef(), HasError(false) {}
@@ -109,24 +106,24 @@ public:
}
IterType &operator++() {
- if (!Array || IterRef.getLength() == 0 || ThisLen == 0 || HasError)
- return *this;
+ // We are done with the current record, discard it so that we are
+ // positioned at the next record.
IterRef = IterRef.drop_front(ThisLen);
- if (IterRef.getLength() == 0)
- ThisLen = 0;
- else {
+ if (IterRef.getLength() == 0) {
+ // There is nothing after the current record, we must make this an end
+ // iterator.
+ moveToEnd();
+ } else {
+ // There is some data after the current record.
auto EC = Extract(IterRef, ThisLen, ThisValue);
if (EC) {
consumeError(std::move(EC));
- HasError = true;
- if (HadError)
- *HadError = true;
+ markError();
+ } else if (ThisLen == 0) {
+ // An empty record? Make this an end iterator.
+ moveToEnd();
}
}
- if (ThisLen == 0 || HasError) {
- Array = nullptr;
- ThisLen = 0;
- }
return *this;
}
@@ -137,6 +134,17 @@ public:
}
private:
+ void moveToEnd() {
+ Array = nullptr;
+ ThisLen = 0;
+ }
+ void markError() {
+ moveToEnd();
+ HasError = true;
+ if (HadError != nullptr)
+ *HadError = true;
+ }
+
const ArrayType *Array;
uint32_t ThisLen;
ValueType ThisValue;
More information about the llvm-commits
mailing list