[cfe-commits] r48776 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/GRSimpleVals.cpp
Ted Kremenek
kremenek at apple.com
Tue Mar 25 09:40:06 PDT 2008
Author: kremenek
Date: Tue Mar 25 11:40:05 2008
New Revision: 48776
URL: http://llvm.org/viewvc/llvm-project?rev=48776&view=rev
Log:
GRSimple analysis now outputs additional diagnostic warnings about
passing an uninitialized value to a message expresion.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Analysis/GRSimpleVals.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=48776&r1=48775&r2=48776&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Tue Mar 25 11:40:05 2008
@@ -211,7 +211,12 @@
bool isUndefArg(const NodeTy* N) const {
return N->isSink() &&
- UndefArgs.find(const_cast<NodeTy*>(N)) != UndefArgs.end();
+ (UndefArgs.find(const_cast<NodeTy*>(N)) != UndefArgs.end() ||
+ MsgExprUndefArgs.find(const_cast<NodeTy*>(N)) != MsgExprUndefArgs.end());
+ }
+
+ bool isUndefReceiver(const NodeTy* N) const {
+ return N->isSink() && UndefReceivers.count(const_cast<NodeTy*>(N)) != 0;
}
typedef UndefBranchesTy::iterator undef_branch_iterator;
@@ -256,6 +261,23 @@
undef_arg_iterator undef_arg_begin() { return UndefArgs.begin(); }
undef_arg_iterator undef_arg_end() { return UndefArgs.end(); }
+ undef_arg_iterator msg_expr_undef_arg_begin() {
+ return MsgExprUndefArgs.begin();
+ }
+ undef_arg_iterator msg_expr_undef_arg_end() {
+ return MsgExprUndefArgs.end();
+ }
+
+ typedef UndefReceiversTy::iterator undef_receivers_iterator;
+
+ undef_receivers_iterator undef_receivers_begin() {
+ return UndefReceivers.begin();
+ }
+
+ undef_receivers_iterator undef_receivers_end() {
+ return UndefReceivers.end();
+ }
+
/// ProcessStmt - Called by GRCoreEngine. Used to generate new successor
/// nodes by processing the 'effects' of a block-level statement.
void ProcessStmt(Stmt* S, StmtNodeBuilder& builder);
Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=48776&r1=48775&r2=48776&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Tue Mar 25 11:40:05 2008
@@ -119,7 +119,7 @@
EmitWarning(Diag, SrcMgr,
CheckerState->null_derefs_begin(),
CheckerState->null_derefs_end(),
- "NULL pointer is dereferenced after it is checked for NULL.");
+ "Dereference of NULL pointer.");
EmitWarning(Diag, SrcMgr,
CheckerState->undef_derefs_begin(),
@@ -127,9 +127,9 @@
"Dereference of undefined value.");
EmitWarning(Diag, SrcMgr,
- CheckerState->undef_derefs_begin(),
- CheckerState->undef_derefs_end(),
- "Dereference of undefined value.");
+ CheckerState->undef_branches_begin(),
+ CheckerState->undef_branches_end(),
+ "Branch condition evaluates to an uninitialized value.");
EmitWarning(Diag, SrcMgr,
CheckerState->explicit_bad_divides_begin(),
@@ -149,12 +149,18 @@
EmitWarning(Diag, SrcMgr,
CheckerState->undef_arg_begin(),
CheckerState->undef_arg_end(),
- "Pass-by-value argument in function or message expression is undefined.");
+ "Pass-by-value argument in function is undefined.");
EmitWarning(Diag, SrcMgr,
- CheckerState->undef_branches_begin(),
- CheckerState->undef_branches_end(),
- "Branch condition evaluates to an uninitialized value.");
+ CheckerState->msg_expr_undef_arg_begin(),
+ CheckerState->msg_expr_undef_arg_end(),
+ "Pass-by-value argument in message expression is undefined.");
+
+ EmitWarning(Diag, SrcMgr,
+ CheckerState->undef_receivers_begin(),
+ CheckerState->undef_receivers_end(),
+ "Receiver in message expression is an uninitialized value.");
+
#ifndef NDEBUG
if (Visualize) CheckerState->ViewGraph(TrimGraph);
More information about the cfe-commits
mailing list