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 | |
Ted Kremenek | c263704 | 2010-03-23 01:37:12 +0000 | [diff] [blame] | 42 | enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 }; |
| 43 | llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 44 | |
| 45 | public: |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 46 | AnalysisBasedWarnings(Sema &s); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 47 | |
| 48 | Policy getDefaultPolicy() { return DefaultPolicy; } |
| 49 | |
Ted Kremenek | b7e5f14 | 2010-04-08 18:51:44 +0000 | [diff] [blame] | 50 | void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType()); |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 51 | }; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 52 | |
Ted Kremenek | dbdbaaf | 2010-03-20 21:06:02 +0000 | [diff] [blame] | 53 | }} // end namespace clang::sema |
| 54 | |
| 55 | #endif |