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