]> granicus.if.org Git - clang/blob - include/clang/Sema/AnalysisBasedWarnings.h
Move more stuff out of Sema.h.
[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 "clang/AST/Type.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/DenseMap.h"
20
21 namespace clang {
22
23 class FunctionDecl;
24 class Sema;
25
26 namespace sema {
27
28 class AnalysisBasedWarnings {
29 public:
30   class Policy {
31     friend class AnalysisBasedWarnings;
32     // The warnings to run.
33     unsigned enableCheckFallThrough : 1;
34     unsigned enableCheckUnreachable : 1;
35   public:
36     Policy();
37     void disableCheckFallThrough() { enableCheckFallThrough = 0; }
38   };
39
40 private:
41   Sema &S;
42   Policy DefaultPolicy;
43
44   enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
45   llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
46
47 public:
48   AnalysisBasedWarnings(Sema &s);
49
50   Policy getDefaultPolicy() { return DefaultPolicy; }
51
52   void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType());
53 };
54
55 }} // end namespace clang::sema
56
57 #endif