clang API Documentation
00001 //= UninitializedValues.h - Finding uses of uninitialized values -*- C++ -*-==// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines APIs for invoking and reported uninitialized values 00011 // warnings. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CLANG_UNINIT_VALS_H 00016 #define LLVM_CLANG_UNINIT_VALS_H 00017 00018 namespace clang { 00019 00020 class AnalysisDeclContext; 00021 class CFG; 00022 class DeclContext; 00023 class Expr; 00024 class VarDecl; 00025 00026 class UninitVariablesHandler { 00027 public: 00028 UninitVariablesHandler() {} 00029 virtual ~UninitVariablesHandler(); 00030 00031 /// Called when the uninitialized variable is used at the given expression. 00032 virtual void handleUseOfUninitVariable(const Expr *ex, 00033 const VarDecl *vd, 00034 bool isAlwaysUninit) {} 00035 00036 /// Called when the uninitialized variable analysis detects the 00037 /// idiom 'int x = x'. All other uses of 'x' within the initializer 00038 /// are handled by handleUseOfUninitVariable. 00039 virtual void handleSelfInit(const VarDecl *vd) {} 00040 }; 00041 00042 struct UninitVariablesAnalysisStats { 00043 unsigned NumVariablesAnalyzed; 00044 unsigned NumBlockVisits; 00045 }; 00046 00047 void runUninitializedVariablesAnalysis(const DeclContext &dc, const CFG &cfg, 00048 AnalysisDeclContext &ac, 00049 UninitVariablesHandler &handler, 00050 UninitVariablesAnalysisStats &stats); 00051 00052 } 00053 #endif