aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-06-26 16:54:09 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-06-26 16:54:09 -0700
commit359669b6c4987eda3a7a177c67c906af56f8bb73 (patch)
tree30547ddc41329a14ddd93a6207273e86772b6028 /lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h
parentdc80ae361ec894a266815c078d92c78233acf542 (diff)
PNaCl pexe reader: Remove now-unused Type argument from getValue()/popValue()
Before this change, NaClBitcodeReader had some icky use of C++ function overloading and reference types. Whether getValue() modified its Slot argument depended on whether it was passed a Type argument, which wasn't very readable: // Modifies Slot. bool getValue(SmallVector<uint64_t, 64> &Record, unsigned &Slot, unsigned InstNum, Value *&ResVal); // Does not modify Slot. bool getValue(SmallVector<uint64_t, 64> &Record, unsigned Slot, unsigned InstNum, Type *Ty, Value *&ResVal); // Does not modify Slot. Value *getValue(SmallVector<uint64_t, 64> &Record, unsigned Slot, unsigned InstNum, Type *Ty); So, do these cleanups: * Convert non-const reference arguments to pointers. (Also add "const" to the Record argument.) * Remove the unused Type argument from getValue()/popValue(). * Remove the getValue() case that was identical to popValue(). Call popValue() instead. Now popValue() modifies *Slot and getValue() does not. * Remove an unused getValue() case. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17938002
Diffstat (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h')
-rw-r--r--lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h45
1 files changed, 12 insertions, 33 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h
index cacd971286..9320de92ea 100644
--- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h
@@ -219,44 +219,24 @@ private:
return FunctionBBs[ID];
}
- /// \brief Read a value out of the specified record from slot 'Slot'.
- /// Increment Slot past the number of slots used by the value in the record.
+ /// \brief Read a value out of the specified record from slot '*Slot'.
+ /// Increment *Slot past the number of slots used by the value in the record.
/// Return true if there is an error.
- bool getValue(SmallVector<uint64_t, 64> &Record, unsigned &Slot,
- unsigned InstNum, Value *&ResVal) {
- if (Slot == Record.size()) return true;
- unsigned ValNo = (unsigned)Record[Slot++];
+ bool popValue(const SmallVector<uint64_t, 64> &Record, unsigned *Slot,
+ unsigned InstNum, Value **ResVal) {
+ if (*Slot == Record.size()) return true;
+ unsigned ValNo = (unsigned)Record[(*Slot)++];
// Adjust the ValNo, if it was encoded relative to the InstNum.
if (UseRelativeIDs)
ValNo = InstNum - ValNo;
- ResVal = getFnValueByID(ValNo);
- return ResVal == 0;
- }
-
- /// popValue - Read a value out of the specified record from slot 'Slot'.
- /// Increment Slot past the number of slots used by the value in the record.
- /// Return true if there is an error.
- bool popValue(SmallVector<uint64_t, 64> &Record, unsigned &Slot,
- unsigned InstNum, Type *Ty, Value *&ResVal) {
- if (getValue(Record, Slot, InstNum, Ty, ResVal))
- return true;
- // All values currently take a single record slot.
- ++Slot;
- return false;
- }
-
- /// getValue -- Like popValue, but does not increment the Slot number.
- bool getValue(SmallVector<uint64_t, 64> &Record, unsigned Slot,
- unsigned InstNum, Type *Ty, Value *&ResVal) {
- ResVal = getValue(Record, Slot, InstNum, Ty);
- return ResVal == 0;
+ *ResVal = getFnValueByID(ValNo);
+ return *ResVal == 0;
}
/// getValue -- Version of getValue that returns ResVal directly,
/// or 0 if there is an error.
- /// TODO(mseaborn): Remove the unused Type argument from this function.
- Value *getValue(SmallVector<uint64_t, 64> &Record, unsigned Slot,
- unsigned InstNum, Type *Ty) {
+ Value *getValue(const SmallVector<uint64_t, 64> &Record, unsigned Slot,
+ unsigned InstNum) {
if (Slot == Record.size()) return 0;
unsigned ValNo = (unsigned)Record[Slot];
// Adjust the ValNo, if it was encoded relative to the InstNum.
@@ -266,9 +246,8 @@ private:
}
/// getValueSigned -- Like getValue, but decodes signed VBRs.
- /// TODO(mseaborn): Remove the unused Type argument from this function.
- Value *getValueSigned(SmallVector<uint64_t, 64> &Record, unsigned Slot,
- unsigned InstNum, Type *Ty) {
+ Value *getValueSigned(const SmallVector<uint64_t, 64> &Record, unsigned Slot,
+ unsigned InstNum) {
if (Slot == Record.size()) return 0;
unsigned ValNo = (unsigned) NaClDecodeSignRotatedValue(Record[Slot]);
// Adjust the ValNo, if it was encoded relative to the InstNum.