aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-04-18 17:44:15 +0000
committerTed Kremenek <kremenek@apple.com>2013-04-18 17:44:15 +0000
commit62fba4f08af16ff17b5cbe8816061349504317e4 (patch)
treedd84e2fae0ccd99bb25679e9ec8e79de362817b6 /lib/StaticAnalyzer/Core
parent688f2a1fc1ac38e8b7b602ab8afc69cdfa7492bf (diff)
[analyzer] Refine 'nil receiver' diagnostics to mention the name of the method not called.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporterVisitors.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 11fb1fcebd..8f78757ee7 100644
--- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1046,10 +1046,22 @@ PathDiagnosticPiece *NilReceiverBRVisitor::VisitNode(const ExplodedNode *N,
if (!P)
return 0;
- const Expr *Receiver = getNilReceiver(P->getStmt(), N);
+ const Stmt *S = P->getStmt();
+ const Expr *Receiver = getNilReceiver(S, N);
if (!Receiver)
return 0;
+ llvm::SmallString<256> Buf;
+ llvm::raw_svector_ostream OS(Buf);
+
+ if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S)) {
+ OS << "'" << ME->getSelector().getAsString() << "' not called";
+ }
+ else {
+ OS << "No method is called";
+ }
+ OS << " because the receiver is nil";
+
// The receiver was nil, and hence the method was skipped.
// Register a BugReporterVisitor to issue a message telling us how
// the receiver was null.
@@ -1058,8 +1070,7 @@ PathDiagnosticPiece *NilReceiverBRVisitor::VisitNode(const ExplodedNode *N,
// Issue a message saying that the method was skipped.
PathDiagnosticLocation L(Receiver, BRC.getSourceManager(),
N->getLocationContext());
- return new PathDiagnosticEventPiece(L, "No method is called "
- "because the receiver is nil");
+ return new PathDiagnosticEventPiece(L, OS.str());
}
// Registers every VarDecl inside a Stmt with a last store visitor.