Fix accidental use of CheckSVal instead of CheckLocation, and add a

small test case to show we handle dereferences of undefined values.

llvm-svn: 85492
This commit is contained in:
Ted Kremenek 2009-10-29 05:33:39 +00:00
parent 98261735b4
commit 1dbdbcc04c
2 changed files with 8 additions and 2 deletions

View File

@ -763,7 +763,7 @@ class VISIBILITY_HIDDEN CheckUndefDeref : public Checker {
public:
CheckUndefDeref() : BT(0) {}
ExplodedNode *CheckSVal(const Stmt *S, ExplodedNode *Pred,
ExplodedNode *CheckLocation(const Stmt *S, ExplodedNode *Pred,
const GRState *state, SVal V, GRExprEngine &Eng);
static void *getTag() {
@ -772,7 +772,7 @@ public:
}
};
ExplodedNode *CheckUndefDeref::CheckSVal(const Stmt *S, ExplodedNode *Pred,
ExplodedNode *CheckUndefDeref::CheckLocation(const Stmt *S, ExplodedNode *Pred,
const GRState *state, SVal V,
GRExprEngine &Eng) {
GRStmtNodeBuilder &Builder = Eng.getBuilder();

View File

@ -154,6 +154,12 @@ void handle_sizeof_void(unsigned flag) {
*p = 1; // no-warning
}
// check deference of undefined values
void check_deref_undef(void) {
int *p;
*p = 0xDEADBEEF; // expected-warning{{Dereference of undefined pointer value}}
}
// PR 3422
void pr3422_helper(char *p);
void pr3422() {