diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-03-20 21:06:02 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-03-20 21:06:02 +0000 |
commit | dbdbaaf34f798fa5cabec273c4b9397b3fd6a98c (patch) | |
tree | 2a6ae20829406dde7052e1f45108ad2d390f7bcf /lib/Sema/AnalysisBasedWarnings.h | |
parent | 4c8c8e93ca3b63de4d30f4a460b50fe63fd6bd3b (diff) |
Refactor CFG-based warnings in Sema to be run by a worked object called AnalysisBasedWarnings.
This object controls when the warnings are executed, allowing the client code
in Sema to selectively disable warnings as needed.
Centralizing the logic for analysis-based warnings allows us to optimize
when and how they are run.
Along the way, remove the redundant logic for the 'check fall-through' warning
for blocks; now the same logic is used for both blocks and functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99085 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.h')
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.h b/lib/Sema/AnalysisBasedWarnings.h new file mode 100644 index 0000000000..39da1b14d4 --- /dev/null +++ b/lib/Sema/AnalysisBasedWarnings.h @@ -0,0 +1,35 @@ +//=- AnalysisBasedWarnings.h - Sema warnings based on libAnalysis -*- C++ -*-=// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines AnalysisBasedWarnings, a worker object used by Sema +// that issues warnings based on dataflow-analysis. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H +#define LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H + +namespace clang { namespace sema { + +class AnalysisBasedWarnings { + Sema &S; + // The warnings to run. + unsigned enableCheckFallThrough : 1; + unsigned enableCheckUnreachable : 1; + +public: + + AnalysisBasedWarnings(Sema &s); + void IssueWarnings(const Decl *D, QualType BlockTy = QualType()); + + void disableCheckFallThrough() { enableCheckFallThrough = 0; } +}; + +}} // end namespace clang::sema + +#endif |