[cfe-commits] r49183 - /cfe/trunk/lib/Analysis/GRSimpleVals.cpp
Ted Kremenek
kremenek at apple.com
Thu Apr 3 11:46:16 PDT 2008
Author: kremenek
Date: Thu Apr 3 13:46:16 2008
New Revision: 49183
URL: http://llvm.org/viewvc/llvm-project?rev=49183&view=rev
Log:
When reporting "bad receiver" warnings, highlight the receiver.
Modified:
cfe/trunk/lib/Analysis/GRSimpleVals.cpp
Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=49183&r1=49182&r2=49183&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Thu Apr 3 13:46:16 2008
@@ -103,7 +103,7 @@
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 @@
};
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 @@
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());
More information about the cfe-commits
mailing list