Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 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 | |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame^] | 17 | #include "llvm/ADT/SmallVector.h" |
| 18 | #include "llvm/ADT/DenseMap.h" |
| 19 | |
| 20 | namespace clang { |
| 21 | |
| 22 | class Sema; |
| 23 | |
| 24 | namespace sema { |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 25 | |
| 26 | class AnalysisBasedWarnings { |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 27 | public: |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame^] | 28 | 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 Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 37 | |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame^] | 38 | private: |
| 39 | Sema &S; |
| 40 | Policy DefaultPolicy; |
| 41 | |
| 42 | llvm::DenseMap<const FunctionDecl*, unsigned> VisitedFD; |
| 43 | |
| 44 | public: |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 45 | AnalysisBasedWarnings(Sema &s); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame^] | 46 | |
| 47 | Policy getDefaultPolicy() { return DefaultPolicy; } |
| 48 | |
| 49 | void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType(), |
| 50 | const bool analyzeStaticInline = false); |
| 51 | |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 52 | }; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame^] | 53 | |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 54 | }} // end namespace clang::sema |
| 55 | |
| 56 | #endif |