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