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 18 namespace clang { 19 20 class AnalysisDeclContext; 21 class CFG; 22 class DeclContext; 23 class Expr; 24 class VarDecl; 25 26 class UninitVariablesHandler { 27 public: 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 42 struct UninitVariablesAnalysisStats { 43 unsigned NumVariablesAnalyzed; 44 unsigned NumBlockVisits; 45 }; 46 47 void runUninitializedVariablesAnalysis(const DeclContext &dc, const CFG &cfg, 48 AnalysisDeclContext &ac, 49 UninitVariablesHandler &handler, 50 UninitVariablesAnalysisStats &stats); 51 52 } 53 #endif 54