[analyzer] Replace calls to getNameAsString() with StringRef equivalents.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138215 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
index d369518..66787f7 100644
--- a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -103,26 +103,25 @@
     if (!reachableCode->isReachable(currentBlock))
       return;
 
-    const std::string &name = V->getNameAsString();
-
-    const char* BugType = 0;
-    std::string msg;
+    llvm::SmallString<64> buf;
+    llvm::raw_svector_ostream os(buf);
+    const char *BugType = 0;
 
     switch (dsk) {
       default:
-        assert(false && "Impossible dead store type.");
+        llvm_unreachable("Impossible dead store type.");
 
       case DeadInit:
         BugType = "Dead initialization";
-        msg = "Value stored to '" + name +
-          "' during its initialization is never read";
+        os << "Value stored to '" << V
+           << "' during its initialization is never read";
         break;
 
       case DeadIncrement:
         BugType = "Dead increment";
       case Standard:
         if (!BugType) BugType = "Dead assignment";
-        msg = "Value stored to '" + name + "' is never read";
+        os << "Value stored to '" << V << "' is never read";
         break;
 
       case Enclosing:
@@ -132,7 +131,7 @@
         return;
     }
 
-    BR.EmitBasicReport(BugType, "Dead store", msg, L, R);
+    BR.EmitBasicReport(BugType, "Dead store", os.str(), L, R);
   }
 
   void CheckVarDecl(const VarDecl *VD, const Expr *Ex, const Expr *Val,
diff --git a/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp b/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index dc5fe08..b004aa9 100644
--- a/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -202,7 +202,7 @@
                                 Eng.getContext().getSourceManager());
     os << " is still referred to by the global variable '";
     const VarRegion *VR = cast<VarRegion>(cb.V[i].first->getBaseRegion());
-    os << VR->getDecl()->getNameAsString() 
+    os << VR->getDecl()
        << "' upon returning to the caller.  This will be a dangling reference";
     BugReport *report = new BugReport(*BT_stackleak, os.str(), N);
     if (range.isValid())