diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-09-18 23:09:54 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-09-18 23:09:54 +0000 |
commit | 7360fda1efd88fd28ca2882579676dbd8569c181 (patch) | |
tree | 923c21a0fa78f3ce6a44f56489f01e5e8c29adaf /include/clang/Analysis | |
parent | 644f5fc35c9d093b2ae1e8f43cf5a70680b5945a (diff) |
Implement second part of PR 2600: NSError** parameter may be null, and should be checked before being dereferenced.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis')
-rw-r--r-- | include/clang/Analysis/PathSensitive/BasicValueFactory.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngine.h | 7 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRState.h | 28 |
3 files changed, 32 insertions, 5 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h index c3729ed53e..29957a7996 100644 --- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h +++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h @@ -77,6 +77,8 @@ public: const std::pair<RVal, RVal>& getPersistentRValPair(const RVal& V1, const RVal& V2); + + const RVal* getPersistentRVal(RVal X); }; } // end clang namespace diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index d08e442e35..1a288c24af 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -293,6 +293,13 @@ public: null_deref_iterator null_derefs_begin() { return ExplicitNullDeref.begin(); } null_deref_iterator null_derefs_end() { return ExplicitNullDeref.end(); } + null_deref_iterator implicit_null_derefs_begin() { + return ImplicitNullDeref.begin(); + } + null_deref_iterator implicit_null_derefs_end() { + return ImplicitNullDeref.end(); + } + typedef BadDerefTy::iterator undef_deref_iterator; undef_deref_iterator undef_derefs_begin() { return UndefDeref.begin(); } undef_deref_iterator undef_derefs_end() { return UndefDeref.end(); } diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 993977984f..fd81a86946 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -43,12 +43,25 @@ namespace clang { class GRStateManager; class GRTransferFuncs; + +//===----------------------------------------------------------------------===// +// GRStateTrait - Traits used by the Generic Data Map of a GRState. +//===----------------------------------------------------------------------===// +template <typename T> struct GRStatePartialTrait; + +template <typename T> struct GRStateTrait { + typedef typename T::data_type data_type; + static inline void* GDMIndex() { return &T::TagInt; } + static inline void* MakeVoidPtr(data_type D) { return (void*) D; } + static inline data_type MakeData(void* const* P) { + return P ? (data_type) *P : (data_type) 0; + } +}; + //===----------------------------------------------------------------------===// // GRState- An ImmutableMap type Stmt*/Decl*/Symbols to RVals. //===----------------------------------------------------------------------===// - -template<typename T> struct GRStateTrait; /// GRState - This class encapsulates the actual data values for /// for a "state" in our symbolic value tracking. It is intended to be @@ -169,7 +182,13 @@ public: void print(std::ostream& Out, StoreManager& StoreMgr, ConstraintManager& ConstraintMgr, Printer **Beg = 0, Printer **End = 0, - const char* nl = "\n", const char *sep = "") const; + const char* nl = "\n", const char *sep = "") const; + + // Tags used for the Generic Data Map. + struct NullDerefTag { + static int TagInt; + typedef const RVal* data_type; + }; }; template<> struct GRTrait<GRState*> { @@ -566,8 +585,7 @@ public: void printDOT(std::ostream& Out) const; }; - - + } // end clang namespace #endif |