clang API Documentation
00001 //== PseudoConstantAnalysis.h - Find Pseudo-constants in the AST -*- 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 tracks the usage of variables in a Decl body to see if they are 00011 // never written to, implying that they constant. This is useful in static 00012 // analysis to see if a developer might have intended a variable to be const. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_PSEUDOCONSTANTANALYSIS_H 00017 #define LLVM_CLANG_ANALYSIS_ANALYSES_PSEUDOCONSTANTANALYSIS_H 00018 00019 #include "clang/AST/Stmt.h" 00020 00021 namespace clang { 00022 00023 class PseudoConstantAnalysis { 00024 public: 00025 PseudoConstantAnalysis(const Stmt *DeclBody); 00026 ~PseudoConstantAnalysis(); 00027 00028 bool isPseudoConstant(const VarDecl *VD); 00029 bool wasReferenced(const VarDecl *VD); 00030 00031 private: 00032 void RunAnalysis(); 00033 inline static const Decl *getDecl(const Expr *E); 00034 00035 // for storing the result of analyzed ValueDecls 00036 void *NonConstantsImpl; 00037 void *UsedVarsImpl; 00038 00039 const Stmt *DeclBody; 00040 bool Analyzed; 00041 }; 00042 00043 } 00044 00045 #endif