From: Ted Kremenek Date: Thu, 29 Oct 2009 05:33:39 +0000 (+0000) Subject: Fix accidental use of CheckSVal instead of CheckLocation, and add a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f214b35cac948f8bb68542814379858e984c745;p=clang Fix accidental use of CheckSVal instead of CheckLocation, and add a small test case to show we handle dereferences of undefined values. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85492 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp index ca38b05df8..526bc93e85 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -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(); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index fcc13a39a4..0d4592a9e3 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -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() {