Convert the rest of the ocaml types and functions to use context.
[oota-llvm.git] / lib / Debugger / ProgramInfo.cpp
index 9d987ea4ad687ebb2c4159b812e14461ec02019a..6e584bdcc31195e5eee10609b7c1bf4c749aceb8 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -14,6 +14,7 @@
 
 #include "llvm/Debugger/ProgramInfo.h"
 #include "llvm/Constants.h"
+#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Intrinsics.h"
 #include "llvm/IntrinsicInst.h"
@@ -22,6 +23,7 @@
 #include "llvm/Debugger/SourceFile.h"
 #include "llvm/Debugger/SourceLanguage.h"
 #include "llvm/Support/SlowOperationInformer.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/ADT/STLExtras.h"
 using namespace llvm;
 
@@ -115,8 +117,10 @@ SourceFileInfo::SourceFileInfo(const GlobalVariable *Desc,
         if (ConstantInt *CUI = dyn_cast<ConstantInt>(CS->getOperand(1)))
           Version = CUI->getZExtValue();
 
-        BaseName  = CS->getOperand(3)->getStringValue();
-        Directory = CS->getOperand(4)->getStringValue();
+        if (!GetConstantStringInfo(CS->getOperand(3), BaseName))
+          BaseName = "";
+        if (!GetConstantStringInfo(CS->getOperand(4), Directory))
+          Directory = "";
       }
 }
 
@@ -156,7 +160,8 @@ SourceFunctionInfo::SourceFunctionInfo(ProgramInfo &PI,
           SourceFile = &PI.getSourceFile(GV);
 
         // Entry #2 is the function name.
-        Name = CS->getOperand(2)->getStringValue();
+        if (!GetConstantStringInfo(CS->getOperand(2), Name))
+          Name = "";
       }
 }
 
@@ -266,8 +271,8 @@ ProgramInfo::getSourceFiles(bool RequiresCompleteMap) {
   // should be on the use list of the llvm.dbg.translation_units global.
   //
   GlobalVariable *Units =
-    M->getGlobalVariable("llvm.dbg.translation_units",
-                         StructType::get(std::vector<const Type*>()));
+    M->getGlobalVariable("llvm.dbg.translation_units", 
+                         StructType::get(M->getContext()));
   if (Units == 0)
     throw "Program contains no debugging information!";
 
@@ -349,8 +354,7 @@ ProgramInfo::getSourceFunctions(bool RequiresCompleteMap) {
   // should be on the use list of the llvm.dbg.translation_units global.
   //
   GlobalVariable *Units =
-    M->getGlobalVariable("llvm.dbg.globals",
-                         StructType::get(std::vector<const Type*>()));
+    M->getGlobalVariable("llvm.dbg.globals", StructType::get(M->getContext()));
   if (Units == 0)
     throw "Program contains no debugging information!";