PseudoConstantAnalysis.h revision 212795
1212795Sdim//== PseudoConstantAnalysis.h - Find Pseudo-constants in the AST -*- C++ -*-==// 2212795Sdim// 3212795Sdim// The LLVM Compiler Infrastructure 4212795Sdim// 5212795Sdim// This file is distributed under the University of Illinois Open Source 6212795Sdim// License. See LICENSE.TXT for details. 7212795Sdim// 8212795Sdim//===----------------------------------------------------------------------===// 9212795Sdim// 10212795Sdim// This file tracks the usage of variables in a Decl body to see if they are 11212795Sdim// never written to, implying that they constant. This is useful in static 12212795Sdim// analysis to see if a developer might have intended a variable to be const. 13212795Sdim// 14212795Sdim//===----------------------------------------------------------------------===// 15212795Sdim 16212795Sdim#ifndef LLVM_CLANG_ANALYSIS_PSEUDOCONSTANTANALYSIS 17212795Sdim#define LLVM_CLANG_ANALYSIS_PSEUDOCONSTANTANALYSIS 18212795Sdim 19212795Sdim#include "clang/AST/Stmt.h" 20212795Sdim 21212795Sdimnamespace clang { 22212795Sdim 23212795Sdimclass PseudoConstantAnalysis { 24212795Sdimpublic: 25212795Sdim PseudoConstantAnalysis(const Stmt *DeclBody); 26212795Sdim ~PseudoConstantAnalysis(); 27212795Sdim 28212795Sdim bool isPseudoConstant(const VarDecl *VD); 29212795Sdim bool wasReferenced(const VarDecl *VD); 30212795Sdim 31212795Sdimprivate: 32212795Sdim void RunAnalysis(); 33212795Sdim inline static const Decl *getDecl(const Expr *E); 34212795Sdim 35212795Sdim // for storing the result of analyzed ValueDecls 36212795Sdim void *NonConstantsImpl; 37212795Sdim void *UsedVarsImpl; 38212795Sdim 39212795Sdim const Stmt *DeclBody; 40212795Sdim bool Analyzed; 41212795Sdim}; 42212795Sdim 43212795Sdim} 44212795Sdim 45212795Sdim#endif 46