blob: 26e973a3f40496db25ae58414c86b5990406a1e4 [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
42 llvm::DenseMap<const FunctionDecl*, unsigned> VisitedFD;
43
44public:
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000045 AnalysisBasedWarnings(Sema &s);
Ted Kremenekd064fdc2010-03-23 00:13:23 +000046
47 Policy getDefaultPolicy() { return DefaultPolicy; }
48
49 void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType(),
50 const bool analyzeStaticInline = false);
51
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000052};
Ted Kremenekd064fdc2010-03-23 00:13:23 +000053
Ted Kremenekdbdbaaf2010-03-20 21:06:02 +000054}} // end namespace clang::sema
55
56#endif