Oops...I committed too much.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66867 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 9014557..d9f0aa5 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -35,16 +35,24 @@
     GV = 0;
 }
 
-const char *DIDescriptor::getStringField(unsigned Elt) const {
-  if (GV == 0)
-    return 0;
+const std::string &
+DIDescriptor::getStringField(unsigned Elt, std::string &Result) const {
+  if (GV == 0) {
+    Result.clear();
+    return Result;
+  }
 
   Constant *C = GV->getInitializer();
-  if (C == 0 || Elt >= C->getNumOperands())
-    return 0;
+  if (C == 0 || Elt >= C->getNumOperands()) {
+    Result.clear();
+    return Result;
+  }
   
   // Fills in the string if it succeeds
-  return GetConstantStringInfo(C->getOperand(Elt));
+  if (!GetConstantStringInfo(C->getOperand(Elt), Result))
+    Result.clear();
+
+  return Result;
 }
 
 uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const {
@@ -182,9 +190,11 @@
 bool DICompileUnit::Verify() const {
   if (isNull()) 
     return false;
-
+  std::string Res;
+  if (getFilename(Res).empty()) 
+    return false;
   // It is possible that directory and produce string is empty.
-  return getFilename();
+  return true;
 }
 
 /// Verify - Verify that a type descriptor is well formed.
@@ -495,7 +505,7 @@
 
 /// CreateBasicType - Create a basic type like int, float, etc.
 DIBasicType DIFactory::CreateBasicType(DIDescriptor Context,
-                                       const std::string &Name,
+                                      const std::string &Name,
                                        DICompileUnit CompileUnit,
                                        unsigned LineNumber,
                                        uint64_t SizeInBits,
@@ -884,7 +894,8 @@
   }
 
   bool getLocationInfo(const Value *V, std::string &DisplayName, std::string &Type,
-                       unsigned &LineNo, std::string &File, std::string &Dir) {
+                       unsigned &LineNo, std::string &File, std::string &Dir)
+  {
     DICompileUnit Unit;
     DIType TypeD;
     if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
@@ -892,11 +903,7 @@
       if (!DIGV)
         return false;
       DIGlobalVariable Var(cast<GlobalVariable>(DIGV));
-      const char *DN = Var.getDisplayName();
-      if (DN)
-        DisplayName = DN;
-      else
-        DisplayName.clear();
+      Var.getDisplayName(DisplayName);
       LineNo = Var.getLineNumber();
       Unit = Var.getCompileUnit();
       TypeD = Var.getType();
@@ -905,24 +912,14 @@
       if (!DDI)
         return false;
       DIVariable Var(cast<GlobalVariable>(DDI->getVariable()));
-      const char *DN = Var.getName();
-      if (DN)
-        DisplayName = DN;
-      else
-        DisplayName.clear();
+      Var.getName(DisplayName);
       LineNo = Var.getLineNumber();
       Unit = Var.getCompileUnit();
       TypeD = Var.getType();
     }
-    Type.clear();
-    File.clear();
-    Dir.clear();
-    const char *Str = TypeD.getName();
-    if (Str) Type = Str;
-    Str = Unit.getFilename();
-    if (Str) File = Str;
-    Str = Unit.getDirectory();
-    if (Str) Dir = Str;
+    TypeD.getName(Type);
+    Unit.getFilename(File);
+    Unit.getDirectory(Dir);
     return true;
   }
 }
@@ -932,17 +929,17 @@
   if (getLanguage())
     cerr << " [" << dwarf::LanguageString(getLanguage()) << "] ";
 
-  const char *Dir = getDirectory();
-  const char *FN = getFilename();
-  cerr << " [" << (Dir ? Dir : "") << "/" << (FN ? FN : "") << " ]";
+  std::string Res1, Res2;
+  cerr << " [" << getDirectory(Res1) << "/" << getFilename(Res2) << " ]";
 }
 
 /// dump - print type.
 void DIType::dump() const {
   if (isNull()) return;
 
-  if (const char *N = getName())
-    cerr << " [" << N << "] ";
+  std::string Res;
+  if (!getName(Res).empty())
+    cerr << " [" << Res << "] ";
 
   unsigned Tag = getTag();
   cerr << " [" << dwarf::TagString(Tag) << "] ";
@@ -999,8 +996,9 @@
 
 /// dump - print global.
 void DIGlobal::dump() const {
-  if (const char *N = getName())
-    cerr << " [" << N << "] ";
+  std::string Res;
+  if (!getName(Res).empty())
+    cerr << " [" << Res << "] ";
 
   unsigned Tag = getTag();
   cerr << " [" << dwarf::TagString(Tag) << "] ";
@@ -1033,8 +1031,9 @@
 
 /// dump - print variable.
 void DIVariable::dump() const {
-  if (const char *N = getName())
-    cerr << " [" << N << "] ";
+  std::string Res;
+  if (!getName(Res).empty())
+    cerr << " [" << Res << "] ";
 
   getCompileUnit().dump();
   cerr << " [" << getLineNumber() << "] ";