blob: b354566db02fd1a536cbe9b44f1f76652f3b4e79 [file] [log] [blame]
Ted Kremenek26e47462007-09-20 21:42:55 +00001//=- LiveVariables.cpp - Live Variable Analysis for Source CFGs -*- C++ --*-==//
Ted Kremenekaa04c512007-09-06 00:17:54 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner959e5be2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Ted Kremenekaa04c512007-09-06 00:17:54 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements Live Variables analysis for source-level CFGs.
11//
12//===----------------------------------------------------------------------===//
13
Ted Kremenekcdf8e842007-12-21 21:42:19 +000014#include "clang/Analysis/Analyses/LiveVariables.h"
Ted Kremenek05334682007-09-06 21:26:58 +000015#include "clang/Basic/SourceManager.h"
Ted Kremenek41a40bc2008-12-09 00:14:14 +000016#include "clang/AST/ASTContext.h"
Ted Kremenekaa04c512007-09-06 00:17:54 +000017#include "clang/AST/Expr.h"
18#include "clang/AST/CFG.h"
Ted Kremenekd7a2f812007-09-25 04:31:27 +000019#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
Ted Kremenek10d80462007-09-25 21:00:24 +000020#include "clang/Analysis/FlowSensitive/DataflowSolver.h"
Ted Kremenekaa04c512007-09-06 00:17:54 +000021#include "llvm/ADT/SmallPtrSet.h"
Ted Kremenek9ea943f2008-04-15 18:35:30 +000022#include "llvm/ADT/SmallVector.h"
Ted Kremenekec818352008-01-08 18:19:08 +000023#include "llvm/Support/Compiler.h"
Ted Kremenekaa04c512007-09-06 00:17:54 +000024
Ted Kremenek05334682007-09-06 21:26:58 +000025#include <string.h>
26#include <stdio.h>
Ted Kremenekaa04c512007-09-06 00:17:54 +000027
28using namespace clang;
29
30//===----------------------------------------------------------------------===//
Ted Kremenek9ea943f2008-04-15 18:35:30 +000031// Useful constants.
32//===----------------------------------------------------------------------===//
33
34static const bool Alive = true;
35static const bool Dead = false;
36
37//===----------------------------------------------------------------------===//
Ted Kremenekd7a2f812007-09-25 04:31:27 +000038// Dataflow initialization logic.
39//===----------------------------------------------------------------------===//
Ted Kremenekaa04c512007-09-06 00:17:54 +000040
41namespace {
Ted Kremenekec818352008-01-08 18:19:08 +000042class VISIBILITY_HIDDEN RegisterDecls
43 : public CFGRecStmtDeclVisitor<RegisterDecls> {
44
Ted Kremenekd7a2f812007-09-25 04:31:27 +000045 LiveVariables::AnalysisDataTy& AD;
Ted Kremenek9ea943f2008-04-15 18:35:30 +000046
47 typedef llvm::SmallVector<VarDecl*, 20> AlwaysLiveTy;
48 AlwaysLiveTy AlwaysLive;
49
50
Ted Kremenekeebf1312007-09-28 20:38:59 +000051public:
Ted Kremenek9ea943f2008-04-15 18:35:30 +000052 RegisterDecls(LiveVariables::AnalysisDataTy& ad) : AD(ad) {}
53
54 ~RegisterDecls() {
55
56 AD.AlwaysLive.resetValues(AD);
57
58 for (AlwaysLiveTy::iterator I = AlwaysLive.begin(), E = AlwaysLive.end();
59 I != E; ++ I)
60 AD.AlwaysLive(*I, AD) = Alive;
61 }
62
Chris Lattner8c7c6a12008-06-17 18:05:57 +000063 void VisitImplicitParamDecl(ImplicitParamDecl* IPD) {
64 // Register the VarDecl for tracking.
65 AD.Register(IPD);
66 }
67
Ted Kremenek9ea943f2008-04-15 18:35:30 +000068 void VisitVarDecl(VarDecl* VD) {
69 // Register the VarDecl for tracking.
70 AD.Register(VD);
71
72 // Does the variable have global storage? If so, it is always live.
73 if (VD->hasGlobalStorage())
74 AlwaysLive.push_back(VD);
75 }
76
Ted Kremenek705386b2007-11-20 03:01:58 +000077 CFG& getCFG() { return AD.getCFG(); }
Ted Kremenek8ce772b2007-10-01 20:33:52 +000078};
Ted Kremenekaa04c512007-09-06 00:17:54 +000079} // end anonymous namespace
80
Ted Kremenek41a40bc2008-12-09 00:14:14 +000081LiveVariables::LiveVariables(ASTContext& Ctx, CFG& cfg) {
Ted Kremenekf41ac5f2008-03-13 16:55:07 +000082 // Register all referenced VarDecls.
Ted Kremenek41a40bc2008-12-09 00:14:14 +000083 getAnalysisData().setCFG(cfg);
84 getAnalysisData().setContext(Ctx);
85
Ted Kremenek8ce772b2007-10-01 20:33:52 +000086 RegisterDecls R(getAnalysisData());
Ted Kremenekd7a2f812007-09-25 04:31:27 +000087 cfg.VisitBlockStmts(R);
88}
Ted Kremenekaa04c512007-09-06 00:17:54 +000089
90//===----------------------------------------------------------------------===//
Ted Kremenekd7a2f812007-09-25 04:31:27 +000091// Transfer functions.
92//===----------------------------------------------------------------------===//
Ted Kremenekaa04c512007-09-06 00:17:54 +000093
94namespace {
Ted Kremenekeebf1312007-09-28 20:38:59 +000095
Ted Kremenekec818352008-01-08 18:19:08 +000096class VISIBILITY_HIDDEN TransferFuncs : public CFGRecStmtVisitor<TransferFuncs>{
Ted Kremenekd7a2f812007-09-25 04:31:27 +000097 LiveVariables::AnalysisDataTy& AD;
Ted Kremenekeebf1312007-09-28 20:38:59 +000098 LiveVariables::ValTy LiveState;
Ted Kremenekaa04c512007-09-06 00:17:54 +000099public:
Ted Kremenek8ce772b2007-10-01 20:33:52 +0000100 TransferFuncs(LiveVariables::AnalysisDataTy& ad) : AD(ad) {}
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000101
Ted Kremenekeebf1312007-09-28 20:38:59 +0000102 LiveVariables::ValTy& getVal() { return LiveState; }
Ted Kremenek705386b2007-11-20 03:01:58 +0000103 CFG& getCFG() { return AD.getCFG(); }
Ted Kremenek00b63272007-09-12 19:10:52 +0000104
Ted Kremenekaa04c512007-09-06 00:17:54 +0000105 void VisitDeclRefExpr(DeclRefExpr* DR);
106 void VisitBinaryOperator(BinaryOperator* B);
107 void VisitAssign(BinaryOperator* B);
Ted Kremenek05334682007-09-06 21:26:58 +0000108 void VisitDeclStmt(DeclStmt* DS);
Ted Kremeneke71b3c32008-11-12 21:58:46 +0000109 void BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S);
Ted Kremenek05334682007-09-06 21:26:58 +0000110 void VisitUnaryOperator(UnaryOperator* U);
Ted Kremeneke48db1c2008-11-11 17:42:10 +0000111 void Visit(Stmt *S);
Ted Kremenek79f0a632008-04-16 21:10:48 +0000112 void VisitTerminator(CFGBlock* B);
Ted Kremenek9ea943f2008-04-15 18:35:30 +0000113
114 void SetTopValue(LiveVariables::ValTy& V) {
Ted Kremenekb79cdbe2009-01-30 21:35:30 +0000115 V = AD.AlwaysLive;
Ted Kremenek9ea943f2008-04-15 18:35:30 +0000116 }
117
Ted Kremenekaa04c512007-09-06 00:17:54 +0000118};
Ted Kremenek8ce772b2007-10-01 20:33:52 +0000119
Ted Kremenek8ce772b2007-10-01 20:33:52 +0000120void TransferFuncs::Visit(Stmt *S) {
Ted Kremenekeebf1312007-09-28 20:38:59 +0000121
Ted Kremenekab6c5902008-01-17 20:48:37 +0000122 if (S == getCurrentBlkStmt()) {
Ted Kremenekb4677db2008-07-03 22:25:27 +0000123
124 if (AD.Observer)
125 AD.Observer->ObserveStmt(S,AD,LiveState);
126
Ted Kremenek925b3a92008-03-05 19:26:46 +0000127 if (getCFG().isBlkExpr(S)) LiveState(S,AD) = Dead;
Ted Kremenek1796e132008-01-18 00:40:21 +0000128 StmtVisitor<TransferFuncs,void>::Visit(S);
Ted Kremenekab6c5902008-01-17 20:48:37 +0000129 }
Ted Kremenekb4677db2008-07-03 22:25:27 +0000130 else if (!getCFG().isBlkExpr(S)) {
131
132 if (AD.Observer)
133 AD.Observer->ObserveStmt(S,AD,LiveState);
134
Ted Kremenekab6c5902008-01-17 20:48:37 +0000135 StmtVisitor<TransferFuncs,void>::Visit(S);
Ted Kremenekb4677db2008-07-03 22:25:27 +0000136
137 }
Zhongxing Xu4b4e7da2009-06-30 12:11:58 +0000138 else {
Ted Kremenekab6c5902008-01-17 20:48:37 +0000139 // For block-level expressions, mark that they are live.
140 LiveState(S,AD) = Alive;
Zhongxing Xu4b4e7da2009-06-30 12:11:58 +0000141 StmtVisitor<TransferFuncs,void>::Visit(S);
142 }
Ted Kremenek8ce772b2007-10-01 20:33:52 +0000143}
Ted Kremeneka0aa0b12008-04-15 04:39:08 +0000144
Ted Kremenek79f0a632008-04-16 21:10:48 +0000145void TransferFuncs::VisitTerminator(CFGBlock* B) {
146
Ted Kremenek0d2bc352008-11-12 21:12:18 +0000147 const Stmt* E = B->getTerminatorCondition();
Ted Kremenek79f0a632008-04-16 21:10:48 +0000148
Ted Kremenek5ae4e832008-04-16 17:07:59 +0000149 if (!E)
150 return;
151
Ted Kremenek5ae4e832008-04-16 17:07:59 +0000152 assert (getCFG().isBlkExpr(E));
153 LiveState(E, AD) = Alive;
Ted Kremeneka0aa0b12008-04-15 04:39:08 +0000154}
155
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000156void TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
157 if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
Ted Kremenekeebf1312007-09-28 20:38:59 +0000158 LiveState(V,AD) = Alive;
Ted Kremenekaa04c512007-09-06 00:17:54 +0000159}
Ted Kremenekaa04c512007-09-06 00:17:54 +0000160
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000161void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
Ted Kremenek00b63272007-09-12 19:10:52 +0000162 if (B->isAssignmentOp()) VisitAssign(B);
163 else VisitStmt(B);
Ted Kremenekaa04c512007-09-06 00:17:54 +0000164}
165
Ted Kremeneke71b3c32008-11-12 21:58:46 +0000166void
167TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
168
Ted Kremenek54c73972008-11-14 21:07:14 +0000169 // This is a block-level expression. Its value is 'dead' before this point.
170 LiveState(S, AD) = Dead;
171
Ted Kremenek612ba102008-11-11 19:40:47 +0000172 // This represents a 'use' of the collection.
173 Visit(S->getCollection());
Ted Kremeneke48db1c2008-11-11 17:42:10 +0000174
175 // This represents a 'kill' for the variable.
Ted Kremenek612ba102008-11-11 19:40:47 +0000176 Stmt* Element = S->getElement();
Ted Kremeneke5cb9172008-11-14 01:58:12 +0000177 DeclRefExpr* DR = 0;
Ted Kremenek612ba102008-11-11 19:40:47 +0000178 VarDecl* VD = 0;
179
180 if (DeclStmt* DS = dyn_cast<DeclStmt>(Element))
Chris Lattner4a9a85e2009-03-28 06:33:19 +0000181 VD = cast<VarDecl>(DS->getSingleDecl());
Ted Kremenek612ba102008-11-11 19:40:47 +0000182 else {
Ted Kremeneke5cb9172008-11-14 01:58:12 +0000183 Expr* ElemExpr = cast<Expr>(Element)->IgnoreParens();
184 if ((DR = dyn_cast<DeclRefExpr>(ElemExpr)))
185 VD = cast<VarDecl>(DR->getDecl());
Ted Kremenek54c73972008-11-14 21:07:14 +0000186 else {
187 Visit(ElemExpr);
188 return;
189 }
Ted Kremenek612ba102008-11-11 19:40:47 +0000190 }
191
Ted Kremeneke5cb9172008-11-14 01:58:12 +0000192 if (VD) {
193 LiveState(VD, AD) = Dead;
194 if (AD.Observer && DR) { AD.Observer->ObserverKill(DR); }
195 }
Ted Kremeneke48db1c2008-11-11 17:42:10 +0000196}
197
198
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000199void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
Ted Kremenek133befa2008-01-17 17:50:49 +0000200 Expr *E = U->getSubExpr();
Ted Kremenek83a6ba12007-09-28 21:29:33 +0000201
Ted Kremenek05334682007-09-06 21:26:58 +0000202 switch (U->getOpcode()) {
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000203 case UnaryOperator::PostInc:
204 case UnaryOperator::PostDec:
205 case UnaryOperator::PreInc:
206 case UnaryOperator::PreDec:
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000207 // Walk through the subexpressions, blasting through ParenExprs
208 // until we either find a DeclRefExpr or some non-DeclRefExpr
209 // expression.
Ted Kremenek2c3041c2008-02-22 00:34:10 +0000210 if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParens()))
Ted Kremenek96715132008-04-15 04:08:54 +0000211 if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl())) {
212 // Treat the --/++ operator as a kill.
Ted Kremenek2c3041c2008-02-22 00:34:10 +0000213 if (AD.Observer) { AD.Observer->ObserverKill(DR); }
Ted Kremenek96715132008-04-15 04:08:54 +0000214 LiveState(VD, AD) = Alive;
Ted Kremenek2c3041c2008-02-22 00:34:10 +0000215 return VisitDeclRefExpr(DR);
216 }
Ted Kremenek83a6ba12007-09-28 21:29:33 +0000217
218 // Fall-through.
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000219
220 default:
Ted Kremenek133befa2008-01-17 17:50:49 +0000221 return Visit(E);
Ted Kremenek05334682007-09-06 21:26:58 +0000222 }
223}
Ted Kremenek83a6ba12007-09-28 21:29:33 +0000224
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000225void TransferFuncs::VisitAssign(BinaryOperator* B) {
Ted Kremenek133befa2008-01-17 17:50:49 +0000226 Expr* LHS = B->getLHS();
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000227
Ted Kremenek83a6ba12007-09-28 21:29:33 +0000228 // Assigning to a variable?
Ted Kremenek133befa2008-01-17 17:50:49 +0000229 if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS->IgnoreParens())) {
Ted Kremenek9ea943f2008-04-15 18:35:30 +0000230
231 // Update liveness inforamtion.
232 unsigned bit = AD.getIdx(DR->getDecl());
233 LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
234
Ted Kremenekeebf1312007-09-28 20:38:59 +0000235 if (AD.Observer) { AD.Observer->ObserverKill(DR); }
236
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000237 // Handle things like +=, etc., which also generate "uses"
238 // of a variable. Do this just by visiting the subexpression.
Ted Kremenek83a6ba12007-09-28 21:29:33 +0000239 if (B->getOpcode() != BinaryOperator::Assign)
240 VisitDeclRefExpr(DR);
Ted Kremenekaa04c512007-09-06 00:17:54 +0000241 }
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000242 else // Not assigning to a variable. Process LHS as usual.
Ted Kremenek05334682007-09-06 21:26:58 +0000243 Visit(LHS);
Ted Kremenekaa04c512007-09-06 00:17:54 +0000244
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000245 Visit(B->getRHS());
Ted Kremenekaa04c512007-09-06 00:17:54 +0000246}
247
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000248void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
249 // Declarations effectively "kill" a variable since they cannot
250 // possibly be live before they are declared.
Ted Kremenekb59f9cf2008-08-05 20:46:55 +0000251 for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE = DS->decl_end();
252 DI != DE; ++DI)
253 if (VarDecl* VD = dyn_cast<VarDecl>(*DI)) {
Ted Kremenek85abe6e2008-09-26 05:52:45 +0000254 // The initializer is evaluated after the variable comes into scope.
255 // Since this is a reverse dataflow analysis, we must evaluate the
256 // transfer function for this expression first.
Ted Kremenek0c5fe982008-02-07 02:38:55 +0000257 if (Expr* Init = VD->getInit())
258 Visit(Init);
Ted Kremenek85abe6e2008-09-26 05:52:45 +0000259
Ted Kremenek41a40bc2008-12-09 00:14:14 +0000260 if (const VariableArrayType* VT =
261 AD.getContext().getAsVariableArrayType(VD->getType())) {
262 StmtIterator I(const_cast<VariableArrayType*>(VT));
263 StmtIterator E;
264 for (; I != E; ++I) Visit(*I);
265 }
266
Ted Kremenek85abe6e2008-09-26 05:52:45 +0000267 // Update liveness information by killing the VarDecl.
268 unsigned bit = AD.getIdx(VD);
269 LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
Ted Kremenek43c51bd2008-02-25 22:28:54 +0000270 }
Ted Kremenek05334682007-09-06 21:26:58 +0000271}
Ted Kremenekeebf1312007-09-28 20:38:59 +0000272
Ted Kremenekaa04c512007-09-06 00:17:54 +0000273} // end anonymous namespace
274
Ted Kremenekeebf1312007-09-28 20:38:59 +0000275//===----------------------------------------------------------------------===//
276// Merge operator: if something is live on any successor block, it is live
277// in the current block (a set union).
278//===----------------------------------------------------------------------===//
Ted Kremenekaa04c512007-09-06 00:17:54 +0000279
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000280namespace {
Ted Kremenek9b9f2b92008-03-20 21:46:49 +0000281
282struct Merge {
Ted Kremeneke178f202008-11-14 01:14:18 +0000283 typedef StmtDeclBitVector_Types::ValTy ValTy;
Ted Kremenek9b9f2b92008-03-20 21:46:49 +0000284
285 void operator()(ValTy& Dst, const ValTy& Src) {
286 Dst.OrDeclBits(Src);
Ted Kremenekb79cdbe2009-01-30 21:35:30 +0000287 Dst.OrBlkExprBits(Src);
Ted Kremenek9b9f2b92008-03-20 21:46:49 +0000288 }
289};
290
291typedef DataflowSolver<LiveVariables, TransferFuncs, Merge> Solver;
Ted Kremenekeebf1312007-09-28 20:38:59 +0000292} // end anonymous namespace
293
294//===----------------------------------------------------------------------===//
295// External interface to run Liveness analysis.
296//===----------------------------------------------------------------------===//
Ted Kremenekaa04c512007-09-06 00:17:54 +0000297
Ted Kremenek5ee98a72008-01-11 00:40:29 +0000298void LiveVariables::runOnCFG(CFG& cfg) {
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000299 Solver S(*this);
300 S.runOnCFG(cfg);
301}
Ted Kremenek05334682007-09-06 21:26:58 +0000302
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000303void LiveVariables::runOnAllBlocks(const CFG& cfg,
Ted Kremenekab8ed952008-01-17 18:25:22 +0000304 LiveVariables::ObserverTy* Obs,
305 bool recordStmtValues) {
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000306 Solver S(*this);
307 ObserverTy* OldObserver = getAnalysisData().Observer;
Ted Kremenekab8ed952008-01-17 18:25:22 +0000308 getAnalysisData().Observer = Obs;
309 S.runOnAllBlocks(cfg, recordStmtValues);
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000310 getAnalysisData().Observer = OldObserver;
Ted Kremenek05334682007-09-06 21:26:58 +0000311}
312
313//===----------------------------------------------------------------------===//
314// liveness queries
315//
316
Ted Kremenek6b2b4e32007-09-10 17:36:42 +0000317bool LiveVariables::isLive(const CFGBlock* B, const VarDecl* D) const {
Ted Kremenekf41ac5f2008-03-13 16:55:07 +0000318 DeclBitVector_Types::Idx i = getAnalysisData().getIdx(D);
319 return i.isValid() ? getBlockData(B).getBit(i) : false;
Ted Kremenek05334682007-09-06 21:26:58 +0000320}
321
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000322bool LiveVariables::isLive(const ValTy& Live, const VarDecl* D) const {
Ted Kremenekf41ac5f2008-03-13 16:55:07 +0000323 DeclBitVector_Types::Idx i = getAnalysisData().getIdx(D);
324 return i.isValid() ? Live.getBit(i) : false;
Ted Kremeneke805c4a2007-09-06 23:00:42 +0000325}
326
Ted Kremenekab6c5902008-01-17 20:48:37 +0000327bool LiveVariables::isLive(const Stmt* Loc, const Stmt* StmtVal) const {
328 return getStmtData(Loc)(StmtVal,getAnalysisData());
329}
330
Ted Kremenek1796e132008-01-18 00:40:21 +0000331bool LiveVariables::isLive(const Stmt* Loc, const VarDecl* D) const {
332 return getStmtData(Loc)(D,getAnalysisData());
333}
334
Ted Kremeneke805c4a2007-09-06 23:00:42 +0000335//===----------------------------------------------------------------------===//
Ted Kremenekaa04c512007-09-06 00:17:54 +0000336// printing liveness state for debugging
337//
338
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000339void LiveVariables::dumpLiveness(const ValTy& V, SourceManager& SM) const {
340 const AnalysisDataTy& AD = getAnalysisData();
341
Ted Kremenekeebf1312007-09-28 20:38:59 +0000342 for (AnalysisDataTy::decl_iterator I = AD.begin_decl(),
343 E = AD.end_decl(); I!=E; ++I)
344 if (V.getDeclBit(I->second)) {
Chris Lattner836774b2009-01-27 07:57:44 +0000345 fprintf(stderr, " %s <", I->first->getIdentifier()->getName());
346 I->first->getLocation().dump(SM);
347 fprintf(stderr, ">\n");
Ted Kremenekaa04c512007-09-06 00:17:54 +0000348 }
Ted Kremenekaa04c512007-09-06 00:17:54 +0000349}
350
Ted Kremenek05334682007-09-06 21:26:58 +0000351void LiveVariables::dumpBlockLiveness(SourceManager& M) const {
Ted Kremenekd7a2f812007-09-25 04:31:27 +0000352 for (BlockDataMapTy::iterator I = getBlockDataMap().begin(),
353 E = getBlockDataMap().end(); I!=E; ++I) {
354 fprintf(stderr, "\n[ B%d (live variables at block exit) ]\n",
Ted Kremenek05334682007-09-06 21:26:58 +0000355 I->first->getBlockID());
356
357 dumpLiveness(I->second,M);
358 }
Ted Kremenek6b2b4e32007-09-10 17:36:42 +0000359
360 fprintf(stderr,"\n");
361}