Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 1 | //== ValueState.h - Path-Sens. "State" for tracking valuues -----*- C++ -*--==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 10 | // This files defines SymbolID, VarBindKey, and ValueState. |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_ANALYSIS_VALUESTATE_H |
| 15 | #define LLVM_CLANG_ANALYSIS_VALUESTATE_H |
| 16 | |
| 17 | // FIXME: Reduce the number of includes. |
| 18 | |
| 19 | #include "RValues.h" |
| 20 | |
| 21 | #include "clang/Analysis/PathSensitive/GREngine.h" |
| 22 | #include "clang/AST/Expr.h" |
| 23 | #include "clang/AST/Decl.h" |
| 24 | #include "clang/AST/ASTContext.h" |
| 25 | #include "clang/Analysis/Analyses/LiveVariables.h" |
| 26 | |
| 27 | #include "llvm/Support/Casting.h" |
| 28 | #include "llvm/Support/DataTypes.h" |
| 29 | #include "llvm/ADT/APSInt.h" |
| 30 | #include "llvm/ADT/FoldingSet.h" |
| 31 | #include "llvm/ADT/ImmutableMap.h" |
| 32 | #include "llvm/ADT/SmallVector.h" |
| 33 | #include "llvm/ADT/SmallPtrSet.h" |
| 34 | #include "llvm/Support/Allocator.h" |
| 35 | #include "llvm/Support/Compiler.h" |
| 36 | #include "llvm/Support/Streams.h" |
| 37 | |
| 38 | #include <functional> |
| 39 | |
| 40 | namespace clang { |
| 41 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 42 | /// VarBindKey - A variant smart pointer that wraps either a ValueDecl* or a |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 43 | /// Stmt*. Use cast<> or dyn_cast<> to get actual pointer type |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 44 | class VarBindKey { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 45 | uintptr_t Raw; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 46 | void operator=(const VarBindKey& RHS); // Do not implement. |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 47 | |
| 48 | public: |
| 49 | enum Kind { IsSubExpr=0x0, IsBlkExpr=0x1, IsDecl=0x2, // L-Value Bindings. |
| 50 | IsSymbol=0x3, // Symbol Bindings. |
| 51 | Mask=0x3 }; |
| 52 | |
| 53 | inline Kind getKind() const { |
| 54 | return (Kind) (Raw & Mask); |
| 55 | } |
| 56 | |
| 57 | inline void* getPtr() const { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 58 | return reinterpret_cast<void*>(Raw & ~Mask); |
| 59 | } |
| 60 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 61 | VarBindKey(const ValueDecl* VD) |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 62 | : Raw(reinterpret_cast<uintptr_t>(VD) | IsDecl) { |
| 63 | assert(VD && "ValueDecl cannot be NULL."); |
| 64 | } |
| 65 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 66 | VarBindKey(Stmt* S, bool isBlkExpr = false) |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 67 | : Raw(reinterpret_cast<uintptr_t>(S) | (isBlkExpr ? IsBlkExpr : IsSubExpr)){ |
| 68 | assert(S && "Tracked statement cannot be NULL."); |
| 69 | } |
| 70 | |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 71 | bool isSubExpr() const { return getKind() == IsSubExpr; } |
| 72 | bool isBlkExpr() const { return getKind() == IsBlkExpr; } |
| 73 | bool isDecl() const { return getKind() == IsDecl; } |
| 74 | bool isStmt() const { return getKind() <= IsBlkExpr; } |
| 75 | |
| 76 | inline void Profile(llvm::FoldingSetNodeID& ID) const { |
Ted Kremenek | 071679d | 2008-02-08 19:08:13 +0000 | [diff] [blame] | 77 | ID.AddPointer(getPtr()); |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 80 | inline bool operator==(const VarBindKey& X) const { |
Ted Kremenek | 071679d | 2008-02-08 19:08:13 +0000 | [diff] [blame] | 81 | return getPtr() == X.getPtr(); |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 84 | inline bool operator!=(const VarBindKey& X) const { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 85 | return !operator==(X); |
| 86 | } |
| 87 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 88 | inline bool operator<(const VarBindKey& X) const { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 89 | return getPtr() < X.getPtr(); |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | //===----------------------------------------------------------------------===// |
| 94 | // ValueState - An ImmutableMap type Stmt*/Decl*/Symbols to RValues. |
| 95 | //===----------------------------------------------------------------------===// |
| 96 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 97 | namespace vstate { |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 98 | typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy; |
| 99 | |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 100 | typedef llvm::ImmutableMap<VarBindKey,RValue> VarBindingsTy; |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 101 | typedef llvm::ImmutableMap<SymbolID,IntSetTy> ConstantNotEqTy; |
| 102 | typedef llvm::ImmutableMap<SymbolID,const llvm::APSInt*> ConstantEqTy; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 103 | } |
Ted Kremenek | 6f886bd | 2008-02-05 18:24:17 +0000 | [diff] [blame] | 104 | |
| 105 | /// ValueStateImpl - This class encapsulates the actual data values for |
| 106 | /// for a "state" in our symbolic value tracking. It is intended to be |
| 107 | /// used as a functional object; that is once it is created and made |
| 108 | /// "persistent" in a FoldingSet its values will never change. |
Ted Kremenek | a40ba02 | 2008-02-06 02:50:36 +0000 | [diff] [blame] | 109 | class ValueStateImpl : public llvm::FoldingSetNode { |
| 110 | private: |
| 111 | void operator=(const ValueStateImpl& R) const; |
| 112 | |
| 113 | public: |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 114 | vstate::VarBindingsTy VarBindings; |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 115 | vstate::ConstantNotEqTy ConstantNotEq; |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 116 | vstate::ConstantEqTy ConstantEq; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 117 | |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 118 | /// This ctor is used when creating the first ValueStateImpl object. |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 119 | ValueStateImpl(vstate::VarBindingsTy VB, |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 120 | vstate::ConstantNotEqTy CNE, |
| 121 | vstate::ConstantEqTy CE) |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 122 | : VarBindings(VB), ConstantNotEq(CNE), ConstantEq(CE) {} |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 123 | |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 124 | /// Copy ctor - We must explicitly define this or else the "Next" ptr |
| 125 | /// in FoldingSetNode will also get copied. |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 126 | ValueStateImpl(const ValueStateImpl& RHS) |
Ted Kremenek | 6f886bd | 2008-02-05 18:24:17 +0000 | [diff] [blame] | 127 | : llvm::FoldingSetNode(), |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 128 | VarBindings(RHS.VarBindings), |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 129 | ConstantNotEq(RHS.ConstantNotEq), |
| 130 | ConstantEq(RHS.ConstantEq) {} |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 131 | |
Ted Kremenek | a40ba02 | 2008-02-06 02:50:36 +0000 | [diff] [blame] | 132 | |
| 133 | |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 134 | /// Profile - Profile the contents of a ValueStateImpl object for use |
| 135 | /// in a FoldingSet. |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 136 | static void Profile(llvm::FoldingSetNodeID& ID, const ValueStateImpl& V) { |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 137 | V.VarBindings.Profile(ID); |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 138 | V.ConstantNotEq.Profile(ID); |
| 139 | V.ConstantEq.Profile(ID); |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 140 | } |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 141 | |
| 142 | /// Profile - Used to profile the contents of this object for inclusion |
| 143 | /// in a FoldingSet. |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 144 | void Profile(llvm::FoldingSetNodeID& ID) const { |
| 145 | Profile(ID, *this); |
| 146 | } |
| 147 | |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
Ted Kremenek | 6f886bd | 2008-02-05 18:24:17 +0000 | [diff] [blame] | 150 | /// ValueState - This class represents a "state" in our symbolic value |
| 151 | /// tracking. It is really just a "smart pointer", wrapping a pointer |
| 152 | /// to ValueStateImpl object. Making this class a smart pointer means that its |
| 153 | /// size is always the size of a pointer, which allows easy conversion to |
| 154 | /// void* when being handled by GREngine. It also forces us to unique states; |
| 155 | /// consequently, a ValueStateImpl* with a specific address will always refer |
| 156 | /// to the unique state with those values. |
Ted Kremenek | a40ba02 | 2008-02-06 02:50:36 +0000 | [diff] [blame] | 157 | class ValueState { |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 158 | ValueStateImpl* Data; |
| 159 | public: |
Ted Kremenek | ed90021 | 2008-02-05 18:17:58 +0000 | [diff] [blame] | 160 | ValueState(ValueStateImpl* D) : Data(D) {} |
Ted Kremenek | a40ba02 | 2008-02-06 02:50:36 +0000 | [diff] [blame] | 161 | ValueState() : Data(0) {} |
Ted Kremenek | ed90021 | 2008-02-05 18:17:58 +0000 | [diff] [blame] | 162 | |
Ted Kremenek | cba2e43 | 2008-02-05 19:35:18 +0000 | [diff] [blame] | 163 | // Accessors. |
Ted Kremenek | ed90021 | 2008-02-05 18:17:58 +0000 | [diff] [blame] | 164 | ValueStateImpl* getImpl() const { return Data; } |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 165 | |
Ted Kremenek | cba2e43 | 2008-02-05 19:35:18 +0000 | [diff] [blame] | 166 | // Typedefs. |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 167 | typedef vstate::IntSetTy IntSetTy; |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 168 | typedef vstate::VarBindingsTy VarBindingsTy; |
Ted Kremenek | cba2e43 | 2008-02-05 19:35:18 +0000 | [diff] [blame] | 169 | typedef vstate::ConstantNotEqTy ConstantNotEqTy; |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 170 | typedef vstate::ConstantEqTy ConstantEqTy; |
| 171 | |
Ted Kremenek | cba2e43 | 2008-02-05 19:35:18 +0000 | [diff] [blame] | 172 | typedef llvm::SmallVector<ValueState,5> BufferTy; |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 173 | |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 174 | // Queries. |
| 175 | |
| 176 | bool isNotEqual(SymbolID sym, const llvm::APSInt& V) const; |
| 177 | const llvm::APSInt* getSymVal(SymbolID sym) const; |
| 178 | |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 179 | // Iterators. |
| 180 | |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 181 | typedef VarBindingsTy::iterator vb_iterator; |
| 182 | vb_iterator begin() { return Data->VarBindings.begin(); } |
| 183 | vb_iterator end() { return Data->VarBindings.end(); } |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 184 | |
Ted Kremenek | ed90021 | 2008-02-05 18:17:58 +0000 | [diff] [blame] | 185 | // Profiling and equality testing. |
| 186 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 187 | bool operator==(const ValueState& RHS) const { |
| 188 | return Data == RHS.Data; |
| 189 | } |
| 190 | |
| 191 | static void Profile(llvm::FoldingSetNodeID& ID, const ValueState& V) { |
| 192 | ID.AddPointer(V.getImpl()); |
| 193 | } |
| 194 | |
| 195 | void Profile(llvm::FoldingSetNodeID& ID) const { |
| 196 | Profile(ID, *this); |
| 197 | } |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | template<> struct GRTrait<ValueState> { |
| 201 | static inline void* toPtr(ValueState St) { |
| 202 | return reinterpret_cast<void*>(St.getImpl()); |
| 203 | } |
| 204 | static inline ValueState toState(void* P) { |
| 205 | return ValueState(static_cast<ValueStateImpl*>(P)); |
| 206 | } |
| 207 | }; |
| 208 | |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 209 | |
| 210 | class ValueStateManager { |
| 211 | public: |
| 212 | typedef ValueState StateTy; |
| 213 | |
| 214 | private: |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 215 | ValueState::IntSetTy::Factory ISetFactory; |
Ted Kremenek | 53c641a | 2008-02-08 03:02:48 +0000 | [diff] [blame] | 216 | ValueState::VarBindingsTy::Factory VBFactory; |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 217 | ValueState::ConstantNotEqTy::Factory CNEFactory; |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 218 | ValueState::ConstantEqTy::Factory CEFactory; |
Ted Kremenek | 174aea4 | 2008-02-05 18:51:06 +0000 | [diff] [blame] | 219 | |
| 220 | /// StateSet - FoldingSet containing all the states created for analyzing |
| 221 | /// a particular function. This is used to unique states. |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 222 | llvm::FoldingSet<ValueStateImpl> StateSet; |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 223 | |
| 224 | /// ValueMgr - Object that manages the data for all created RValues. |
| 225 | ValueManager ValMgr; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 226 | |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 227 | /// SymMgr - Object that manages the symbol information. |
| 228 | SymbolManager SymMgr; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 229 | |
| 230 | /// Alloc - A BumpPtrAllocator to allocate states. |
| 231 | llvm::BumpPtrAllocator& Alloc; |
| 232 | |
| 233 | StateTy getPersistentState(const ValueState& St); |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 234 | |
| 235 | public: |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 236 | ValueStateManager(ASTContext& Ctx, llvm::BumpPtrAllocator& alloc) |
| 237 | : ValMgr(Ctx, alloc), Alloc(alloc) {} |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 238 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 239 | StateTy getInitialState(); |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 240 | |
| 241 | ValueManager& getValueManager() { return ValMgr; } |
| 242 | SymbolManager& getSymbolManager() { return SymMgr; } |
| 243 | |
Ted Kremenek | b87d909 | 2008-02-08 19:17:19 +0000 | [diff] [blame] | 244 | StateTy RemoveDeadBindings(StateTy St, Stmt* Loc, |
| 245 | const LiveVariables& Liveness); |
| 246 | |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 247 | StateTy SetValue(StateTy St, Stmt* S, bool isBlkExpr, const RValue& V); |
| 248 | StateTy SetValue(StateTy St, const LValue& LV, const RValue& V); |
| 249 | |
Ted Kremenek | f233d48 | 2008-02-05 00:26:40 +0000 | [diff] [blame] | 250 | RValue GetValue(const StateTy& St, Stmt* S, bool* hasVal = NULL); |
Ted Kremenek | b87d909 | 2008-02-08 19:17:19 +0000 | [diff] [blame] | 251 | RValue GetValue(const StateTy& St, const LValue& LV, QualType* T = NULL); |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 252 | LValue GetLValue(const StateTy& St, Stmt* S); |
Ted Kremenek | b87d909 | 2008-02-08 19:17:19 +0000 | [diff] [blame] | 253 | |
| 254 | |
| 255 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 256 | |
| 257 | StateTy Add(StateTy St, VarBindKey K, const RValue& V); |
| 258 | StateTy Remove(StateTy St, VarBindKey K); |
| 259 | StateTy getPersistentState(const ValueStateImpl& Impl); |
Ted Kremenek | 862d5bb | 2008-02-06 00:54:14 +0000 | [diff] [blame] | 260 | |
| 261 | StateTy AddEQ(StateTy St, SymbolID sym, const llvm::APSInt& V); |
| 262 | StateTy AddNE(StateTy St, SymbolID sym, const llvm::APSInt& V); |
Ted Kremenek | e070a1d | 2008-02-04 21:59:01 +0000 | [diff] [blame] | 263 | }; |
| 264 | |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 265 | } // end clang namespace |
| 266 | |
| 267 | //==------------------------------------------------------------------------==// |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 268 | // Casting machinery to get cast<> and dyn_cast<> working with VarBindKey. |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 269 | //==------------------------------------------------------------------------==// |
| 270 | |
| 271 | namespace llvm { |
| 272 | |
| 273 | template<> inline bool |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 274 | isa<clang::ValueDecl,clang::VarBindKey>(const clang::VarBindKey& V) { |
| 275 | return V.getKind() == clang::VarBindKey::IsDecl; |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | template<> inline bool |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 279 | isa<clang::Stmt,clang::VarBindKey>(const clang::VarBindKey& V) { |
| 280 | return ((unsigned) V.getKind()) < clang::VarBindKey::IsDecl; |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 283 | template<> struct cast_retty_impl<clang::ValueDecl,clang::VarBindKey> { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 284 | typedef const clang::ValueDecl* ret_type; |
| 285 | }; |
| 286 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 287 | template<> struct cast_retty_impl<clang::Stmt,clang::VarBindKey> { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 288 | typedef const clang::Stmt* ret_type; |
| 289 | }; |
| 290 | |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 291 | template<> struct simplify_type<clang::VarBindKey> { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 292 | typedef void* SimpleType; |
Ted Kremenek | 9153f73 | 2008-02-05 07:17:49 +0000 | [diff] [blame] | 293 | static inline SimpleType getSimplifiedValue(const clang::VarBindKey &V) { |
Ted Kremenek | a90ccfe | 2008-01-31 19:34:24 +0000 | [diff] [blame] | 294 | return V.getPtr(); |
| 295 | } |
| 296 | }; |
| 297 | } // end llvm namespace |
| 298 | |
| 299 | #endif |