forked from OSchip/llvm-project
[analyzer] Replace calls to getNameAsString() with StringRef equivalents.
llvm-svn: 138215
This commit is contained in:
parent
3cca223a2a
commit
82c673de33
|
@ -103,26 +103,25 @@ public:
|
||||||
if (!reachableCode->isReachable(currentBlock))
|
if (!reachableCode->isReachable(currentBlock))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::string &name = V->getNameAsString();
|
llvm::SmallString<64> buf;
|
||||||
|
llvm::raw_svector_ostream os(buf);
|
||||||
const char* BugType = 0;
|
const char *BugType = 0;
|
||||||
std::string msg;
|
|
||||||
|
|
||||||
switch (dsk) {
|
switch (dsk) {
|
||||||
default:
|
default:
|
||||||
assert(false && "Impossible dead store type.");
|
llvm_unreachable("Impossible dead store type.");
|
||||||
|
|
||||||
case DeadInit:
|
case DeadInit:
|
||||||
BugType = "Dead initialization";
|
BugType = "Dead initialization";
|
||||||
msg = "Value stored to '" + name +
|
os << "Value stored to '" << V
|
||||||
"' during its initialization is never read";
|
<< "' during its initialization is never read";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DeadIncrement:
|
case DeadIncrement:
|
||||||
BugType = "Dead increment";
|
BugType = "Dead increment";
|
||||||
case Standard:
|
case Standard:
|
||||||
if (!BugType) BugType = "Dead assignment";
|
if (!BugType) BugType = "Dead assignment";
|
||||||
msg = "Value stored to '" + name + "' is never read";
|
os << "Value stored to '" << V << "' is never read";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Enclosing:
|
case Enclosing:
|
||||||
|
@ -132,7 +131,7 @@ public:
|
||||||
return;
|
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,
|
void CheckVarDecl(const VarDecl *VD, const Expr *Ex, const Expr *Val,
|
||||||
|
|
|
@ -202,7 +202,7 @@ void StackAddrEscapeChecker::checkEndPath(EndOfFunctionNodeBuilder &B,
|
||||||
Eng.getContext().getSourceManager());
|
Eng.getContext().getSourceManager());
|
||||||
os << " is still referred to by the global variable '";
|
os << " is still referred to by the global variable '";
|
||||||
const VarRegion *VR = cast<VarRegion>(cb.V[i].first->getBaseRegion());
|
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";
|
<< "' upon returning to the caller. This will be a dangling reference";
|
||||||
BugReport *report = new BugReport(*BT_stackleak, os.str(), N);
|
BugReport *report = new BugReport(*BT_stackleak, os.str(), N);
|
||||||
if (range.isValid())
|
if (range.isValid())
|
||||||
|
|
|
@ -438,10 +438,11 @@ public:
|
||||||
FullSourceLoc L(S->getLocStart(), BR.getSourceManager());
|
FullSourceLoc L(S->getLocStart(), BR.getSourceManager());
|
||||||
|
|
||||||
if (Loc::isLocType(VD->getType())) {
|
if (Loc::isLocType(VD->getType())) {
|
||||||
std::string msg = "'" + std::string(VD->getNameAsString()) +
|
llvm::SmallString<64> buf;
|
||||||
"' now aliases '" + MostRecent->getNameAsString() + "'";
|
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;
|
return true;
|
||||||
|
|
|
@ -2189,13 +2189,12 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
|
||||||
const Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
|
const Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
|
||||||
SVal X = CurrSt->getSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee());
|
SVal X = CurrSt->getSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee());
|
||||||
const FunctionDecl *FD = X.getAsFunctionDecl();
|
const FunctionDecl *FD = X.getAsFunctionDecl();
|
||||||
const std::string& FName = FD->getNameAsString();
|
|
||||||
|
|
||||||
if (TF.isGCEnabled()) {
|
if (TF.isGCEnabled()) {
|
||||||
// Determine if the object's reference count was pushed to zero.
|
// Determine if the object's reference count was pushed to zero.
|
||||||
assert(!(PrevV == CurrV) && "The typestate *must* have changed.");
|
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 "
|
<< "' decrements an object's retain count and registers the "
|
||||||
"object with the garbage collector. ";
|
"object with the garbage collector. ";
|
||||||
|
|
||||||
|
@ -2210,7 +2209,7 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
|
||||||
<< '.';
|
<< '.';
|
||||||
}
|
}
|
||||||
else
|
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.";
|
<< "' has no effect on its argument.";
|
||||||
|
|
||||||
// Nothing more to say.
|
// Nothing more to say.
|
||||||
|
|
Loading…
Reference in New Issue