clang  6.0.0svn
PseudoConstantAnalysis.h
Go to the documentation of this file.
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_ANALYSES_PSEUDOCONSTANTANALYSIS_H
17 #define LLVM_CLANG_ANALYSIS_ANALYSES_PSEUDOCONSTANTANALYSIS_H
18 
19 #include "clang/AST/Stmt.h"
20 
21 namespace clang {
22 
24 public:
25  PseudoConstantAnalysis(const Stmt *DeclBody);
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
Stmt - This represents one statement.
Definition: Stmt.h:66
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:806
Expr - This represents one expression.
Definition: Expr.h:106
PseudoConstantAnalysis(const Stmt *DeclBody)
bool wasReferenced(const VarDecl *VD)
Dataflow Directional Tag Classes.
bool isPseudoConstant(const VarDecl *VD)