PseudoConstantAnalysis.h revision db34ab70961ca4b24b600eb47053d7af304659f5
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
21namespace clang {
22
23class PseudoConstantAnalysis {
24public:
25  PseudoConstantAnalysis(const Stmt *DeclBody);
26  ~PseudoConstantAnalysis();
27
28  bool isPseudoConstant(const VarDecl *VD);
29
30private:
31  void RunAnalysis();
32
33  // for storing the result of analyzed ValueDecls
34  void *NonConstantsImpl;
35
36  const Stmt *DeclBody;
37  bool Analyzed;
38};
39
40}
41
42#endif
43