Benjamin Kramer | a93d0f2 | 2012-12-01 17:12:56 +0000 | [diff] [blame] | 1 | //=- LiveVariables.cpp - Live Variable Analysis for Source CFGs ----------*-==// |
| 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 | // |
| 10 | // This file implements Live Variables analysis for source-level CFGs. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Ted Kremenek | cf6e41b | 2007-12-21 21:42:19 +0000 | [diff] [blame] | 14 | #include "clang/Analysis/Analyses/LiveVariables.h" |
Benjamin Kramer | a93d0f2 | 2012-12-01 17:12:56 +0000 | [diff] [blame] | 15 | #include "clang/AST/Stmt.h" |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 16 | #include "clang/AST/StmtVisitor.h" |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 17 | #include "clang/Analysis/Analyses/PostOrderCFGView.h" |
| 18 | #include "clang/Analysis/AnalysisContext.h" |
| 19 | #include "clang/Analysis/CFG.h" |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/DenseMap.h" |
Benjamin Kramer | a93d0f2 | 2012-12-01 17:12:56 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/PostOrderIterator.h" |
| 22 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 23 | #include <algorithm> |
| 24 | #include <vector> |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 25 | |
| 26 | using namespace clang; |
| 27 | |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 28 | namespace { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 29 | |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 30 | class DataflowWorklist { |
| 31 | SmallVector<const CFGBlock *, 20> worklist; |
| 32 | llvm::BitVector enqueuedBlocks; |
Ted Kremenek | edb1863 | 2011-10-22 02:14:23 +0000 | [diff] [blame] | 33 | PostOrderCFGView *POV; |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 34 | public: |
Ted Kremenek | 1d26f48 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 35 | DataflowWorklist(const CFG &cfg, AnalysisDeclContext &Ctx) |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 36 | : enqueuedBlocks(cfg.getNumBlockIDs()), |
Ted Kremenek | edb1863 | 2011-10-22 02:14:23 +0000 | [diff] [blame] | 37 | POV(Ctx.getAnalysis<PostOrderCFGView>()) {} |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 38 | |
| 39 | void enqueueBlock(const CFGBlock *block); |
| 40 | void enqueueSuccessors(const CFGBlock *block); |
| 41 | void enqueuePredecessors(const CFGBlock *block); |
| 42 | |
| 43 | const CFGBlock *dequeue(); |
| 44 | |
| 45 | void sortWorklist(); |
| 46 | }; |
| 47 | |
| 48 | } |
| 49 | |
| 50 | void DataflowWorklist::enqueueBlock(const clang::CFGBlock *block) { |
| 51 | if (block && !enqueuedBlocks[block->getBlockID()]) { |
| 52 | enqueuedBlocks[block->getBlockID()] = true; |
| 53 | worklist.push_back(block); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | void DataflowWorklist::enqueueSuccessors(const clang::CFGBlock *block) { |
| 58 | const unsigned OldWorklistSize = worklist.size(); |
| 59 | for (CFGBlock::const_succ_iterator I = block->succ_begin(), |
| 60 | E = block->succ_end(); I != E; ++I) { |
| 61 | enqueueBlock(*I); |
| 62 | } |
| 63 | |
| 64 | if (OldWorklistSize == 0 || OldWorklistSize == worklist.size()) |
| 65 | return; |
| 66 | |
| 67 | sortWorklist(); |
| 68 | } |
| 69 | |
| 70 | void DataflowWorklist::enqueuePredecessors(const clang::CFGBlock *block) { |
| 71 | const unsigned OldWorklistSize = worklist.size(); |
| 72 | for (CFGBlock::const_pred_iterator I = block->pred_begin(), |
| 73 | E = block->pred_end(); I != E; ++I) { |
| 74 | enqueueBlock(*I); |
| 75 | } |
| 76 | |
| 77 | if (OldWorklistSize == 0 || OldWorklistSize == worklist.size()) |
| 78 | return; |
| 79 | |
| 80 | sortWorklist(); |
| 81 | } |
| 82 | |
| 83 | void DataflowWorklist::sortWorklist() { |
Ted Kremenek | edb1863 | 2011-10-22 02:14:23 +0000 | [diff] [blame] | 84 | std::sort(worklist.begin(), worklist.end(), POV->getComparator()); |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 87 | const CFGBlock *DataflowWorklist::dequeue() { |
| 88 | if (worklist.empty()) |
| 89 | return 0; |
Robert Wilhelm | 344472e | 2013-08-23 16:11:15 +0000 | [diff] [blame] | 90 | const CFGBlock *b = worklist.pop_back_val(); |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 91 | enqueuedBlocks[b->getBlockID()] = false; |
| 92 | return b; |
| 93 | } |
| 94 | |
| 95 | namespace { |
| 96 | class LiveVariablesImpl { |
| 97 | public: |
Ted Kremenek | 1d26f48 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 98 | AnalysisDeclContext &analysisContext; |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 99 | std::vector<LiveVariables::LivenessValues> cfgBlockValues; |
| 100 | llvm::ImmutableSet<const Stmt *>::Factory SSetFact; |
| 101 | llvm::ImmutableSet<const VarDecl *>::Factory DSetFact; |
| 102 | llvm::DenseMap<const CFGBlock *, LiveVariables::LivenessValues> blocksEndToLiveness; |
| 103 | llvm::DenseMap<const CFGBlock *, LiveVariables::LivenessValues> blocksBeginToLiveness; |
| 104 | llvm::DenseMap<const Stmt *, LiveVariables::LivenessValues> stmtsToLiveness; |
| 105 | llvm::DenseMap<const DeclRefExpr *, unsigned> inAssignment; |
| 106 | const bool killAtAssign; |
| 107 | |
| 108 | LiveVariables::LivenessValues |
| 109 | merge(LiveVariables::LivenessValues valsA, |
| 110 | LiveVariables::LivenessValues valsB); |
| 111 | |
| 112 | LiveVariables::LivenessValues runOnBlock(const CFGBlock *block, |
| 113 | LiveVariables::LivenessValues val, |
| 114 | LiveVariables::Observer *obs = 0); |
| 115 | |
| 116 | void dumpBlockLiveness(const SourceManager& M); |
| 117 | |
Ted Kremenek | 1d26f48 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 118 | LiveVariablesImpl(AnalysisDeclContext &ac, bool KillAtAssign) |
Ted Kremenek | 3c2b5f7 | 2011-10-02 01:45:37 +0000 | [diff] [blame] | 119 | : analysisContext(ac), |
| 120 | SSetFact(false), // Do not canonicalize ImmutableSets by default. |
| 121 | DSetFact(false), // This is a *major* performance win. |
| 122 | killAtAssign(KillAtAssign) {} |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 123 | }; |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 124 | } |
Ted Kremenek | 7deed0c | 2008-04-15 18:35:30 +0000 | [diff] [blame] | 125 | |
Ted Kremenek | 9c378f7 | 2011-08-12 23:37:29 +0000 | [diff] [blame] | 126 | static LiveVariablesImpl &getImpl(void *x) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 127 | return *((LiveVariablesImpl *) x); |
Ted Kremenek | fdd225e | 2007-09-25 04:31:27 +0000 | [diff] [blame] | 128 | } |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 129 | |
| 130 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 131 | // Operations and queries on LivenessValues. |
| 132 | //===----------------------------------------------------------------------===// |
| 133 | |
| 134 | bool LiveVariables::LivenessValues::isLive(const Stmt *S) const { |
| 135 | return liveStmts.contains(S); |
| 136 | } |
| 137 | |
| 138 | bool LiveVariables::LivenessValues::isLive(const VarDecl *D) const { |
| 139 | return liveDecls.contains(D); |
| 140 | } |
| 141 | |
| 142 | namespace { |
| 143 | template <typename SET> |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 144 | SET mergeSets(SET A, SET B) { |
| 145 | if (A.isEmpty()) |
| 146 | return B; |
| 147 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 148 | for (typename SET::iterator it = B.begin(), ei = B.end(); it != ei; ++it) { |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 149 | A = A.add(*it); |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 150 | } |
| 151 | return A; |
| 152 | } |
| 153 | } |
| 154 | |
David Blaikie | 99ba9e3 | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 155 | void LiveVariables::Observer::anchor() { } |
| 156 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 157 | LiveVariables::LivenessValues |
| 158 | LiveVariablesImpl::merge(LiveVariables::LivenessValues valsA, |
| 159 | LiveVariables::LivenessValues valsB) { |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 160 | |
| 161 | llvm::ImmutableSetRef<const Stmt *> |
| 162 | SSetRefA(valsA.liveStmts.getRootWithoutRetain(), SSetFact.getTreeFactory()), |
| 163 | SSetRefB(valsB.liveStmts.getRootWithoutRetain(), SSetFact.getTreeFactory()); |
| 164 | |
| 165 | |
| 166 | llvm::ImmutableSetRef<const VarDecl *> |
| 167 | DSetRefA(valsA.liveDecls.getRootWithoutRetain(), DSetFact.getTreeFactory()), |
| 168 | DSetRefB(valsB.liveDecls.getRootWithoutRetain(), DSetFact.getTreeFactory()); |
| 169 | |
| 170 | |
| 171 | SSetRefA = mergeSets(SSetRefA, SSetRefB); |
| 172 | DSetRefA = mergeSets(DSetRefA, DSetRefB); |
| 173 | |
Ted Kremenek | 3c2b5f7 | 2011-10-02 01:45:37 +0000 | [diff] [blame] | 174 | // asImmutableSet() canonicalizes the tree, allowing us to do an easy |
| 175 | // comparison afterwards. |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 176 | return LiveVariables::LivenessValues(SSetRefA.asImmutableSet(), |
| 177 | DSetRefA.asImmutableSet()); |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | bool LiveVariables::LivenessValues::equals(const LivenessValues &V) const { |
| 181 | return liveStmts == V.liveStmts && liveDecls == V.liveDecls; |
| 182 | } |
| 183 | |
| 184 | //===----------------------------------------------------------------------===// |
| 185 | // Query methods. |
| 186 | //===----------------------------------------------------------------------===// |
| 187 | |
| 188 | static bool isAlwaysAlive(const VarDecl *D) { |
| 189 | return D->hasGlobalStorage(); |
| 190 | } |
| 191 | |
| 192 | bool LiveVariables::isLive(const CFGBlock *B, const VarDecl *D) { |
| 193 | return isAlwaysAlive(D) || getImpl(impl).blocksEndToLiveness[B].isLive(D); |
| 194 | } |
| 195 | |
| 196 | bool LiveVariables::isLive(const Stmt *S, const VarDecl *D) { |
| 197 | return isAlwaysAlive(D) || getImpl(impl).stmtsToLiveness[S].isLive(D); |
| 198 | } |
| 199 | |
| 200 | bool LiveVariables::isLive(const Stmt *Loc, const Stmt *S) { |
| 201 | return getImpl(impl).stmtsToLiveness[Loc].isLive(S); |
| 202 | } |
| 203 | |
| 204 | //===----------------------------------------------------------------------===// |
| 205 | // Dataflow computation. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 206 | //===----------------------------------------------------------------------===// |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 207 | |
| 208 | namespace { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 209 | class TransferFunctions : public StmtVisitor<TransferFunctions> { |
| 210 | LiveVariablesImpl &LV; |
| 211 | LiveVariables::LivenessValues &val; |
| 212 | LiveVariables::Observer *observer; |
Ted Kremenek | 848ec83 | 2011-02-11 23:24:26 +0000 | [diff] [blame] | 213 | const CFGBlock *currentBlock; |
Pavel Labath | 6a556a4 | 2013-08-23 07:19:22 +0000 | [diff] [blame] | 214 | |
| 215 | void markLogicalExprLeaves(const Expr *E); |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 216 | public: |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 217 | TransferFunctions(LiveVariablesImpl &im, |
| 218 | LiveVariables::LivenessValues &Val, |
| 219 | LiveVariables::Observer *Observer, |
| 220 | const CFGBlock *CurrentBlock) |
| 221 | : LV(im), val(Val), observer(Observer), currentBlock(CurrentBlock) {} |
Ted Kremenek | fdd225e | 2007-09-25 04:31:27 +0000 | [diff] [blame] | 222 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 223 | void VisitBinaryOperator(BinaryOperator *BO); |
| 224 | void VisitBlockExpr(BlockExpr *BE); |
| 225 | void VisitDeclRefExpr(DeclRefExpr *DR); |
| 226 | void VisitDeclStmt(DeclStmt *DS); |
| 227 | void VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS); |
| 228 | void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE); |
| 229 | void VisitUnaryOperator(UnaryOperator *UO); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 230 | void Visit(Stmt *S); |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 231 | }; |
Ted Kremenek | 11e7218 | 2007-10-01 20:33:52 +0000 | [diff] [blame] | 232 | } |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 233 | |
Ted Kremenek | f91a5b0 | 2011-08-06 00:30:00 +0000 | [diff] [blame] | 234 | static const VariableArrayType *FindVA(QualType Ty) { |
| 235 | const Type *ty = Ty.getTypePtr(); |
| 236 | while (const ArrayType *VT = dyn_cast<ArrayType>(ty)) { |
| 237 | if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(VT)) |
| 238 | if (VAT->getSizeExpr()) |
| 239 | return VAT; |
| 240 | |
| 241 | ty = VT->getElementType().getTypePtr(); |
| 242 | } |
| 243 | |
| 244 | return 0; |
| 245 | } |
| 246 | |
Ted Kremenek | ddaec0d | 2011-11-05 00:26:53 +0000 | [diff] [blame] | 247 | static const Stmt *LookThroughStmt(const Stmt *S) { |
Ted Kremenek | 6bbecd5 | 2011-11-05 07:34:28 +0000 | [diff] [blame] | 248 | while (S) { |
| 249 | if (const Expr *Ex = dyn_cast<Expr>(S)) |
| 250 | S = Ex->IgnoreParens(); |
John McCall | f3fb5c5 | 2011-11-09 17:10:36 +0000 | [diff] [blame] | 251 | if (const ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(S)) { |
| 252 | S = EWC->getSubExpr(); |
| 253 | continue; |
| 254 | } |
Ted Kremenek | 6bbecd5 | 2011-11-05 07:34:28 +0000 | [diff] [blame] | 255 | if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(S)) { |
| 256 | S = OVE->getSourceExpr(); |
| 257 | continue; |
| 258 | } |
| 259 | break; |
| 260 | } |
Ted Kremenek | ddaec0d | 2011-11-05 00:26:53 +0000 | [diff] [blame] | 261 | return S; |
| 262 | } |
| 263 | |
| 264 | static void AddLiveStmt(llvm::ImmutableSet<const Stmt *> &Set, |
| 265 | llvm::ImmutableSet<const Stmt *>::Factory &F, |
| 266 | const Stmt *S) { |
| 267 | Set = F.add(Set, LookThroughStmt(S)); |
| 268 | } |
| 269 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 270 | void TransferFunctions::Visit(Stmt *S) { |
| 271 | if (observer) |
| 272 | observer->observeStmt(S, currentBlock, val); |
Ted Kremenek | bfbcefb | 2009-12-24 02:40:30 +0000 | [diff] [blame] | 273 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 274 | StmtVisitor<TransferFunctions>::Visit(S); |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 275 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 276 | if (isa<Expr>(S)) { |
| 277 | val.liveStmts = LV.SSetFact.remove(val.liveStmts, S); |
| 278 | } |
| 279 | |
| 280 | // Mark all children expressions live. |
| 281 | |
| 282 | switch (S->getStmtClass()) { |
| 283 | default: |
| 284 | break; |
| 285 | case Stmt::StmtExprClass: { |
| 286 | // For statement expressions, look through the compound statement. |
| 287 | S = cast<StmtExpr>(S)->getSubStmt(); |
| 288 | break; |
| 289 | } |
| 290 | case Stmt::CXXMemberCallExprClass: { |
| 291 | // Include the implicit "this" pointer as being live. |
| 292 | CXXMemberCallExpr *CE = cast<CXXMemberCallExpr>(S); |
Ted Kremenek | c808503 | 2011-10-06 20:53:28 +0000 | [diff] [blame] | 293 | if (Expr *ImplicitObj = CE->getImplicitObjectArgument()) { |
Ted Kremenek | ddaec0d | 2011-11-05 00:26:53 +0000 | [diff] [blame] | 294 | AddLiveStmt(val.liveStmts, LV.SSetFact, ImplicitObj); |
Ted Kremenek | c808503 | 2011-10-06 20:53:28 +0000 | [diff] [blame] | 295 | } |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 296 | break; |
| 297 | } |
Anna Zaks | c739406 | 2012-08-14 00:36:20 +0000 | [diff] [blame] | 298 | case Stmt::ObjCMessageExprClass: { |
| 299 | // In calls to super, include the implicit "self" pointer as being live. |
| 300 | ObjCMessageExpr *CE = cast<ObjCMessageExpr>(S); |
| 301 | if (CE->getReceiverKind() == ObjCMessageExpr::SuperInstance) |
| 302 | val.liveDecls = LV.DSetFact.add(val.liveDecls, |
| 303 | LV.analysisContext.getSelfDecl()); |
| 304 | break; |
| 305 | } |
Ted Kremenek | f91a5b0 | 2011-08-06 00:30:00 +0000 | [diff] [blame] | 306 | case Stmt::DeclStmtClass: { |
| 307 | const DeclStmt *DS = cast<DeclStmt>(S); |
| 308 | if (const VarDecl *VD = dyn_cast<VarDecl>(DS->getSingleDecl())) { |
| 309 | for (const VariableArrayType* VA = FindVA(VD->getType()); |
| 310 | VA != 0; VA = FindVA(VA->getElementType())) { |
Ted Kremenek | ddaec0d | 2011-11-05 00:26:53 +0000 | [diff] [blame] | 311 | AddLiveStmt(val.liveStmts, LV.SSetFact, VA->getSizeExpr()); |
Ted Kremenek | f91a5b0 | 2011-08-06 00:30:00 +0000 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | break; |
| 315 | } |
John McCall | 4b9c2d2 | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 316 | case Stmt::PseudoObjectExprClass: { |
| 317 | // A pseudo-object operation only directly consumes its result |
| 318 | // expression. |
| 319 | Expr *child = cast<PseudoObjectExpr>(S)->getResultExpr(); |
| 320 | if (!child) return; |
| 321 | if (OpaqueValueExpr *OV = dyn_cast<OpaqueValueExpr>(child)) |
| 322 | child = OV->getSourceExpr(); |
| 323 | child = child->IgnoreParens(); |
| 324 | val.liveStmts = LV.SSetFact.add(val.liveStmts, child); |
| 325 | return; |
| 326 | } |
| 327 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 328 | // FIXME: These cases eventually shouldn't be needed. |
| 329 | case Stmt::ExprWithCleanupsClass: { |
| 330 | S = cast<ExprWithCleanups>(S)->getSubExpr(); |
| 331 | break; |
| 332 | } |
| 333 | case Stmt::CXXBindTemporaryExprClass: { |
| 334 | S = cast<CXXBindTemporaryExpr>(S)->getSubExpr(); |
| 335 | break; |
| 336 | } |
Ted Kremenek | f91a5b0 | 2011-08-06 00:30:00 +0000 | [diff] [blame] | 337 | case Stmt::UnaryExprOrTypeTraitExprClass: { |
| 338 | // No need to unconditionally visit subexpressions. |
| 339 | return; |
| 340 | } |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | for (Stmt::child_iterator it = S->child_begin(), ei = S->child_end(); |
| 344 | it != ei; ++it) { |
Ted Kremenek | ddaec0d | 2011-11-05 00:26:53 +0000 | [diff] [blame] | 345 | if (Stmt *child = *it) |
| 346 | AddLiveStmt(val.liveStmts, LV.SSetFact, child); |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 347 | } |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 348 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 349 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 350 | void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) { |
| 351 | if (B->isAssignmentOp()) { |
| 352 | if (!LV.killAtAssign) |
Ted Kremenek | 06529ae | 2008-11-14 21:07:14 +0000 | [diff] [blame] | 353 | return; |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 354 | |
| 355 | // Assigning to a variable? |
| 356 | Expr *LHS = B->getLHS()->IgnoreParens(); |
| 357 | |
Ted Kremenek | 9c378f7 | 2011-08-12 23:37:29 +0000 | [diff] [blame] | 358 | if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(LHS)) |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 359 | if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) { |
| 360 | // Assignments to references don't kill the ref's address |
| 361 | if (VD->getType()->isReferenceType()) |
| 362 | return; |
Ted Kremenek | e97d9db | 2008-11-11 19:40:47 +0000 | [diff] [blame] | 363 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 364 | if (!isAlwaysAlive(VD)) { |
| 365 | // The variable is now dead. |
| 366 | val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD); |
| 367 | } |
Ted Kremenek | 8f5aab6 | 2008-11-11 17:42:10 +0000 | [diff] [blame] | 368 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 369 | if (observer) |
| 370 | observer->observerKill(DR); |
Ted Kremenek | 5620631 | 2008-02-22 00:34:10 +0000 | [diff] [blame] | 371 | } |
Pavel Labath | 6a556a4 | 2013-08-23 07:19:22 +0000 | [diff] [blame] | 372 | } else if (B->isLogicalOp()) { |
| 373 | // Leaf expressions in the logical operator tree are live until we reach the |
| 374 | // outermost logical operator. Static analyzer relies on this behaviour. |
| 375 | markLogicalExprLeaves(B->getLHS()->IgnoreParens()); |
| 376 | markLogicalExprLeaves(B->getRHS()->IgnoreParens()); |
Ted Kremenek | 27b07c5 | 2007-09-06 21:26:58 +0000 | [diff] [blame] | 377 | } |
| 378 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 379 | |
Pavel Labath | 6a556a4 | 2013-08-23 07:19:22 +0000 | [diff] [blame] | 380 | void TransferFunctions::markLogicalExprLeaves(const Expr *E) { |
| 381 | const BinaryOperator *B = dyn_cast<BinaryOperator>(E); |
| 382 | if (!B || !B->isLogicalOp()) { |
| 383 | val.liveStmts = LV.SSetFact.add(val.liveStmts, E); |
| 384 | return; |
| 385 | } |
| 386 | |
| 387 | markLogicalExprLeaves(B->getLHS()->IgnoreParens()); |
| 388 | markLogicalExprLeaves(B->getRHS()->IgnoreParens()); |
| 389 | } |
| 390 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 391 | void TransferFunctions::VisitBlockExpr(BlockExpr *BE) { |
Ted Kremenek | 15ce164 | 2011-12-22 01:30:46 +0000 | [diff] [blame] | 392 | AnalysisDeclContext::referenced_decls_iterator I, E; |
| 393 | llvm::tie(I, E) = |
| 394 | LV.analysisContext.getReferencedBlockVars(BE->getBlockDecl()); |
| 395 | for ( ; I != E ; ++I) { |
| 396 | const VarDecl *VD = *I; |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 397 | if (isAlwaysAlive(VD)) |
| 398 | continue; |
| 399 | val.liveDecls = LV.DSetFact.add(val.liveDecls, VD); |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 400 | } |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 403 | void TransferFunctions::VisitDeclRefExpr(DeclRefExpr *DR) { |
| 404 | if (const VarDecl *D = dyn_cast<VarDecl>(DR->getDecl())) |
| 405 | if (!isAlwaysAlive(D) && LV.inAssignment.find(DR) == LV.inAssignment.end()) |
| 406 | val.liveDecls = LV.DSetFact.add(val.liveDecls, D); |
| 407 | } |
| 408 | |
| 409 | void TransferFunctions::VisitDeclStmt(DeclStmt *DS) { |
Ted Kremenek | 14f8b4f | 2008-08-05 20:46:55 +0000 | [diff] [blame] | 410 | for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE = DS->decl_end(); |
| 411 | DI != DE; ++DI) |
Ted Kremenek | 9c378f7 | 2011-08-12 23:37:29 +0000 | [diff] [blame] | 412 | if (VarDecl *VD = dyn_cast<VarDecl>(*DI)) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 413 | if (!isAlwaysAlive(VD)) |
| 414 | val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD); |
Ted Kremenek | dcc4810 | 2008-02-25 22:28:54 +0000 | [diff] [blame] | 415 | } |
Ted Kremenek | 27b07c5 | 2007-09-06 21:26:58 +0000 | [diff] [blame] | 416 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 417 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 418 | void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS) { |
| 419 | // Kill the iteration variable. |
| 420 | DeclRefExpr *DR = 0; |
| 421 | const VarDecl *VD = 0; |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 422 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 423 | Stmt *element = OS->getElement(); |
| 424 | if (DeclStmt *DS = dyn_cast<DeclStmt>(element)) { |
| 425 | VD = cast<VarDecl>(DS->getSingleDecl()); |
| 426 | } |
| 427 | else if ((DR = dyn_cast<DeclRefExpr>(cast<Expr>(element)->IgnoreParens()))) { |
| 428 | VD = cast<VarDecl>(DR->getDecl()); |
| 429 | } |
| 430 | |
| 431 | if (VD) { |
| 432 | val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD); |
| 433 | if (observer && DR) |
| 434 | observer->observerKill(DR); |
| 435 | } |
Ted Kremenek | fdd225e | 2007-09-25 04:31:27 +0000 | [diff] [blame] | 436 | } |
Ted Kremenek | 27b07c5 | 2007-09-06 21:26:58 +0000 | [diff] [blame] | 437 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 438 | void TransferFunctions:: |
| 439 | VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE) |
| 440 | { |
| 441 | // While sizeof(var) doesn't technically extend the liveness of 'var', it |
| 442 | // does extent the liveness of metadata if 'var' is a VariableArrayType. |
| 443 | // We handle that special case here. |
| 444 | if (UE->getKind() != UETT_SizeOf || UE->isArgumentType()) |
| 445 | return; |
| 446 | |
Ted Kremenek | f91a5b0 | 2011-08-06 00:30:00 +0000 | [diff] [blame] | 447 | const Expr *subEx = UE->getArgumentExpr(); |
| 448 | if (subEx->getType()->isVariableArrayType()) { |
| 449 | assert(subEx->isLValue()); |
| 450 | val.liveStmts = LV.SSetFact.add(val.liveStmts, subEx->IgnoreParens()); |
| 451 | } |
Ted Kremenek | 27b07c5 | 2007-09-06 21:26:58 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 454 | void TransferFunctions::VisitUnaryOperator(UnaryOperator *UO) { |
| 455 | // Treat ++/-- as a kill. |
| 456 | // Note we don't actually have to do anything if we don't have an observer, |
| 457 | // since a ++/-- acts as both a kill and a "use". |
| 458 | if (!observer) |
| 459 | return; |
| 460 | |
| 461 | switch (UO->getOpcode()) { |
| 462 | default: |
| 463 | return; |
| 464 | case UO_PostInc: |
| 465 | case UO_PostDec: |
| 466 | case UO_PreInc: |
| 467 | case UO_PreDec: |
| 468 | break; |
| 469 | } |
| 470 | |
| 471 | if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) |
| 472 | if (isa<VarDecl>(DR->getDecl())) { |
| 473 | // Treat ++/-- as a kill. |
| 474 | observer->observerKill(DR); |
| 475 | } |
Ted Kremenek | 27b07c5 | 2007-09-06 21:26:58 +0000 | [diff] [blame] | 476 | } |
| 477 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 478 | LiveVariables::LivenessValues |
| 479 | LiveVariablesImpl::runOnBlock(const CFGBlock *block, |
| 480 | LiveVariables::LivenessValues val, |
| 481 | LiveVariables::Observer *obs) { |
| 482 | |
| 483 | TransferFunctions TF(*this, val, obs, block); |
| 484 | |
| 485 | // Visit the terminator (if any). |
| 486 | if (const Stmt *term = block->getTerminator()) |
| 487 | TF.Visit(const_cast<Stmt*>(term)); |
| 488 | |
| 489 | // Apply the transfer function for all Stmts in the block. |
| 490 | for (CFGBlock::const_reverse_iterator it = block->rbegin(), |
| 491 | ei = block->rend(); it != ei; ++it) { |
| 492 | const CFGElement &elem = *it; |
Jordan Rose | d7f1d13 | 2012-07-26 20:04:08 +0000 | [diff] [blame] | 493 | |
David Blaikie | b078054 | 2013-02-23 00:29:34 +0000 | [diff] [blame] | 494 | if (Optional<CFGAutomaticObjDtor> Dtor = |
| 495 | elem.getAs<CFGAutomaticObjDtor>()) { |
| 496 | val.liveDecls = DSetFact.add(val.liveDecls, Dtor->getVarDecl()); |
Jordan Rose | d7f1d13 | 2012-07-26 20:04:08 +0000 | [diff] [blame] | 497 | continue; |
| 498 | } |
| 499 | |
David Blaikie | fdf6a27 | 2013-02-21 20:58:29 +0000 | [diff] [blame] | 500 | if (!elem.getAs<CFGStmt>()) |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 501 | continue; |
| 502 | |
David Blaikie | fdf6a27 | 2013-02-21 20:58:29 +0000 | [diff] [blame] | 503 | const Stmt *S = elem.castAs<CFGStmt>().getStmt(); |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 504 | TF.Visit(const_cast<Stmt*>(S)); |
| 505 | stmtsToLiveness[S] = val; |
| 506 | } |
| 507 | return val; |
Ted Kremenek | 055c275 | 2007-09-06 23:00:42 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 510 | void LiveVariables::runOnAllBlocks(LiveVariables::Observer &obs) { |
| 511 | const CFG *cfg = getImpl(impl).analysisContext.getCFG(); |
| 512 | for (CFG::const_iterator it = cfg->begin(), ei = cfg->end(); it != ei; ++it) |
| 513 | getImpl(impl).runOnBlock(*it, getImpl(impl).blocksEndToLiveness[*it], &obs); |
Ted Kremenek | 8694674 | 2008-01-17 20:48:37 +0000 | [diff] [blame] | 514 | } |
| 515 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 516 | LiveVariables::LiveVariables(void *im) : impl(im) {} |
| 517 | |
| 518 | LiveVariables::~LiveVariables() { |
| 519 | delete (LiveVariablesImpl*) impl; |
Ted Kremenek | 2a9da9c | 2008-01-18 00:40:21 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 522 | LiveVariables * |
Ted Kremenek | 1d26f48 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 523 | LiveVariables::computeLiveness(AnalysisDeclContext &AC, |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 524 | bool killAtAssign) { |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 525 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 526 | // No CFG? Bail out. |
| 527 | CFG *cfg = AC.getCFG(); |
| 528 | if (!cfg) |
| 529 | return 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 530 | |
Ted Kremenek | d4aeb80 | 2012-07-02 20:21:52 +0000 | [diff] [blame] | 531 | // The analysis currently has scalability issues for very large CFGs. |
| 532 | // Bail out if it looks too large. |
| 533 | if (cfg->getNumBlockIDs() > 300000) |
| 534 | return 0; |
| 535 | |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 536 | LiveVariablesImpl *LV = new LiveVariablesImpl(AC, killAtAssign); |
| 537 | |
| 538 | // Construct the dataflow worklist. Enqueue the exit block as the |
| 539 | // start of the analysis. |
Ted Kremenek | edb1863 | 2011-10-22 02:14:23 +0000 | [diff] [blame] | 540 | DataflowWorklist worklist(*cfg, AC); |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 541 | llvm::BitVector everAnalyzedBlock(cfg->getNumBlockIDs()); |
| 542 | |
| 543 | // FIXME: we should enqueue using post order. |
| 544 | for (CFG::const_iterator it = cfg->begin(), ei = cfg->end(); it != ei; ++it) { |
| 545 | const CFGBlock *block = *it; |
| 546 | worklist.enqueueBlock(block); |
| 547 | |
| 548 | // FIXME: Scan for DeclRefExprs using in the LHS of an assignment. |
| 549 | // We need to do this because we lack context in the reverse analysis |
| 550 | // to determine if a DeclRefExpr appears in such a context, and thus |
| 551 | // doesn't constitute a "use". |
| 552 | if (killAtAssign) |
| 553 | for (CFGBlock::const_iterator bi = block->begin(), be = block->end(); |
| 554 | bi != be; ++bi) { |
David Blaikie | b078054 | 2013-02-23 00:29:34 +0000 | [diff] [blame] | 555 | if (Optional<CFGStmt> cs = bi->getAs<CFGStmt>()) { |
| 556 | if (const BinaryOperator *BO = |
| 557 | dyn_cast<BinaryOperator>(cs->getStmt())) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 558 | if (BO->getOpcode() == BO_Assign) { |
| 559 | if (const DeclRefExpr *DR = |
| 560 | dyn_cast<DeclRefExpr>(BO->getLHS()->IgnoreParens())) { |
| 561 | LV->inAssignment[DR] = 1; |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 569 | worklist.sortWorklist(); |
| 570 | |
| 571 | while (const CFGBlock *block = worklist.dequeue()) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 572 | // Determine if the block's end value has changed. If not, we |
| 573 | // have nothing left to do for this block. |
| 574 | LivenessValues &prevVal = LV->blocksEndToLiveness[block]; |
| 575 | |
| 576 | // Merge the values of all successor blocks. |
| 577 | LivenessValues val; |
| 578 | for (CFGBlock::const_succ_iterator it = block->succ_begin(), |
| 579 | ei = block->succ_end(); it != ei; ++it) { |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 580 | if (const CFGBlock *succ = *it) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 581 | val = LV->merge(val, LV->blocksBeginToLiveness[succ]); |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 582 | } |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | if (!everAnalyzedBlock[block->getBlockID()]) |
| 586 | everAnalyzedBlock[block->getBlockID()] = true; |
| 587 | else if (prevVal.equals(val)) |
| 588 | continue; |
| 589 | |
| 590 | prevVal = val; |
| 591 | |
| 592 | // Update the dataflow value for the start of this block. |
| 593 | LV->blocksBeginToLiveness[block] = LV->runOnBlock(block, val); |
| 594 | |
| 595 | // Enqueue the value to the predecessors. |
Ted Kremenek | 87aa125 | 2011-09-16 23:01:39 +0000 | [diff] [blame] | 596 | worklist.enqueuePredecessors(block); |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | return new LiveVariables(LV); |
| 600 | } |
| 601 | |
Benjamin Kramer | 39997fc | 2011-08-02 04:50:49 +0000 | [diff] [blame] | 602 | static bool compare_entries(const CFGBlock *A, const CFGBlock *B) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 603 | return A->getBlockID() < B->getBlockID(); |
| 604 | } |
Benjamin Kramer | 39997fc | 2011-08-02 04:50:49 +0000 | [diff] [blame] | 605 | |
| 606 | static bool compare_vd_entries(const Decl *A, const Decl *B) { |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 607 | SourceLocation ALoc = A->getLocStart(); |
| 608 | SourceLocation BLoc = B->getLocStart(); |
| 609 | return ALoc.getRawEncoding() < BLoc.getRawEncoding(); |
| 610 | } |
| 611 | |
| 612 | void LiveVariables::dumpBlockLiveness(const SourceManager &M) { |
| 613 | getImpl(impl).dumpBlockLiveness(M); |
| 614 | } |
| 615 | |
| 616 | void LiveVariablesImpl::dumpBlockLiveness(const SourceManager &M) { |
| 617 | std::vector<const CFGBlock *> vec; |
| 618 | for (llvm::DenseMap<const CFGBlock *, LiveVariables::LivenessValues>::iterator |
| 619 | it = blocksEndToLiveness.begin(), ei = blocksEndToLiveness.end(); |
| 620 | it != ei; ++it) { |
| 621 | vec.push_back(it->first); |
| 622 | } |
| 623 | std::sort(vec.begin(), vec.end(), compare_entries); |
| 624 | |
| 625 | std::vector<const VarDecl*> declVec; |
| 626 | |
| 627 | for (std::vector<const CFGBlock *>::iterator |
| 628 | it = vec.begin(), ei = vec.end(); it != ei; ++it) { |
| 629 | llvm::errs() << "\n[ B" << (*it)->getBlockID() |
| 630 | << " (live variables at block exit) ]\n"; |
| 631 | |
| 632 | LiveVariables::LivenessValues vals = blocksEndToLiveness[*it]; |
| 633 | declVec.clear(); |
| 634 | |
| 635 | for (llvm::ImmutableSet<const VarDecl *>::iterator si = |
| 636 | vals.liveDecls.begin(), |
| 637 | se = vals.liveDecls.end(); si != se; ++si) { |
| 638 | declVec.push_back(*si); |
| 639 | } |
| 640 | |
| 641 | std::sort(declVec.begin(), declVec.end(), compare_vd_entries); |
| 642 | |
| 643 | for (std::vector<const VarDecl*>::iterator di = declVec.begin(), |
| 644 | de = declVec.end(); di != de; ++di) { |
| 645 | llvm::errs() << " " << (*di)->getDeclName().getAsString() |
| 646 | << " <"; |
| 647 | (*di)->getLocation().dump(M); |
Daniel Dunbar | c0d5672 | 2009-10-17 18:12:37 +0000 | [diff] [blame] | 648 | llvm::errs() << ">\n"; |
Ted Kremenek | e4e6334 | 2007-09-06 00:17:54 +0000 | [diff] [blame] | 649 | } |
Ted Kremenek | 27b07c5 | 2007-09-06 21:26:58 +0000 | [diff] [blame] | 650 | } |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 651 | llvm::errs() << "\n"; |
Ted Kremenek | c0576ca | 2007-09-10 17:36:42 +0000 | [diff] [blame] | 652 | } |
Ted Kremenek | 8829989 | 2011-07-28 23:07:59 +0000 | [diff] [blame] | 653 | |
Ted Kremenek | a5937bb | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 654 | const void *LiveVariables::getTag() { static int x; return &x; } |
| 655 | const void *RelaxedLiveVariables::getTag() { static int x; return &x; } |