GRSimple analysis now outputs additional diagnostic warnings about

passing an uninitialized value to a message expresion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2008-03-25 16:40:05 +00:00
Родитель b9308372e0
Коммит dbfe41acda
2 изменённых файлов: 37 добавлений и 9 удалений

Просмотреть файл

@ -211,7 +211,12 @@ public:
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 @@ public:
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);

Просмотреть файл

@ -119,7 +119,7 @@ unsigned RunGRSimpleVals(CFG& cfg, Decl& CD, ASTContext& Ctx,
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 @@ unsigned RunGRSimpleVals(CFG& cfg, Decl& CD, ASTContext& Ctx,
"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 @@ unsigned RunGRSimpleVals(CFG& cfg, Decl& CD, ASTContext& Ctx,
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);