blob: dea19ba28ccfea7ffac82297a1cfc9e7dc6eebf2 [file] [log] [blame]
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +00001//=- 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
Ted Kremenekd064fdc2010-03-23 00:13:23 +000017#include "llvm/ADT/SmallVector.h"
18#include "llvm/ADT/DenseMap.h"
19
20namespace clang {
21
22class Sema;
23
24namespace sema {
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000025
26class AnalysisBasedWarnings {
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000027public:
Ted Kremenekd064fdc2010-03-23 00:13:23 +000028 class Policy {
29 friend class AnalysisBasedWarnings;
30 // The warnings to run.
31 unsigned enableCheckFallThrough : 1;
32 unsigned enableCheckUnreachable : 1;
33 public:
34 Policy();
35 void disableCheckFallThrough() { enableCheckFallThrough = 0; }
36 };
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000037
Ted Kremenekd064fdc2010-03-23 00:13:23 +000038private:
39 Sema &S;
40 Policy DefaultPolicy;
41
Ted Kremenekc2637042010-03-23 01:37:12 +000042 enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
43 llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
Ted Kremenekd064fdc2010-03-23 00:13:23 +000044
45public:
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000046 AnalysisBasedWarnings(Sema &s);
Ted Kremenekd064fdc2010-03-23 00:13:23 +000047
48 Policy getDefaultPolicy() { return DefaultPolicy; }
49
Ted Kremenekb7e5f142010-04-08 18:51:44 +000050 void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType());
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000051};
Ted Kremenekd064fdc2010-03-23 00:13:23 +000052
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000053}} // end namespace clang::sema
54
55#endif