getFilename/getDirectory shouldn't abort if the global has no init. This

can happen on bugpoint reduced testcases f.e..


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30729 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-10-04 23:06:26 +00:00
parent 693163e74d
commit df20b96ffd

View File

@ -26,11 +26,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/IntrinsicInst.h"
#include "llvm/Constants.h"
#include "llvm/GlobalVariable.h"
#include "llvm/CodeGen/MachineDebugInfo.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@ -63,6 +61,7 @@ std::string DbgStopPointInst::getFileName() const {
// Once the operand indices are verified, update this assert
assert(LLVMDebugVersion == (5 << 16) && "Verify operand indices");
GlobalVariable *GV = cast<GlobalVariable>(getContext());
if (!GV->hasInitializer()) return "";
ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer());
return CS->getOperand(3)->getStringValue();
}
@ -71,6 +70,7 @@ std::string DbgStopPointInst::getDirectory() const {
// Once the operand indices are verified, update this assert
assert(LLVMDebugVersion == (5 << 16) && "Verify operand indices");
GlobalVariable *GV = cast<GlobalVariable>(getContext());
if (!GV->hasInitializer()) return "";
ConstantStruct *CS = cast<ConstantStruct>(GV->getInitializer());
return CS->getOperand(4)->getStringValue();
}