aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-03 18:46:16 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-03 18:46:16 +0000
commita7bf7e79cc42ab723facd3a0ce37a5c8f3d077a6 (patch)
tree57ba0b798883d91736b34dfb1530f94d64fad018
parentde7161fa687201393edf0b92a0bc9c6d4023cc84 (diff)
When reporting "bad receiver" warnings, highlight the receiver.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49183 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/GRSimpleVals.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Analysis/GRSimpleVals.cpp b/lib/Analysis/GRSimpleVals.cpp
index 208e7cb7ae..d7138b2466 100644
--- a/lib/Analysis/GRSimpleVals.cpp
+++ b/lib/Analysis/GRSimpleVals.cpp
@@ -103,7 +103,7 @@ public:
class VISIBILITY_HIDDEN BadMsgExprArg : public BugDescription {
public:
virtual const char* getName() const {
- return "bad argument";
+ return "bad receiver";
}
virtual const char* getDescription() const {
return "Pass-by-value argument in message expression is undefined.";
@@ -111,13 +111,26 @@ public:
};
class VISIBILITY_HIDDEN BadReceiver : public BugDescription {
+ SourceRange R;
public:
+ BadReceiver(ExplodedNode<ValueState>* N) {
+ Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
+ Expr* E = cast<ObjCMessageExpr>(S)->getReceiver();
+ assert (E && "Receiver cannot be NULL");
+ R = E->getSourceRange();
+ }
+
virtual const char* getName() const {
return "invalid message expression";
}
virtual const char* getDescription() const {
return "Receiver in message expression is an uninitialized value.";
}
+
+ virtual void getRanges(const SourceRange*& B, const SourceRange*& E) const {
+ B = &R;
+ E = B+1;
+ }
};
class VISIBILITY_HIDDEN RetStack : public BugDescription {
@@ -211,8 +224,12 @@ unsigned RunGRSimpleVals(CFG& cfg, Decl& CD, ASTContext& Ctx,
EmitWarning(Diag, PD, Ctx, BR, BadMsgExprArg(), G,
CS->msg_expr_undef_arg_begin(), CS->msg_expr_undef_arg_end());
- EmitWarning(Diag, PD, Ctx, BR, BadReceiver(), G,
- CS->undef_receivers_begin(), CS->undef_receivers_end());
+ for (GRExprEngine::UndefReceiversTy::iterator I = CS->undef_receivers_begin(),
+ E = CS->undef_receivers_end(); I!=E; ++I) {
+
+ BadReceiver Desc(*I);
+ BR.EmitPathWarning(Diag, PD, Ctx, Desc, G, *I);
+ }
EmitWarning(Diag, PD, Ctx, BR, RetStack(), G,
CS->ret_stackaddr_begin(), CS->ret_stackaddr_end());