From c9456ca64c102516744deb4ba9b0790aea6b5c0a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 9 Oct 2003 20:41:16 +0000 Subject: Change getConstantValue to throw an exception on error, not return null git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8988 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/Reader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Bytecode/Reader/Reader.cpp') diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index c515c1575c..bf2b0118a3 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -164,7 +164,10 @@ BasicBlock *BytecodeParser::getBasicBlock(unsigned ID) { /// Constant *BytecodeParser::getConstantValue(const Type *Ty, unsigned Slot) { if (Value *V = getValue(Ty, Slot, false)) - return dyn_cast(V); // If we already have the value parsed... + if (Constant *C = dyn_cast(V)) + return C; // If we already have the value parsed, just return it + else + throw std::string("Reference of a value is expected to be a constant!"); std::pair Key(Ty, Slot); GlobalRefsType::iterator I = GlobalRefs.lower_bound(Key); -- cgit v1.2.3