UninitializedValues.h revision 9e7617220135a6f6226cf09cb242cc1b905aedb4
1//= UninitializedValues.h - Finding uses of uninitialized values --*- C++ -*-==//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines APIs for invoking and reported uninitialized values
11// warnings.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_UNINIT_VALS_H
16#define LLVM_CLANG_UNINIT_VALS_H
17
18namespace clang {
19
20class AnalysisContext;
21class CFG;
22class DeclContext;
23class Expr;
24class VarDecl;
25
26class UninitVariablesHandler {
27public:
28  UninitVariablesHandler() {}
29  virtual ~UninitVariablesHandler();
30
31  /// Called when the uninitialized variable is used at the given expression.
32  virtual void handleUseOfUninitVariable(const Expr *ex,
33                                         const VarDecl *vd,
34                                         bool isAlwaysUninit) {}
35
36  /// Called when the uninitialized variable analysis detects the
37  /// idiom 'int x = x'.  All other uses of 'x' within the initializer
38  /// are handled by handleUseOfUninitVariable.
39  virtual void handleSelfInit(const VarDecl *vd) {}
40};
41
42struct UninitVariablesAnalysisStats {
43  unsigned NumVariablesAnalyzed;
44  unsigned NumBlockVisits;
45};
46
47void runUninitializedVariablesAnalysis(const DeclContext &dc, const CFG &cfg,
48                                       AnalysisContext &ac,
49                                       UninitVariablesHandler &handler,
50                                       UninitVariablesAnalysisStats &stats);
51
52}
53#endif
54