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

llvm-svn: 138215
This commit is contained in:
Jordy Rose 2011-08-21 05:25:15 +00:00
parent 3cca223a2a
commit 82c673de33
4 changed files with 15 additions and 16 deletions

View File

@ -103,26 +103,25 @@ public:
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 @@ public:
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,

View File

@ -202,7 +202,7 @@ void StackAddrEscapeChecker::checkEndPath(EndOfFunctionNodeBuilder &B,
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())

View File

@ -438,10 +438,11 @@ public:
FullSourceLoc L(S->getLocStart(), BR.getSourceManager());
if (Loc::isLocType(VD->getType())) {
std::string msg = "'" + std::string(VD->getNameAsString()) +
"' now aliases '" + MostRecent->getNameAsString() + "'";
llvm::SmallString<64> buf;
llvm::raw_svector_ostream os(buf);
os << '\'' << VD << "' now aliases '" << MostRecent << '\'';
PD.push_front(new PathDiagnosticEventPiece(L, msg));
PD.push_front(new PathDiagnosticEventPiece(L, os.str()));
}
return true;

View File

@ -2189,13 +2189,12 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
const Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
SVal X = CurrSt->getSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee());
const FunctionDecl *FD = X.getAsFunctionDecl();
const std::string& FName = FD->getNameAsString();
if (TF.isGCEnabled()) {
// Determine if the object's reference count was pushed to zero.
assert(!(PrevV == CurrV) && "The typestate *must* have changed.");
os << "In GC mode a call to '" << FName
os << "In GC mode a call to '" << FD
<< "' decrements an object's retain count and registers the "
"object with the garbage collector. ";
@ -2210,7 +2209,7 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
<< '.';
}
else
os << "When GC is not enabled a call to '" << FName
os << "When GC is not enabled a call to '" << FD
<< "' has no effect on its argument.";
// Nothing more to say.