blob: 1b37c29990169aed67e3d1fa36add5df34a02faf [file] [log] [blame]
Ted Kremenek6f342132011-03-15 03:17:07 +00001//==- UninitializedValues.cpp - Find Uninitialized Values -------*- C++ --*-==//
Ted Kremenek610068c2011-01-15 02:58:47 +00002//
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 uninitialized values analysis for source-level CFGs.
11//
12//===----------------------------------------------------------------------===//
13
Ted Kremenek13bd4232011-01-20 17:37:17 +000014#include <utility>
Ted Kremenek610068c2011-01-15 02:58:47 +000015#include "llvm/ADT/Optional.h"
16#include "llvm/ADT/SmallVector.h"
Argyrios Kyrtzidis049f6d02011-05-31 03:56:09 +000017#include "llvm/ADT/PackedVector.h"
Ted Kremenek610068c2011-01-15 02:58:47 +000018#include "llvm/ADT/DenseMap.h"
Richard Smith558e8872012-07-13 23:33:44 +000019#include "clang/AST/ASTContext.h"
Ted Kremenek610068c2011-01-15 02:58:47 +000020#include "clang/AST/Decl.h"
21#include "clang/Analysis/CFG.h"
Ted Kremeneka8c17a52011-01-25 19:13:48 +000022#include "clang/Analysis/AnalysisContext.h"
Ted Kremenek610068c2011-01-15 02:58:47 +000023#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
Ted Kremenek6f342132011-03-15 03:17:07 +000024#include "clang/Analysis/Analyses/UninitializedValues.h"
Argyrios Kyrtzidisb2c60b02012-03-01 19:45:56 +000025#include "llvm/Support/SaveAndRestore.h"
Ted Kremenek610068c2011-01-15 02:58:47 +000026
27using namespace clang;
28
Richard Smith558e8872012-07-13 23:33:44 +000029#define DEBUG_LOGGING 0
30
Ted Kremenek40900ee2011-01-27 02:29:34 +000031static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) {
Ted Kremenek1cbc3152011-03-17 03:06:11 +000032 if (vd->isLocalVarDecl() && !vd->hasGlobalStorage() &&
Ted Kremeneka21612f2011-04-07 20:02:56 +000033 !vd->isExceptionVariable() &&
Ted Kremenek1cbc3152011-03-17 03:06:11 +000034 vd->getDeclContext() == dc) {
35 QualType ty = vd->getType();
36 return ty->isScalarType() || ty->isVectorType();
37 }
38 return false;
Ted Kremenekc104e532011-01-18 04:53:25 +000039}
40
Ted Kremenek610068c2011-01-15 02:58:47 +000041//------------------------------------------------------------------------====//
Ted Kremenek136f8f22011-03-15 04:57:27 +000042// DeclToIndex: a mapping from Decls we track to value indices.
Ted Kremenek610068c2011-01-15 02:58:47 +000043//====------------------------------------------------------------------------//
44
45namespace {
Ted Kremenek136f8f22011-03-15 04:57:27 +000046class DeclToIndex {
Ted Kremenek610068c2011-01-15 02:58:47 +000047 llvm::DenseMap<const VarDecl *, unsigned> map;
48public:
Ted Kremenek136f8f22011-03-15 04:57:27 +000049 DeclToIndex() {}
Ted Kremenek610068c2011-01-15 02:58:47 +000050
51 /// Compute the actual mapping from declarations to bits.
52 void computeMap(const DeclContext &dc);
53
54 /// Return the number of declarations in the map.
55 unsigned size() const { return map.size(); }
56
57 /// Returns the bit vector index for a given declaration.
Ted Kremenekb831c672011-03-29 01:40:00 +000058 llvm::Optional<unsigned> getValueIndex(const VarDecl *d) const;
Ted Kremenek610068c2011-01-15 02:58:47 +000059};
60}
61
Ted Kremenek136f8f22011-03-15 04:57:27 +000062void DeclToIndex::computeMap(const DeclContext &dc) {
Ted Kremenek610068c2011-01-15 02:58:47 +000063 unsigned count = 0;
64 DeclContext::specific_decl_iterator<VarDecl> I(dc.decls_begin()),
65 E(dc.decls_end());
66 for ( ; I != E; ++I) {
David Blaikie581deb32012-06-06 20:45:41 +000067 const VarDecl *vd = *I;
Ted Kremenek40900ee2011-01-27 02:29:34 +000068 if (isTrackedVar(vd, &dc))
Ted Kremenek610068c2011-01-15 02:58:47 +000069 map[vd] = count++;
70 }
71}
72
Ted Kremenekb831c672011-03-29 01:40:00 +000073llvm::Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) const {
74 llvm::DenseMap<const VarDecl *, unsigned>::const_iterator I = map.find(d);
Ted Kremenek610068c2011-01-15 02:58:47 +000075 if (I == map.end())
76 return llvm::Optional<unsigned>();
77 return I->second;
78}
79
80//------------------------------------------------------------------------====//
81// CFGBlockValues: dataflow values for CFG blocks.
82//====------------------------------------------------------------------------//
83
Ted Kremenekf7bafc72011-03-15 04:57:38 +000084// These values are defined in such a way that a merge can be done using
85// a bitwise OR.
86enum Value { Unknown = 0x0, /* 00 */
87 Initialized = 0x1, /* 01 */
88 Uninitialized = 0x2, /* 10 */
89 MayUninitialized = 0x3 /* 11 */ };
90
91static bool isUninitialized(const Value v) {
92 return v >= Uninitialized;
93}
94static bool isAlwaysUninit(const Value v) {
95 return v == Uninitialized;
96}
Ted Kremenekafb10c42011-03-15 04:57:29 +000097
Benjamin Kramerda57f3e2011-03-26 12:38:21 +000098namespace {
Ted Kremenek496398d2011-03-15 04:57:32 +000099
Argyrios Kyrtzidis049f6d02011-05-31 03:56:09 +0000100typedef llvm::PackedVector<Value, 2> ValueVector;
Ted Kremenek136f8f22011-03-15 04:57:27 +0000101typedef std::pair<ValueVector *, ValueVector *> BVPair;
Ted Kremenek13bd4232011-01-20 17:37:17 +0000102
Ted Kremenek610068c2011-01-15 02:58:47 +0000103class CFGBlockValues {
104 const CFG &cfg;
Ted Kremenek13bd4232011-01-20 17:37:17 +0000105 BVPair *vals;
Ted Kremenek136f8f22011-03-15 04:57:27 +0000106 ValueVector scratch;
Ted Kremenek4ddb3872011-03-15 05:30:12 +0000107 DeclToIndex declToIndex;
Ted Kremenek13bd4232011-01-20 17:37:17 +0000108
Ted Kremenek136f8f22011-03-15 04:57:27 +0000109 ValueVector &lazyCreate(ValueVector *&bv);
Ted Kremenek610068c2011-01-15 02:58:47 +0000110public:
111 CFGBlockValues(const CFG &cfg);
112 ~CFGBlockValues();
113
Ted Kremenekd40066b2011-04-04 23:29:12 +0000114 unsigned getNumEntries() const { return declToIndex.size(); }
115
Ted Kremenek610068c2011-01-15 02:58:47 +0000116 void computeSetOfDeclarations(const DeclContext &dc);
Ted Kremenek136f8f22011-03-15 04:57:27 +0000117 ValueVector &getValueVector(const CFGBlock *block,
Richard Smith81891882012-05-24 23:45:35 +0000118 const CFGBlock *dstBlock);
Ted Kremenek13bd4232011-01-20 17:37:17 +0000119
Ted Kremenek136f8f22011-03-15 04:57:27 +0000120 BVPair &getValueVectors(const CFGBlock *block, bool shouldLazyCreate);
Ted Kremenek13bd4232011-01-20 17:37:17 +0000121
Richard Smitha9e8b9e2012-07-02 23:23:04 +0000122 void setAllScratchValues(Value V);
Ted Kremenek136f8f22011-03-15 04:57:27 +0000123 void mergeIntoScratch(ValueVector const &source, bool isFirst);
124 bool updateValueVectorWithScratch(const CFGBlock *block);
125 bool updateValueVectors(const CFGBlock *block, const BVPair &newVals);
Ted Kremenek610068c2011-01-15 02:58:47 +0000126
127 bool hasNoDeclarations() const {
Ted Kremenek4ddb3872011-03-15 05:30:12 +0000128 return declToIndex.size() == 0;
Ted Kremenek610068c2011-01-15 02:58:47 +0000129 }
Ted Kremeneke0e29332011-08-20 01:15:28 +0000130
Ted Kremenek610068c2011-01-15 02:58:47 +0000131 void resetScratch();
Ted Kremenek136f8f22011-03-15 04:57:27 +0000132 ValueVector &getScratch() { return scratch; }
Ted Kremenek13bd4232011-01-20 17:37:17 +0000133
Ted Kremenek136f8f22011-03-15 04:57:27 +0000134 ValueVector::reference operator[](const VarDecl *vd);
Richard Smith2815e1a2012-05-25 02:17:09 +0000135
136 Value getValue(const CFGBlock *block, const CFGBlock *dstBlock,
137 const VarDecl *vd) {
138 const llvm::Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
139 assert(idx.hasValue());
140 return getValueVector(block, dstBlock)[idx.getValue()];
141 }
Ted Kremenek610068c2011-01-15 02:58:47 +0000142};
Benjamin Kramerda57f3e2011-03-26 12:38:21 +0000143} // end anonymous namespace
Ted Kremenek610068c2011-01-15 02:58:47 +0000144
145CFGBlockValues::CFGBlockValues(const CFG &c) : cfg(c), vals(0) {
146 unsigned n = cfg.getNumBlockIDs();
147 if (!n)
148 return;
Ted Kremenek136f8f22011-03-15 04:57:27 +0000149 vals = new std::pair<ValueVector*, ValueVector*>[n];
Chandler Carruth75c40642011-04-28 08:19:45 +0000150 memset((void*)vals, 0, sizeof(*vals) * n);
Ted Kremenek610068c2011-01-15 02:58:47 +0000151}
152
153CFGBlockValues::~CFGBlockValues() {
154 unsigned n = cfg.getNumBlockIDs();
155 if (n == 0)
156 return;
Ted Kremenek13bd4232011-01-20 17:37:17 +0000157 for (unsigned i = 0; i < n; ++i) {
158 delete vals[i].first;
159 delete vals[i].second;
160 }
Ted Kremenek610068c2011-01-15 02:58:47 +0000161 delete [] vals;
162}
163
164void CFGBlockValues::computeSetOfDeclarations(const DeclContext &dc) {
Ted Kremenek4ddb3872011-03-15 05:30:12 +0000165 declToIndex.computeMap(dc);
166 scratch.resize(declToIndex.size());
Ted Kremenek610068c2011-01-15 02:58:47 +0000167}
168
Ted Kremenek136f8f22011-03-15 04:57:27 +0000169ValueVector &CFGBlockValues::lazyCreate(ValueVector *&bv) {
Ted Kremenek13bd4232011-01-20 17:37:17 +0000170 if (!bv)
Ted Kremenek4ddb3872011-03-15 05:30:12 +0000171 bv = new ValueVector(declToIndex.size());
Ted Kremenek610068c2011-01-15 02:58:47 +0000172 return *bv;
173}
174
Ted Kremenek13bd4232011-01-20 17:37:17 +0000175/// This function pattern matches for a '&&' or '||' that appears at
176/// the beginning of a CFGBlock that also (1) has a terminator and
177/// (2) has no other elements. If such an expression is found, it is returned.
Ted Kremenekf1d10d92011-08-23 23:05:04 +0000178static const BinaryOperator *getLogicalOperatorInChain(const CFGBlock *block) {
Ted Kremenek13bd4232011-01-20 17:37:17 +0000179 if (block->empty())
180 return 0;
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000181
Richard Smithb86b8552012-04-30 00:16:51 +0000182 CFGElement front = block->front();
183 const CFGStmt *cstmt = front.getAs<CFGStmt>();
Ted Kremenek76709bf2011-03-15 05:22:28 +0000184 if (!cstmt)
185 return 0;
186
Ted Kremenekf1d10d92011-08-23 23:05:04 +0000187 const BinaryOperator *b = dyn_cast_or_null<BinaryOperator>(cstmt->getStmt());
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000188
189 if (!b || !b->isLogicalOp())
Ted Kremenek13bd4232011-01-20 17:37:17 +0000190 return 0;
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000191
Ted Kremeneke6c28032011-05-10 22:10:35 +0000192 if (block->pred_size() == 2) {
193 if (block->getTerminatorCondition() == b) {
194 if (block->succ_size() == 2)
195 return b;
196 }
197 else if (block->size() == 1)
198 return b;
199 }
200
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000201 return 0;
Ted Kremenek13bd4232011-01-20 17:37:17 +0000202}
203
Ted Kremenek136f8f22011-03-15 04:57:27 +0000204ValueVector &CFGBlockValues::getValueVector(const CFGBlock *block,
205 const CFGBlock *dstBlock) {
Ted Kremenek13bd4232011-01-20 17:37:17 +0000206 unsigned idx = block->getBlockID();
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000207 if (dstBlock && getLogicalOperatorInChain(block)) {
208 if (*block->succ_begin() == dstBlock)
209 return lazyCreate(vals[idx].first);
210 assert(*(block->succ_begin()+1) == dstBlock);
211 return lazyCreate(vals[idx].second);
Ted Kremenek13bd4232011-01-20 17:37:17 +0000212 }
213
214 assert(vals[idx].second == 0);
215 return lazyCreate(vals[idx].first);
216}
217
Ted Kremenek136f8f22011-03-15 04:57:27 +0000218BVPair &CFGBlockValues::getValueVectors(const clang::CFGBlock *block,
219 bool shouldLazyCreate) {
Ted Kremenek13bd4232011-01-20 17:37:17 +0000220 unsigned idx = block->getBlockID();
221 lazyCreate(vals[idx].first);
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000222 if (shouldLazyCreate)
223 lazyCreate(vals[idx].second);
Ted Kremenek13bd4232011-01-20 17:37:17 +0000224 return vals[idx];
225}
226
Richard Smith558e8872012-07-13 23:33:44 +0000227#if DEBUG_LOGGING
Ted Kremenek136f8f22011-03-15 04:57:27 +0000228static void printVector(const CFGBlock *block, ValueVector &bv,
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000229 unsigned num) {
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000230 llvm::errs() << block->getBlockID() << " :";
231 for (unsigned i = 0; i < bv.size(); ++i) {
232 llvm::errs() << ' ' << bv[i];
233 }
234 llvm::errs() << " : " << num << '\n';
235}
236#endif
Ted Kremenek610068c2011-01-15 02:58:47 +0000237
Richard Smitha9e8b9e2012-07-02 23:23:04 +0000238void CFGBlockValues::setAllScratchValues(Value V) {
239 for (unsigned I = 0, E = scratch.size(); I != E; ++I)
240 scratch[I] = V;
241}
242
Ted Kremenekc5f740e2011-10-07 00:42:48 +0000243void CFGBlockValues::mergeIntoScratch(ValueVector const &source,
244 bool isFirst) {
245 if (isFirst)
246 scratch = source;
247 else
248 scratch |= source;
249}
250
Ted Kremenek136f8f22011-03-15 04:57:27 +0000251bool CFGBlockValues::updateValueVectorWithScratch(const CFGBlock *block) {
252 ValueVector &dst = getValueVector(block, 0);
Ted Kremenek610068c2011-01-15 02:58:47 +0000253 bool changed = (dst != scratch);
254 if (changed)
255 dst = scratch;
Richard Smith558e8872012-07-13 23:33:44 +0000256#if DEBUG_LOGGING
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000257 printVector(block, scratch, 0);
258#endif
Ted Kremenek13bd4232011-01-20 17:37:17 +0000259 return changed;
260}
261
Ted Kremenek136f8f22011-03-15 04:57:27 +0000262bool CFGBlockValues::updateValueVectors(const CFGBlock *block,
Ted Kremenek13bd4232011-01-20 17:37:17 +0000263 const BVPair &newVals) {
Ted Kremenek136f8f22011-03-15 04:57:27 +0000264 BVPair &vals = getValueVectors(block, true);
Ted Kremenek13bd4232011-01-20 17:37:17 +0000265 bool changed = *newVals.first != *vals.first ||
266 *newVals.second != *vals.second;
267 *vals.first = *newVals.first;
268 *vals.second = *newVals.second;
Richard Smith558e8872012-07-13 23:33:44 +0000269#if DEBUG_LOGGING
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000270 printVector(block, *vals.first, 1);
271 printVector(block, *vals.second, 2);
272#endif
Ted Kremenek610068c2011-01-15 02:58:47 +0000273 return changed;
274}
275
276void CFGBlockValues::resetScratch() {
277 scratch.reset();
278}
279
Ted Kremenek136f8f22011-03-15 04:57:27 +0000280ValueVector::reference CFGBlockValues::operator[](const VarDecl *vd) {
Ted Kremenek4ddb3872011-03-15 05:30:12 +0000281 const llvm::Optional<unsigned> &idx = declToIndex.getValueIndex(vd);
Ted Kremenek610068c2011-01-15 02:58:47 +0000282 assert(idx.hasValue());
283 return scratch[idx.getValue()];
284}
285
286//------------------------------------------------------------------------====//
287// Worklist: worklist for dataflow analysis.
288//====------------------------------------------------------------------------//
289
290namespace {
291class DataflowWorklist {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000292 SmallVector<const CFGBlock *, 20> worklist;
Ted Kremenek496398d2011-03-15 04:57:32 +0000293 llvm::BitVector enqueuedBlocks;
Ted Kremenek610068c2011-01-15 02:58:47 +0000294public:
295 DataflowWorklist(const CFG &cfg) : enqueuedBlocks(cfg.getNumBlockIDs()) {}
296
Ted Kremenek610068c2011-01-15 02:58:47 +0000297 void enqueueSuccessors(const CFGBlock *block);
298 const CFGBlock *dequeue();
Ted Kremenek610068c2011-01-15 02:58:47 +0000299};
300}
301
Ted Kremenek610068c2011-01-15 02:58:47 +0000302void DataflowWorklist::enqueueSuccessors(const clang::CFGBlock *block) {
Chandler Carruth80520502011-07-08 11:19:06 +0000303 unsigned OldWorklistSize = worklist.size();
Ted Kremenek610068c2011-01-15 02:58:47 +0000304 for (CFGBlock::const_succ_iterator I = block->succ_begin(),
305 E = block->succ_end(); I != E; ++I) {
Chandler Carruth80520502011-07-08 11:19:06 +0000306 const CFGBlock *Successor = *I;
307 if (!Successor || enqueuedBlocks[Successor->getBlockID()])
308 continue;
309 worklist.push_back(Successor);
310 enqueuedBlocks[Successor->getBlockID()] = true;
Ted Kremenek610068c2011-01-15 02:58:47 +0000311 }
Chandler Carruth80520502011-07-08 11:19:06 +0000312 if (OldWorklistSize == 0 || OldWorklistSize == worklist.size())
313 return;
314
315 // Rotate the newly added blocks to the start of the worklist so that it forms
316 // a proper queue when we pop off the end of the worklist.
317 std::rotate(worklist.begin(), worklist.begin() + OldWorklistSize,
318 worklist.end());
Ted Kremenek610068c2011-01-15 02:58:47 +0000319}
320
321const CFGBlock *DataflowWorklist::dequeue() {
322 if (worklist.empty())
323 return 0;
324 const CFGBlock *b = worklist.back();
325 worklist.pop_back();
326 enqueuedBlocks[b->getBlockID()] = false;
327 return b;
328}
329
330//------------------------------------------------------------------------====//
Richard Smith9532e0d2012-07-17 00:06:14 +0000331// Classification of DeclRefExprs as use or initialization.
Ted Kremenek610068c2011-01-15 02:58:47 +0000332//====------------------------------------------------------------------------//
333
Ted Kremenek610068c2011-01-15 02:58:47 +0000334namespace {
335class FindVarResult {
336 const VarDecl *vd;
337 const DeclRefExpr *dr;
338public:
Richard Smith9532e0d2012-07-17 00:06:14 +0000339 FindVarResult(const VarDecl *vd, const DeclRefExpr *dr) : vd(vd), dr(dr) {}
340
Ted Kremenek610068c2011-01-15 02:58:47 +0000341 const DeclRefExpr *getDeclRefExpr() const { return dr; }
342 const VarDecl *getDecl() const { return vd; }
343};
Richard Smith9532e0d2012-07-17 00:06:14 +0000344
345static const Expr *stripCasts(ASTContext &C, const Expr *Ex) {
346 while (Ex) {
347 Ex = Ex->IgnoreParenNoopCasts(C);
348 if (const CastExpr *CE = dyn_cast<CastExpr>(Ex)) {
349 if (CE->getCastKind() == CK_LValueBitCast) {
350 Ex = CE->getSubExpr();
351 continue;
352 }
353 }
354 break;
355 }
356 return Ex;
357}
358
359/// If E is an expression comprising a reference to a single variable, find that
360/// variable.
361static FindVarResult findVar(const Expr *E, const DeclContext *DC) {
362 if (const DeclRefExpr *DRE =
363 dyn_cast<DeclRefExpr>(stripCasts(DC->getParentASTContext(), E)))
364 if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()))
365 if (isTrackedVar(VD, DC))
366 return FindVarResult(VD, DRE);
367 return FindVarResult(0, 0);
368}
369
370/// \brief Classify each DeclRefExpr as an initialization or a use. Any
371/// DeclRefExpr which isn't explicitly classified will be assumed to have
372/// escaped the analysis and will be treated as an initialization.
373class ClassifyRefs : public StmtVisitor<ClassifyRefs> {
374public:
375 enum Class {
376 Init,
377 Use,
378 SelfInit,
379 Ignore
380 };
381
382private:
383 const DeclContext *DC;
384 llvm::DenseMap<const DeclRefExpr*, Class> Classification;
385
386 bool isTrackedVar(const VarDecl *VD) const {
387 return ::isTrackedVar(VD, DC);
388 }
389
390 void classify(const Expr *E, Class C);
391
392public:
393 ClassifyRefs(AnalysisDeclContext &AC) : DC(cast<DeclContext>(AC.getDecl())) {}
394
395 void VisitDeclStmt(DeclStmt *DS);
396 void VisitUnaryOperator(UnaryOperator *UO);
397 void VisitBinaryOperator(BinaryOperator *BO);
398 void VisitCallExpr(CallExpr *CE);
399 void VisitCastExpr(CastExpr *CE);
400
401 void operator()(Stmt *S) { Visit(S); }
402
403 Class get(const DeclRefExpr *DRE) const {
404 llvm::DenseMap<const DeclRefExpr*, Class>::const_iterator I
405 = Classification.find(DRE);
406 if (I != Classification.end())
407 return I->second;
408
409 const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl());
410 if (!VD || !isTrackedVar(VD))
411 return Ignore;
412
413 return Init;
414 }
415};
416}
417
418static const DeclRefExpr *getSelfInitExpr(VarDecl *VD) {
419 if (Expr *Init = VD->getInit()) {
420 const DeclRefExpr *DRE
421 = dyn_cast<DeclRefExpr>(stripCasts(VD->getASTContext(), Init));
422 if (DRE && DRE->getDecl() == VD)
423 return DRE;
424 }
425 return 0;
426}
427
428void ClassifyRefs::classify(const Expr *E, Class C) {
429 FindVarResult Var = findVar(E, DC);
430 if (const DeclRefExpr *DRE = Var.getDeclRefExpr())
431 Classification[DRE] = std::max(Classification[DRE], C);
432}
433
434void ClassifyRefs::VisitDeclStmt(DeclStmt *DS) {
435 for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
436 DI != DE; ++DI) {
437 VarDecl *VD = dyn_cast<VarDecl>(*DI);
438 if (VD && isTrackedVar(VD))
439 if (const DeclRefExpr *DRE = getSelfInitExpr(VD))
440 Classification[DRE] = SelfInit;
441 }
442}
443
444void ClassifyRefs::VisitBinaryOperator(BinaryOperator *BO) {
445 // Ignore the evaluation of a DeclRefExpr on the LHS of an assignment. If this
446 // is not a compound-assignment, we will treat it as initializing the variable
447 // when TransferFunctions visits it. A compound-assignment does not affect
448 // whether a variable is uninitialized, and there's no point counting it as a
449 // use.
450 if (BO->isAssignmentOp())
451 classify(BO->getLHS(), Ignore);
452}
453
454void ClassifyRefs::VisitUnaryOperator(UnaryOperator *UO) {
455 // Increment and decrement are uses despite there being no lvalue-to-rvalue
456 // conversion.
457 if (UO->isIncrementDecrementOp())
458 classify(UO->getSubExpr(), Use);
459}
460
461void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
462 // If a value is passed by const reference to a function, we should not assume
463 // that it is initialized by the call, and we conservatively do not assume
464 // that it is used.
465 for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
466 I != E; ++I)
467 if ((*I)->getType().isConstQualified() && (*I)->isGLValue())
468 classify(*I, Ignore);
469}
470
471void ClassifyRefs::VisitCastExpr(CastExpr *CE) {
472 if (CE->getCastKind() == CK_LValueToRValue)
473 classify(CE->getSubExpr(), Use);
474 else if (CStyleCastExpr *CSE = dyn_cast<CStyleCastExpr>(CE)) {
475 if (CSE->getType()->isVoidType()) {
476 // Squelch any detected load of an uninitialized value if
477 // we cast it to void.
478 // e.g. (void) x;
479 classify(CSE->getSubExpr(), Ignore);
480 }
481 }
482}
483
484//------------------------------------------------------------------------====//
485// Transfer function for uninitialized values analysis.
486//====------------------------------------------------------------------------//
487
488namespace {
Ted Kremenek0c8e5a02011-07-19 14:18:48 +0000489class TransferFunctions : public StmtVisitor<TransferFunctions> {
Ted Kremenek610068c2011-01-15 02:58:47 +0000490 CFGBlockValues &vals;
491 const CFG &cfg;
Richard Smith2815e1a2012-05-25 02:17:09 +0000492 const CFGBlock *block;
Ted Kremenek1d26f482011-10-24 01:32:45 +0000493 AnalysisDeclContext &ac;
Richard Smith9532e0d2012-07-17 00:06:14 +0000494 const ClassifyRefs &classification;
Ted Kremenek610068c2011-01-15 02:58:47 +0000495 UninitVariablesHandler *handler;
Richard Smith9532e0d2012-07-17 00:06:14 +0000496
Ted Kremenek610068c2011-01-15 02:58:47 +0000497public:
498 TransferFunctions(CFGBlockValues &vals, const CFG &cfg,
Richard Smith2815e1a2012-05-25 02:17:09 +0000499 const CFGBlock *block, AnalysisDeclContext &ac,
Richard Smith9532e0d2012-07-17 00:06:14 +0000500 const ClassifyRefs &classification,
Ted Kremenek6f275422011-09-02 19:39:26 +0000501 UninitVariablesHandler *handler)
Richard Smith9532e0d2012-07-17 00:06:14 +0000502 : vals(vals), cfg(cfg), block(block), ac(ac),
503 classification(classification), handler(handler) {}
504
Richard Smith81891882012-05-24 23:45:35 +0000505 void reportUse(const Expr *ex, const VarDecl *vd);
Ted Kremeneka8c17a52011-01-25 19:13:48 +0000506
Richard Smith9532e0d2012-07-17 00:06:14 +0000507 void VisitObjCForCollectionStmt(ObjCForCollectionStmt *FS);
Ted Kremeneka8c17a52011-01-25 19:13:48 +0000508 void VisitBlockExpr(BlockExpr *be);
Richard Smitha9e8b9e2012-07-02 23:23:04 +0000509 void VisitCallExpr(CallExpr *ce);
Ted Kremenek610068c2011-01-15 02:58:47 +0000510 void VisitDeclStmt(DeclStmt *ds);
Ted Kremenekc21fed32011-01-18 21:18:58 +0000511 void VisitDeclRefExpr(DeclRefExpr *dr);
Ted Kremenek610068c2011-01-15 02:58:47 +0000512 void VisitBinaryOperator(BinaryOperator *bo);
Richard Smith2815e1a2012-05-25 02:17:09 +0000513
Ted Kremenek40900ee2011-01-27 02:29:34 +0000514 bool isTrackedVar(const VarDecl *vd) {
515 return ::isTrackedVar(vd, cast<DeclContext>(ac.getDecl()));
516 }
Richard Smith2815e1a2012-05-25 02:17:09 +0000517
Richard Smith9532e0d2012-07-17 00:06:14 +0000518 FindVarResult findVar(const Expr *ex) {
519 return ::findVar(ex, cast<DeclContext>(ac.getDecl()));
520 }
521
Richard Smith2815e1a2012-05-25 02:17:09 +0000522 UninitUse getUninitUse(const Expr *ex, const VarDecl *vd, Value v) {
523 UninitUse Use(ex, isAlwaysUninit(v));
524
525 assert(isUninitialized(v));
526 if (Use.getKind() == UninitUse::Always)
527 return Use;
528
529 // If an edge which leads unconditionally to this use did not initialize
530 // the variable, we can say something stronger than 'may be uninitialized':
531 // we can say 'either it's used uninitialized or you have dead code'.
532 //
533 // We track the number of successors of a node which have been visited, and
534 // visit a node once we have visited all of its successors. Only edges where
535 // the variable might still be uninitialized are followed. Since a variable
536 // can't transfer from being initialized to being uninitialized, this will
537 // trace out the subgraph which inevitably leads to the use and does not
538 // initialize the variable. We do not want to skip past loops, since their
539 // non-termination might be correlated with the initialization condition.
540 //
541 // For example:
542 //
543 // void f(bool a, bool b) {
544 // block1: int n;
545 // if (a) {
546 // block2: if (b)
547 // block3: n = 1;
548 // block4: } else if (b) {
549 // block5: while (!a) {
550 // block6: do_work(&a);
551 // n = 2;
552 // }
553 // }
554 // block7: if (a)
555 // block8: g();
556 // block9: return n;
557 // }
558 //
559 // Starting from the maybe-uninitialized use in block 9:
560 // * Block 7 is not visited because we have only visited one of its two
561 // successors.
562 // * Block 8 is visited because we've visited its only successor.
563 // From block 8:
564 // * Block 7 is visited because we've now visited both of its successors.
565 // From block 7:
566 // * Blocks 1, 2, 4, 5, and 6 are not visited because we didn't visit all
567 // of their successors (we didn't visit 4, 3, 5, 6, and 5, respectively).
568 // * Block 3 is not visited because it initializes 'n'.
569 // Now the algorithm terminates, having visited blocks 7 and 8, and having
570 // found the frontier is blocks 2, 4, and 5.
571 //
572 // 'n' is definitely uninitialized for two edges into block 7 (from blocks 2
573 // and 4), so we report that any time either of those edges is taken (in
574 // each case when 'b == false'), 'n' is used uninitialized.
575 llvm::SmallVector<const CFGBlock*, 32> Queue;
576 llvm::SmallVector<unsigned, 32> SuccsVisited(cfg.getNumBlockIDs(), 0);
577 Queue.push_back(block);
578 // Specify that we've already visited all successors of the starting block.
579 // This has the dual purpose of ensuring we never add it to the queue, and
580 // of marking it as not being a candidate element of the frontier.
581 SuccsVisited[block->getBlockID()] = block->succ_size();
582 while (!Queue.empty()) {
583 const CFGBlock *B = Queue.back();
584 Queue.pop_back();
585 for (CFGBlock::const_pred_iterator I = B->pred_begin(), E = B->pred_end();
586 I != E; ++I) {
587 const CFGBlock *Pred = *I;
588 if (vals.getValue(Pred, B, vd) == Initialized)
589 // This block initializes the variable.
590 continue;
591
Richard Smith558e8872012-07-13 23:33:44 +0000592 unsigned &SV = SuccsVisited[Pred->getBlockID()];
593 if (!SV) {
594 // When visiting the first successor of a block, mark all NULL
595 // successors as having been visited.
596 for (CFGBlock::const_succ_iterator SI = Pred->succ_begin(),
597 SE = Pred->succ_end();
598 SI != SE; ++SI)
599 if (!*SI)
600 ++SV;
601 }
602
603 if (++SV == Pred->succ_size())
Richard Smith2815e1a2012-05-25 02:17:09 +0000604 // All paths from this block lead to the use and don't initialize the
605 // variable.
606 Queue.push_back(Pred);
607 }
608 }
609
610 // Scan the frontier, looking for blocks where the variable was
611 // uninitialized.
612 for (CFG::const_iterator BI = cfg.begin(), BE = cfg.end(); BI != BE; ++BI) {
613 const CFGBlock *Block = *BI;
614 unsigned BlockID = Block->getBlockID();
615 const Stmt *Term = Block->getTerminator();
616 if (SuccsVisited[BlockID] && SuccsVisited[BlockID] < Block->succ_size() &&
617 Term) {
618 // This block inevitably leads to the use. If we have an edge from here
619 // to a post-dominator block, and the variable is uninitialized on that
620 // edge, we have found a bug.
621 for (CFGBlock::const_succ_iterator I = Block->succ_begin(),
622 E = Block->succ_end(); I != E; ++I) {
623 const CFGBlock *Succ = *I;
624 if (Succ && SuccsVisited[Succ->getBlockID()] >= Succ->succ_size() &&
625 vals.getValue(Block, Succ, vd) == Uninitialized) {
626 // Switch cases are a special case: report the label to the caller
627 // as the 'terminator', not the switch statement itself. Suppress
628 // situations where no label matched: we can't be sure that's
629 // possible.
630 if (isa<SwitchStmt>(Term)) {
631 const Stmt *Label = Succ->getLabel();
632 if (!Label || !isa<SwitchCase>(Label))
633 // Might not be possible.
634 continue;
635 UninitUse::Branch Branch;
636 Branch.Terminator = Label;
637 Branch.Output = 0; // Ignored.
638 Use.addUninitBranch(Branch);
639 } else {
640 UninitUse::Branch Branch;
641 Branch.Terminator = Term;
642 Branch.Output = I - Block->succ_begin();
643 Use.addUninitBranch(Branch);
644 }
645 }
646 }
647 }
648 }
649
650 return Use;
651 }
Ted Kremenek610068c2011-01-15 02:58:47 +0000652};
653}
654
Richard Smith81891882012-05-24 23:45:35 +0000655void TransferFunctions::reportUse(const Expr *ex, const VarDecl *vd) {
656 if (!handler)
657 return;
658 Value v = vals[vd];
659 if (isUninitialized(v))
Richard Smith2815e1a2012-05-25 02:17:09 +0000660 handler->handleUseOfUninitVariable(vd, getUninitUse(ex, vd, v));
Ted Kremenek610068c2011-01-15 02:58:47 +0000661}
662
Richard Smith9532e0d2012-07-17 00:06:14 +0000663void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *FS) {
Ted Kremenek1ea800c2011-01-27 02:01:31 +0000664 // This represents an initialization of the 'element' value.
Richard Smith9532e0d2012-07-17 00:06:14 +0000665 if (DeclStmt *DS = dyn_cast<DeclStmt>(FS->getElement())) {
666 const VarDecl *VD = cast<VarDecl>(DS->getSingleDecl());
667 if (isTrackedVar(VD))
668 vals[VD] = Initialized;
Ted Kremenek1ea800c2011-01-27 02:01:31 +0000669 }
Ted Kremenek1ea800c2011-01-27 02:01:31 +0000670}
671
Ted Kremeneka8c17a52011-01-25 19:13:48 +0000672void TransferFunctions::VisitBlockExpr(BlockExpr *be) {
Ted Kremenekbc8b44c2011-03-31 22:32:41 +0000673 const BlockDecl *bd = be->getBlockDecl();
674 for (BlockDecl::capture_const_iterator i = bd->capture_begin(),
675 e = bd->capture_end() ; i != e; ++i) {
676 const VarDecl *vd = i->getVariable();
Ted Kremenekbc8b44c2011-03-31 22:32:41 +0000677 if (!isTrackedVar(vd))
678 continue;
679 if (i->isByRef()) {
680 vals[vd] = Initialized;
681 continue;
682 }
Richard Smith81891882012-05-24 23:45:35 +0000683 reportUse(be, vd);
Ted Kremeneka8c17a52011-01-25 19:13:48 +0000684 }
685}
686
Richard Smitha9e8b9e2012-07-02 23:23:04 +0000687void TransferFunctions::VisitCallExpr(CallExpr *ce) {
688 // After a call to a function like setjmp or vfork, any variable which is
689 // initialized anywhere within this function may now be initialized. For now,
690 // just assume such a call initializes all variables.
691 // FIXME: Only mark variables as initialized if they have an initializer which
692 // is reachable from here.
693 Decl *Callee = ce->getCalleeDecl();
694 if (Callee && Callee->hasAttr<ReturnsTwiceAttr>())
695 vals.setAllScratchValues(Initialized);
696}
697
Ted Kremenek0c8e5a02011-07-19 14:18:48 +0000698void TransferFunctions::VisitDeclRefExpr(DeclRefExpr *dr) {
Richard Smith9532e0d2012-07-17 00:06:14 +0000699 switch (classification.get(dr)) {
700 case ClassifyRefs::Ignore:
701 break;
702 case ClassifyRefs::Use:
703 reportUse(dr, cast<VarDecl>(dr->getDecl()));
704 break;
705 case ClassifyRefs::Init:
706 vals[cast<VarDecl>(dr->getDecl())] = Initialized;
707 break;
708 case ClassifyRefs::SelfInit:
709 if (handler)
710 handler->handleSelfInit(cast<VarDecl>(dr->getDecl()));
711 break;
712 }
Ted Kremenek0c8e5a02011-07-19 14:18:48 +0000713}
714
Richard Smith9532e0d2012-07-17 00:06:14 +0000715void TransferFunctions::VisitBinaryOperator(BinaryOperator *BO) {
716 if (BO->getOpcode() == BO_Assign) {
717 FindVarResult Var = findVar(BO->getLHS());
718 if (const VarDecl *VD = Var.getDecl())
719 vals[VD] = Initialized;
720 }
721}
722
723void TransferFunctions::VisitDeclStmt(DeclStmt *DS) {
724 for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
Ted Kremenek610068c2011-01-15 02:58:47 +0000725 DI != DE; ++DI) {
Richard Smith9532e0d2012-07-17 00:06:14 +0000726 VarDecl *VD = dyn_cast<VarDecl>(*DI);
727 if (VD && isTrackedVar(VD)) {
728 if (getSelfInitExpr(VD)) {
729 // If the initializer consists solely of a reference to itself, we
730 // explicitly mark the variable as uninitialized. This allows code
731 // like the following:
732 //
733 // int x = x;
734 //
735 // to deliberately leave a variable uninitialized. Different analysis
736 // clients can detect this pattern and adjust their reporting
737 // appropriately, but we need to continue to analyze subsequent uses
738 // of the variable.
739 vals[VD] = Uninitialized;
740 } else if (VD->getInit()) {
741 // Treat the new variable as initialized.
742 vals[VD] = Initialized;
743 } else {
744 // No initializer: the variable is now uninitialized. This matters
745 // for cases like:
746 // while (...) {
747 // int n;
748 // use(n);
749 // n = 0;
750 // }
751 // FIXME: Mark the variable as uninitialized whenever its scope is
752 // left, since its scope could be re-entered by a jump over the
753 // declaration.
754 vals[VD] = Uninitialized;
Ted Kremenekc21fed32011-01-18 21:18:58 +0000755 }
Ted Kremenek610068c2011-01-15 02:58:47 +0000756 }
757 }
758}
759
Ted Kremenek610068c2011-01-15 02:58:47 +0000760//------------------------------------------------------------------------====//
761// High-level "driver" logic for uninitialized values analysis.
762//====------------------------------------------------------------------------//
763
Ted Kremenek13bd4232011-01-20 17:37:17 +0000764static bool runOnBlock(const CFGBlock *block, const CFG &cfg,
Ted Kremenek1d26f482011-10-24 01:32:45 +0000765 AnalysisDeclContext &ac, CFGBlockValues &vals,
Richard Smith9532e0d2012-07-17 00:06:14 +0000766 const ClassifyRefs &classification,
Ted Kremenekf8adeef2011-04-04 20:30:58 +0000767 llvm::BitVector &wasAnalyzed,
Ted Kremenek6f275422011-09-02 19:39:26 +0000768 UninitVariablesHandler *handler = 0) {
Ted Kremenek13bd4232011-01-20 17:37:17 +0000769
Ted Kremenekf8adeef2011-04-04 20:30:58 +0000770 wasAnalyzed[block->getBlockID()] = true;
771
Ted Kremenek13bd4232011-01-20 17:37:17 +0000772 if (const BinaryOperator *b = getLogicalOperatorInChain(block)) {
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000773 CFGBlock::const_pred_iterator itr = block->pred_begin();
Ted Kremenek136f8f22011-03-15 04:57:27 +0000774 BVPair vA = vals.getValueVectors(*itr, false);
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000775 ++itr;
Ted Kremenek136f8f22011-03-15 04:57:27 +0000776 BVPair vB = vals.getValueVectors(*itr, false);
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000777
778 BVPair valsAB;
779
780 if (b->getOpcode() == BO_LAnd) {
781 // Merge the 'F' bits from the first and second.
782 vals.mergeIntoScratch(*(vA.second ? vA.second : vA.first), true);
783 vals.mergeIntoScratch(*(vB.second ? vB.second : vB.first), false);
784 valsAB.first = vA.first;
Ted Kremenek2d4bed12011-01-20 21:25:31 +0000785 valsAB.second = &vals.getScratch();
Chad Rosier30601782011-08-17 23:08:45 +0000786 } else {
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000787 // Merge the 'T' bits from the first and second.
788 assert(b->getOpcode() == BO_LOr);
789 vals.mergeIntoScratch(*vA.first, true);
790 vals.mergeIntoScratch(*vB.first, false);
791 valsAB.first = &vals.getScratch();
792 valsAB.second = vA.second ? vA.second : vA.first;
793 }
Ted Kremenek136f8f22011-03-15 04:57:27 +0000794 return vals.updateValueVectors(block, valsAB);
Ted Kremenek13bd4232011-01-20 17:37:17 +0000795 }
796
Ted Kremenek9fcbcee2011-02-01 17:43:18 +0000797 // Default behavior: merge in values of predecessor blocks.
Ted Kremenek610068c2011-01-15 02:58:47 +0000798 vals.resetScratch();
799 bool isFirst = true;
800 for (CFGBlock::const_pred_iterator I = block->pred_begin(),
801 E = block->pred_end(); I != E; ++I) {
Ted Kremenek6f275422011-09-02 19:39:26 +0000802 const CFGBlock *pred = *I;
803 if (wasAnalyzed[pred->getBlockID()]) {
804 vals.mergeIntoScratch(vals.getValueVector(pred, block), isFirst);
805 isFirst = false;
806 }
Ted Kremenek610068c2011-01-15 02:58:47 +0000807 }
808 // Apply the transfer function.
Richard Smith9532e0d2012-07-17 00:06:14 +0000809 TransferFunctions tf(vals, cfg, block, ac, classification, handler);
Ted Kremenek610068c2011-01-15 02:58:47 +0000810 for (CFGBlock::const_iterator I = block->begin(), E = block->end();
811 I != E; ++I) {
812 if (const CFGStmt *cs = dyn_cast<CFGStmt>(&*I)) {
Ted Kremenekf1d10d92011-08-23 23:05:04 +0000813 tf.Visit(const_cast<Stmt*>(cs->getStmt()));
Ted Kremenek610068c2011-01-15 02:58:47 +0000814 }
815 }
Ted Kremenek136f8f22011-03-15 04:57:27 +0000816 return vals.updateValueVectorWithScratch(block);
Ted Kremenek610068c2011-01-15 02:58:47 +0000817}
818
Chandler Carruth5d989942011-07-06 16:21:37 +0000819void clang::runUninitializedVariablesAnalysis(
820 const DeclContext &dc,
821 const CFG &cfg,
Ted Kremenek1d26f482011-10-24 01:32:45 +0000822 AnalysisDeclContext &ac,
Chandler Carruth5d989942011-07-06 16:21:37 +0000823 UninitVariablesHandler &handler,
824 UninitVariablesAnalysisStats &stats) {
Ted Kremenek610068c2011-01-15 02:58:47 +0000825 CFGBlockValues vals(cfg);
826 vals.computeSetOfDeclarations(dc);
827 if (vals.hasNoDeclarations())
828 return;
Richard Smith558e8872012-07-13 23:33:44 +0000829#if DEBUG_LOGGING
Richard Smith81891882012-05-24 23:45:35 +0000830 cfg.dump(dc.getParentASTContext().getLangOpts(), true);
831#endif
Ted Kremenekd40066b2011-04-04 23:29:12 +0000832
Chandler Carruth5d989942011-07-06 16:21:37 +0000833 stats.NumVariablesAnalyzed = vals.getNumEntries();
834
Richard Smith9532e0d2012-07-17 00:06:14 +0000835 // Precompute which expressions are uses and which are initializations.
836 ClassifyRefs classification(ac);
837 cfg.VisitBlockStmts(classification);
838
Ted Kremenekd40066b2011-04-04 23:29:12 +0000839 // Mark all variables uninitialized at the entry.
840 const CFGBlock &entry = cfg.getEntry();
841 for (CFGBlock::const_succ_iterator i = entry.succ_begin(),
842 e = entry.succ_end(); i != e; ++i) {
843 if (const CFGBlock *succ = *i) {
844 ValueVector &vec = vals.getValueVector(&entry, succ);
845 const unsigned n = vals.getNumEntries();
846 for (unsigned j = 0; j < n ; ++j) {
847 vec[j] = Uninitialized;
848 }
849 }
850 }
851
852 // Proceed with the workist.
Ted Kremenek610068c2011-01-15 02:58:47 +0000853 DataflowWorklist worklist(cfg);
Ted Kremenek496398d2011-03-15 04:57:32 +0000854 llvm::BitVector previouslyVisited(cfg.getNumBlockIDs());
Ted Kremenek610068c2011-01-15 02:58:47 +0000855 worklist.enqueueSuccessors(&cfg.getEntry());
Ted Kremenekf8adeef2011-04-04 20:30:58 +0000856 llvm::BitVector wasAnalyzed(cfg.getNumBlockIDs(), false);
Ted Kremenek6f275422011-09-02 19:39:26 +0000857 wasAnalyzed[cfg.getEntry().getBlockID()] = true;
Ted Kremenek610068c2011-01-15 02:58:47 +0000858
859 while (const CFGBlock *block = worklist.dequeue()) {
Ted Kremenek610068c2011-01-15 02:58:47 +0000860 // Did the block change?
Richard Smith9532e0d2012-07-17 00:06:14 +0000861 bool changed = runOnBlock(block, cfg, ac, vals,
862 classification, wasAnalyzed);
Chandler Carruth5d989942011-07-06 16:21:37 +0000863 ++stats.NumBlockVisits;
Ted Kremenek610068c2011-01-15 02:58:47 +0000864 if (changed || !previouslyVisited[block->getBlockID()])
865 worklist.enqueueSuccessors(block);
866 previouslyVisited[block->getBlockID()] = true;
867 }
868
869 // Run through the blocks one more time, and report uninitialized variabes.
870 for (CFG::const_iterator BI = cfg.begin(), BE = cfg.end(); BI != BE; ++BI) {
Ted Kremenek6f275422011-09-02 19:39:26 +0000871 const CFGBlock *block = *BI;
872 if (wasAnalyzed[block->getBlockID()]) {
Richard Smith9532e0d2012-07-17 00:06:14 +0000873 runOnBlock(block, cfg, ac, vals, classification, wasAnalyzed, &handler);
Chandler Carruth5d989942011-07-06 16:21:37 +0000874 ++stats.NumBlockVisits;
875 }
Ted Kremenek610068c2011-01-15 02:58:47 +0000876 }
877}
878
879UninitVariablesHandler::~UninitVariablesHandler() {}