AnalysisBasedWarnings.h revision 3ed6fc08a9cd293d012fa49ab2a615e618d7c3fa
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
20namespace clang {
21
22class BlockExpr;
23class Decl;
24class FunctionDecl;
25class ObjCMethodDecl;
26class QualType;
27class Sema;
28
29namespace sema {
30
31class AnalysisBasedWarnings {
32public:
33  class Policy {
34    friend class AnalysisBasedWarnings;
35    // The warnings to run.
36    unsigned enableCheckFallThrough : 1;
37    unsigned enableCheckUnreachable : 1;
38  public:
39    Policy();
40    void disableCheckFallThrough() { enableCheckFallThrough = 0; }
41  };
42
43private:
44  Sema &S;
45  Policy DefaultPolicy;
46
47  enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
48  llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
49
50
51public:
52  AnalysisBasedWarnings(Sema &s);
53
54  void IssueWarnings(Policy P, const Decl *D, const BlockExpr *blkExpr);
55
56  Policy getDefaultPolicy() { return DefaultPolicy; }
57};
58
59}} // end namespace clang::sema
60
61#endif
62