getFilename/getDirectory shouldn't abort if the global has no init. This
authorChris Lattner <sabre@nondot.org>
Wed, 4 Oct 2006 23:06:26 +0000 (23:06 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 4 Oct 2006 23:06:26 +0000 (23:06 +0000)
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

lib/VMCore/IntrinsicInst.cpp

index a85d9a4b223fc65c87997780fe2ad92117544523..5c43b6f5e1d9a724343159e9edfe39f5f1f59f88 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #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();
 }