]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/tools/clang/include/clang/Analysis/Analyses/PseudoConstantAnalysis.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / tools / clang / include / clang / Analysis / Analyses / PseudoConstantAnalysis.h
1 //== PseudoConstantAnalysis.h - Find Pseudo-constants in the AST -*- 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 tracks the usage of variables in a Decl body to see if they are
11 // never written to, implying that they constant. This is useful in static
12 // analysis to see if a developer might have intended a variable to be const.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CLANG_ANALYSIS_PSEUDOCONSTANTANALYSIS
17 #define LLVM_CLANG_ANALYSIS_PSEUDOCONSTANTANALYSIS
18
19 #include "clang/AST/Stmt.h"
20
21 namespace clang {
22
23 class PseudoConstantAnalysis {
24 public:
25   PseudoConstantAnalysis(const Stmt *DeclBody);
26   ~PseudoConstantAnalysis();
27
28   bool isPseudoConstant(const VarDecl *VD);
29   bool wasReferenced(const VarDecl *VD);
30
31 private:
32   void RunAnalysis();
33   inline static const Decl *getDecl(const Expr *E);
34
35   // for storing the result of analyzed ValueDecls
36   void *NonConstantsImpl;
37   void *UsedVarsImpl;
38
39   const Stmt *DeclBody;
40   bool Analyzed;
41 };
42
43 }
44
45 #endif