]> granicus.if.org Git - clang/blob - include/clang/Sema/AnalysisBasedWarnings.h
Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.
[clang] / include / clang / Sema / AnalysisBasedWarnings.h
1 //=- AnalysisBasedWarnings.h - Sema warnings based on libAnalysis -*- 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 defines AnalysisBasedWarnings, a worker object used by Sema
11 // that issues warnings based on dataflow-analysis.
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H
15 #define LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H
16
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/DenseMap.h"
19
20 namespace clang {
21
22 class BlockExpr;
23 class Decl;
24 class FunctionDecl;
25 class ObjCMethodDecl;
26 class QualType;
27 class Sema;
28 namespace sema {
29   class FunctionScopeInfo;
30 }
31
32 namespace sema {
33
34 class AnalysisBasedWarnings {
35 public:
36   class Policy {
37     friend class AnalysisBasedWarnings;
38     // The warnings to run.
39     unsigned enableCheckFallThrough : 1;
40     unsigned enableCheckUnreachable : 1;
41   public:
42     Policy();
43     void disableCheckFallThrough() { enableCheckFallThrough = 0; }
44   };
45
46 private:
47   Sema &S;
48   Policy DefaultPolicy;
49
50   enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
51   llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
52
53
54 public:
55   AnalysisBasedWarnings(Sema &s);
56
57   void IssueWarnings(Policy P, FunctionScopeInfo *fscope,
58                      const Decl *D, const BlockExpr *blkExpr);
59
60   Policy getDefaultPolicy() { return DefaultPolicy; }
61 };
62
63 }} // end namespace clang::sema
64
65 #endif