Index: src/PNaClTranslator.cpp |
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp |
index d8d1860f1ef760bf1ac5bda1b21f5cb964562d9e..d3c71fd4091cb737d4bbe45f4347fac86b0cfba6 100644 |
--- a/src/PNaClTranslator.cpp |
+++ b/src/PNaClTranslator.cpp |
@@ -1283,16 +1283,14 @@ public: |
if (Index < CachedNumGlobalValueIDs) { |
return Context->getGlobalConstantByID(Index); |
} |
+ if (isIRGenerationDisabled()) |
+ return nullptr; |
NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs; |
+ if (LocalIndex >= LocalOperands.size()) |
+ reportGetOperandUndefined(Index); |
Ice::Operand *Op = LocalOperands[LocalIndex]; |
- if (Op == nullptr) { |
- if (isIRGenerationDisabled()) |
- return nullptr; |
- std::string Buffer; |
- raw_string_ostream StrBuf(Buffer); |
- StrBuf << "Value index " << Index << " not defined!"; |
- Fatal(StrBuf.str()); |
- } |
+ if (Op == nullptr) |
+ reportGetOperandUndefined(Index); |
return Op; |
} |
@@ -1981,6 +1979,13 @@ private: |
Ice::Variable *Var = getNextInstVar(Ty); |
CurrentNode->appendInst(Ice::InstAssign::create(Func.get(), Var, Var)); |
} |
+ |
+ Ice::Operand *reportGetOperandUndefined(NaClBcIndexSize_t Index) { |
+ std::string Buffer; |
+ raw_string_ostream StrBuf(Buffer); |
+ StrBuf << "Value index " << Index << " not defined!"; |
+ Fatal(StrBuf.str()); |
+ } |
}; |
void FunctionParser::ExitBlock() { |