blob: c9828ce551584e15b2ad47146dc97ef9815745df [file] [log] [blame]
Ted Kremenek11de5cb2007-09-20 21:42:55 +00001//=- LiveVariables.cpp - Live Variable Analysis for Source CFGs -*- C++ --*-==//
Ted Kremeneke4e63342007-09-06 00:17:54 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-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 Kremeneke4e63342007-09-06 00:17:54 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements Live Variables analysis for source-level CFGs.
11//
12//===----------------------------------------------------------------------===//
13
Ted Kremenekcf6e41b2007-12-21 21:42:19 +000014#include "clang/Analysis/Analyses/LiveVariables.h"
Ted Kremenek27b07c52007-09-06 21:26:58 +000015#include "clang/Basic/SourceManager.h"
Ted Kremeneke0dbda12008-12-09 00:14:14 +000016#include "clang/AST/ASTContext.h"
Ted Kremeneke4e63342007-09-06 00:17:54 +000017#include "clang/AST/Expr.h"
Ted Kremeneke41611a2009-07-16 18:13:04 +000018#include "clang/Analysis/CFG.h"
Ted Kremenekfdd225e2007-09-25 04:31:27 +000019#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
Ted Kremenek1de632b2007-09-25 21:00:24 +000020#include "clang/Analysis/FlowSensitive/DataflowSolver.h"
Ted Kremeneke4e63342007-09-06 00:17:54 +000021#include "llvm/ADT/SmallPtrSet.h"
Ted Kremenek7deed0c2008-04-15 18:35:30 +000022#include "llvm/ADT/SmallVector.h"
Ted Kremenekc2b51d82008-01-08 18:19:08 +000023#include "llvm/Support/Compiler.h"
Ted Kremeneke4e63342007-09-06 00:17:54 +000024
Ted Kremenek27b07c52007-09-06 21:26:58 +000025#include <string.h>
26#include <stdio.h>
Ted Kremeneke4e63342007-09-06 00:17:54 +000027
28using namespace clang;
29
30//===----------------------------------------------------------------------===//
Ted Kremenek7deed0c2008-04-15 18:35:30 +000031// Useful constants.
32//===----------------------------------------------------------------------===//
33
34static const bool Alive = true;
35static const bool Dead = false;
36
37//===----------------------------------------------------------------------===//
Ted Kremenekfdd225e2007-09-25 04:31:27 +000038// Dataflow initialization logic.
39//===----------------------------------------------------------------------===//
Ted Kremeneke4e63342007-09-06 00:17:54 +000040
41namespace {
Ted Kremenekc2b51d82008-01-08 18:19:08 +000042class VISIBILITY_HIDDEN RegisterDecls
43 : public CFGRecStmtDeclVisitor<RegisterDecls> {
44
Ted Kremenekfdd225e2007-09-25 04:31:27 +000045 LiveVariables::AnalysisDataTy& AD;
Ted Kremenek7deed0c2008-04-15 18:35:30 +000046
47 typedef llvm::SmallVector<VarDecl*, 20> AlwaysLiveTy;
48 AlwaysLiveTy AlwaysLive;
49
50
Ted Kremenekf63aa452007-09-28 20:38:59 +000051public:
Ted Kremenek7deed0c2008-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 Lattner41110242008-06-17 18:05:57 +000063 void VisitImplicitParamDecl(ImplicitParamDecl* IPD) {
64 // Register the VarDecl for tracking.
65 AD.Register(IPD);
66 }
67
Ted Kremenek7deed0c2008-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 Kremenek9f9141c2007-11-20 03:01:58 +000077 CFG& getCFG() { return AD.getCFG(); }
Ted Kremenek11e72182007-10-01 20:33:52 +000078};
Ted Kremeneke4e63342007-09-06 00:17:54 +000079} // end anonymous namespace
80
Ted Kremeneke0dbda12008-12-09 00:14:14 +000081LiveVariables::LiveVariables(ASTContext& Ctx, CFG& cfg) {
Ted Kremenek7cb15932008-03-13 16:55:07 +000082 // Register all referenced VarDecls.
Ted Kremeneke0dbda12008-12-09 00:14:14 +000083 getAnalysisData().setCFG(cfg);
84 getAnalysisData().setContext(Ctx);
85
Ted Kremenek11e72182007-10-01 20:33:52 +000086 RegisterDecls R(getAnalysisData());
Ted Kremenekfdd225e2007-09-25 04:31:27 +000087 cfg.VisitBlockStmts(R);
88}
Ted Kremeneke4e63342007-09-06 00:17:54 +000089
90//===----------------------------------------------------------------------===//
Ted Kremenekfdd225e2007-09-25 04:31:27 +000091// Transfer functions.
92//===----------------------------------------------------------------------===//
Ted Kremeneke4e63342007-09-06 00:17:54 +000093
94namespace {
Ted Kremenekf63aa452007-09-28 20:38:59 +000095
Ted Kremenekc2b51d82008-01-08 18:19:08 +000096class VISIBILITY_HIDDEN TransferFuncs : public CFGRecStmtVisitor<TransferFuncs>{
Ted Kremenekfdd225e2007-09-25 04:31:27 +000097 LiveVariables::AnalysisDataTy& AD;
Ted Kremenekf63aa452007-09-28 20:38:59 +000098 LiveVariables::ValTy LiveState;
Ted Kremeneke4e63342007-09-06 00:17:54 +000099public:
Ted Kremenek11e72182007-10-01 20:33:52 +0000100 TransferFuncs(LiveVariables::AnalysisDataTy& ad) : AD(ad) {}
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000101
Ted Kremenekf63aa452007-09-28 20:38:59 +0000102 LiveVariables::ValTy& getVal() { return LiveState; }
Ted Kremenek9f9141c2007-11-20 03:01:58 +0000103 CFG& getCFG() { return AD.getCFG(); }
Ted Kremenekf1758052007-09-12 19:10:52 +0000104
Ted Kremeneke4e63342007-09-06 00:17:54 +0000105 void VisitDeclRefExpr(DeclRefExpr* DR);
106 void VisitBinaryOperator(BinaryOperator* B);
107 void VisitAssign(BinaryOperator* B);
Ted Kremenek27b07c52007-09-06 21:26:58 +0000108 void VisitDeclStmt(DeclStmt* DS);
Ted Kremenekbfcb7122008-11-12 21:58:46 +0000109 void BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S);
Ted Kremenek27b07c52007-09-06 21:26:58 +0000110 void VisitUnaryOperator(UnaryOperator* U);
Ted Kremenek8f5aab62008-11-11 17:42:10 +0000111 void Visit(Stmt *S);
Ted Kremenek411cdee2008-04-16 21:10:48 +0000112 void VisitTerminator(CFGBlock* B);
Ted Kremenek7deed0c2008-04-15 18:35:30 +0000113
114 void SetTopValue(LiveVariables::ValTy& V) {
Ted Kremenekbf98c992009-01-30 21:35:30 +0000115 V = AD.AlwaysLive;
Ted Kremenek7deed0c2008-04-15 18:35:30 +0000116 }
117
Ted Kremeneke4e63342007-09-06 00:17:54 +0000118};
Ted Kremenek11e72182007-10-01 20:33:52 +0000119
Ted Kremenek11e72182007-10-01 20:33:52 +0000120void TransferFuncs::Visit(Stmt *S) {
Ted Kremenekf63aa452007-09-28 20:38:59 +0000121
Ted Kremenek86946742008-01-17 20:48:37 +0000122 if (S == getCurrentBlkStmt()) {
Ted Kremenek03648652008-07-03 22:25:27 +0000123
124 if (AD.Observer)
125 AD.Observer->ObserveStmt(S,AD,LiveState);
126
Ted Kremenek1aa9a582008-03-05 19:26:46 +0000127 if (getCFG().isBlkExpr(S)) LiveState(S,AD) = Dead;
Ted Kremenek2a9da9c2008-01-18 00:40:21 +0000128 StmtVisitor<TransferFuncs,void>::Visit(S);
Ted Kremenek86946742008-01-17 20:48:37 +0000129 }
Ted Kremenek03648652008-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 Kremenek86946742008-01-17 20:48:37 +0000135 StmtVisitor<TransferFuncs,void>::Visit(S);
Ted Kremenek03648652008-07-03 22:25:27 +0000136
137 }
Zhongxing Xu1b542212009-06-30 12:11:58 +0000138 else {
Ted Kremenek86946742008-01-17 20:48:37 +0000139 // For block-level expressions, mark that they are live.
140 LiveState(S,AD) = Alive;
Zhongxing Xu1b542212009-06-30 12:11:58 +0000141 }
Ted Kremenek11e72182007-10-01 20:33:52 +0000142}
Ted Kremenek37622082008-04-15 04:39:08 +0000143
Ted Kremenek411cdee2008-04-16 21:10:48 +0000144void TransferFuncs::VisitTerminator(CFGBlock* B) {
145
Ted Kremenek8ded8d82008-11-12 21:12:18 +0000146 const Stmt* E = B->getTerminatorCondition();
Ted Kremenek411cdee2008-04-16 21:10:48 +0000147
Ted Kremenek5cd24382008-04-16 17:07:59 +0000148 if (!E)
149 return;
150
Ted Kremenek5cd24382008-04-16 17:07:59 +0000151 assert (getCFG().isBlkExpr(E));
152 LiveState(E, AD) = Alive;
Ted Kremenek37622082008-04-15 04:39:08 +0000153}
154
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000155void TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
156 if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
Ted Kremenekf63aa452007-09-28 20:38:59 +0000157 LiveState(V,AD) = Alive;
Ted Kremeneke4e63342007-09-06 00:17:54 +0000158}
Ted Kremeneke4e63342007-09-06 00:17:54 +0000159
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000160void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
Ted Kremenekf1758052007-09-12 19:10:52 +0000161 if (B->isAssignmentOp()) VisitAssign(B);
162 else VisitStmt(B);
Ted Kremeneke4e63342007-09-06 00:17:54 +0000163}
164
Ted Kremenekbfcb7122008-11-12 21:58:46 +0000165void
166TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
167
Ted Kremenek06529ae2008-11-14 21:07:14 +0000168 // This is a block-level expression. Its value is 'dead' before this point.
169 LiveState(S, AD) = Dead;
170
Ted Kremeneke97d9db2008-11-11 19:40:47 +0000171 // This represents a 'use' of the collection.
172 Visit(S->getCollection());
Ted Kremenek8f5aab62008-11-11 17:42:10 +0000173
174 // This represents a 'kill' for the variable.
Ted Kremeneke97d9db2008-11-11 19:40:47 +0000175 Stmt* Element = S->getElement();
Ted Kremenek8f646002008-11-14 01:58:12 +0000176 DeclRefExpr* DR = 0;
Ted Kremeneke97d9db2008-11-11 19:40:47 +0000177 VarDecl* VD = 0;
178
179 if (DeclStmt* DS = dyn_cast<DeclStmt>(Element))
Chris Lattner7e24e822009-03-28 06:33:19 +0000180 VD = cast<VarDecl>(DS->getSingleDecl());
Ted Kremeneke97d9db2008-11-11 19:40:47 +0000181 else {
Ted Kremenek8f646002008-11-14 01:58:12 +0000182 Expr* ElemExpr = cast<Expr>(Element)->IgnoreParens();
183 if ((DR = dyn_cast<DeclRefExpr>(ElemExpr)))
184 VD = cast<VarDecl>(DR->getDecl());
Ted Kremenek06529ae2008-11-14 21:07:14 +0000185 else {
186 Visit(ElemExpr);
187 return;
188 }
Ted Kremeneke97d9db2008-11-11 19:40:47 +0000189 }
190
Ted Kremenek8f646002008-11-14 01:58:12 +0000191 if (VD) {
192 LiveState(VD, AD) = Dead;
193 if (AD.Observer && DR) { AD.Observer->ObserverKill(DR); }
194 }
Ted Kremenek8f5aab62008-11-11 17:42:10 +0000195}
196
197
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000198void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
Ted Kremenek5e2b6092008-01-17 17:50:49 +0000199 Expr *E = U->getSubExpr();
Ted Kremenekbcb07d52007-09-28 21:29:33 +0000200
Ted Kremenek27b07c52007-09-06 21:26:58 +0000201 switch (U->getOpcode()) {
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000202 case UnaryOperator::PostInc:
203 case UnaryOperator::PostDec:
204 case UnaryOperator::PreInc:
205 case UnaryOperator::PreDec:
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000206 // Walk through the subexpressions, blasting through ParenExprs
207 // until we either find a DeclRefExpr or some non-DeclRefExpr
208 // expression.
Ted Kremenek56206312008-02-22 00:34:10 +0000209 if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParens()))
Ted Kremenekdace4c92008-04-15 04:08:54 +0000210 if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl())) {
211 // Treat the --/++ operator as a kill.
Ted Kremenek56206312008-02-22 00:34:10 +0000212 if (AD.Observer) { AD.Observer->ObserverKill(DR); }
Ted Kremenekdace4c92008-04-15 04:08:54 +0000213 LiveState(VD, AD) = Alive;
Ted Kremenek56206312008-02-22 00:34:10 +0000214 return VisitDeclRefExpr(DR);
215 }
Ted Kremenekbcb07d52007-09-28 21:29:33 +0000216
217 // Fall-through.
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000218
219 default:
Ted Kremenek5e2b6092008-01-17 17:50:49 +0000220 return Visit(E);
Ted Kremenek27b07c52007-09-06 21:26:58 +0000221 }
222}
Ted Kremenekbcb07d52007-09-28 21:29:33 +0000223
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000224void TransferFuncs::VisitAssign(BinaryOperator* B) {
Ted Kremenek5e2b6092008-01-17 17:50:49 +0000225 Expr* LHS = B->getLHS();
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000226
Ted Kremenekbcb07d52007-09-28 21:29:33 +0000227 // Assigning to a variable?
Ted Kremenek5e2b6092008-01-17 17:50:49 +0000228 if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS->IgnoreParens())) {
Ted Kremenek7deed0c2008-04-15 18:35:30 +0000229
230 // Update liveness inforamtion.
231 unsigned bit = AD.getIdx(DR->getDecl());
232 LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
233
Ted Kremenekf63aa452007-09-28 20:38:59 +0000234 if (AD.Observer) { AD.Observer->ObserverKill(DR); }
235
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000236 // Handle things like +=, etc., which also generate "uses"
237 // of a variable. Do this just by visiting the subexpression.
Ted Kremenekbcb07d52007-09-28 21:29:33 +0000238 if (B->getOpcode() != BinaryOperator::Assign)
239 VisitDeclRefExpr(DR);
Ted Kremeneke4e63342007-09-06 00:17:54 +0000240 }
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000241 else // Not assigning to a variable. Process LHS as usual.
Ted Kremenek27b07c52007-09-06 21:26:58 +0000242 Visit(LHS);
Ted Kremeneke4e63342007-09-06 00:17:54 +0000243
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000244 Visit(B->getRHS());
Ted Kremeneke4e63342007-09-06 00:17:54 +0000245}
246
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000247void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
248 // Declarations effectively "kill" a variable since they cannot
249 // possibly be live before they are declared.
Ted Kremenek14f8b4f2008-08-05 20:46:55 +0000250 for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE = DS->decl_end();
251 DI != DE; ++DI)
252 if (VarDecl* VD = dyn_cast<VarDecl>(*DI)) {
Ted Kremenek84fa6b92008-09-26 05:52:45 +0000253 // The initializer is evaluated after the variable comes into scope.
254 // Since this is a reverse dataflow analysis, we must evaluate the
255 // transfer function for this expression first.
Ted Kremenek2bca5e42008-02-07 02:38:55 +0000256 if (Expr* Init = VD->getInit())
257 Visit(Init);
Ted Kremenek84fa6b92008-09-26 05:52:45 +0000258
Ted Kremeneke0dbda12008-12-09 00:14:14 +0000259 if (const VariableArrayType* VT =
260 AD.getContext().getAsVariableArrayType(VD->getType())) {
261 StmtIterator I(const_cast<VariableArrayType*>(VT));
262 StmtIterator E;
263 for (; I != E; ++I) Visit(*I);
264 }
265
Ted Kremenek84fa6b92008-09-26 05:52:45 +0000266 // Update liveness information by killing the VarDecl.
267 unsigned bit = AD.getIdx(VD);
268 LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
Ted Kremenekdcc48102008-02-25 22:28:54 +0000269 }
Ted Kremenek27b07c52007-09-06 21:26:58 +0000270}
Ted Kremenekf63aa452007-09-28 20:38:59 +0000271
Ted Kremeneke4e63342007-09-06 00:17:54 +0000272} // end anonymous namespace
273
Ted Kremenekf63aa452007-09-28 20:38:59 +0000274//===----------------------------------------------------------------------===//
275// Merge operator: if something is live on any successor block, it is live
276// in the current block (a set union).
277//===----------------------------------------------------------------------===//
Ted Kremeneke4e63342007-09-06 00:17:54 +0000278
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000279namespace {
Ted Kremenekfa59f1f2008-03-20 21:46:49 +0000280
281struct Merge {
Ted Kremenek8d798c72008-11-14 01:14:18 +0000282 typedef StmtDeclBitVector_Types::ValTy ValTy;
Ted Kremenekfa59f1f2008-03-20 21:46:49 +0000283
284 void operator()(ValTy& Dst, const ValTy& Src) {
285 Dst.OrDeclBits(Src);
Ted Kremenekbf98c992009-01-30 21:35:30 +0000286 Dst.OrBlkExprBits(Src);
Ted Kremenekfa59f1f2008-03-20 21:46:49 +0000287 }
288};
289
290typedef DataflowSolver<LiveVariables, TransferFuncs, Merge> Solver;
Ted Kremenekf63aa452007-09-28 20:38:59 +0000291} // end anonymous namespace
292
293//===----------------------------------------------------------------------===//
294// External interface to run Liveness analysis.
295//===----------------------------------------------------------------------===//
Ted Kremeneke4e63342007-09-06 00:17:54 +0000296
Ted Kremenek83c01da2008-01-11 00:40:29 +0000297void LiveVariables::runOnCFG(CFG& cfg) {
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000298 Solver S(*this);
299 S.runOnCFG(cfg);
300}
Ted Kremenek27b07c52007-09-06 21:26:58 +0000301
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000302void LiveVariables::runOnAllBlocks(const CFG& cfg,
Ted Kremenek79649df2008-01-17 18:25:22 +0000303 LiveVariables::ObserverTy* Obs,
304 bool recordStmtValues) {
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000305 Solver S(*this);
306 ObserverTy* OldObserver = getAnalysisData().Observer;
Ted Kremenek79649df2008-01-17 18:25:22 +0000307 getAnalysisData().Observer = Obs;
308 S.runOnAllBlocks(cfg, recordStmtValues);
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000309 getAnalysisData().Observer = OldObserver;
Ted Kremenek27b07c52007-09-06 21:26:58 +0000310}
311
312//===----------------------------------------------------------------------===//
313// liveness queries
314//
315
Ted Kremenekc0576ca2007-09-10 17:36:42 +0000316bool LiveVariables::isLive(const CFGBlock* B, const VarDecl* D) const {
Ted Kremenek7cb15932008-03-13 16:55:07 +0000317 DeclBitVector_Types::Idx i = getAnalysisData().getIdx(D);
318 return i.isValid() ? getBlockData(B).getBit(i) : false;
Ted Kremenek27b07c52007-09-06 21:26:58 +0000319}
320
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000321bool LiveVariables::isLive(const ValTy& Live, const VarDecl* D) const {
Ted Kremenek7cb15932008-03-13 16:55:07 +0000322 DeclBitVector_Types::Idx i = getAnalysisData().getIdx(D);
323 return i.isValid() ? Live.getBit(i) : false;
Ted Kremenek055c2752007-09-06 23:00:42 +0000324}
325
Ted Kremenek86946742008-01-17 20:48:37 +0000326bool LiveVariables::isLive(const Stmt* Loc, const Stmt* StmtVal) const {
327 return getStmtData(Loc)(StmtVal,getAnalysisData());
328}
329
Ted Kremenek2a9da9c2008-01-18 00:40:21 +0000330bool LiveVariables::isLive(const Stmt* Loc, const VarDecl* D) const {
331 return getStmtData(Loc)(D,getAnalysisData());
332}
333
Ted Kremenek055c2752007-09-06 23:00:42 +0000334//===----------------------------------------------------------------------===//
Ted Kremeneke4e63342007-09-06 00:17:54 +0000335// printing liveness state for debugging
336//
337
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000338void LiveVariables::dumpLiveness(const ValTy& V, SourceManager& SM) const {
339 const AnalysisDataTy& AD = getAnalysisData();
340
Ted Kremenekf63aa452007-09-28 20:38:59 +0000341 for (AnalysisDataTy::decl_iterator I = AD.begin_decl(),
342 E = AD.end_decl(); I!=E; ++I)
343 if (V.getDeclBit(I->second)) {
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000344 fprintf(stderr, " %s <", I->first->getIdentifier()->getName());
345 I->first->getLocation().dump(SM);
346 fprintf(stderr, ">\n");
Ted Kremeneke4e63342007-09-06 00:17:54 +0000347 }
Ted Kremeneke4e63342007-09-06 00:17:54 +0000348}
349
Ted Kremenek27b07c52007-09-06 21:26:58 +0000350void LiveVariables::dumpBlockLiveness(SourceManager& M) const {
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000351 for (BlockDataMapTy::iterator I = getBlockDataMap().begin(),
352 E = getBlockDataMap().end(); I!=E; ++I) {
353 fprintf(stderr, "\n[ B%d (live variables at block exit) ]\n",
Ted Kremenek27b07c52007-09-06 21:26:58 +0000354 I->first->getBlockID());
355
356 dumpLiveness(I->second,M);
357 }
Ted Kremenekc0576ca2007-09-10 17:36:42 +0000358
359 fprintf(stderr,"\n");
360}