diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-23 01:52:04 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-23 01:52:04 +0000 |
commit | 3427fac7c883efbb1097ac9ba13198b95c9fbccb (patch) | |
tree | 90b45ab6b5b03a98eef401300c9b0d989f6252b8 /clang/lib/Sema/Sema.cpp | |
parent | 80861ca9b53545dd1579a9853807e780952a55da (diff) | |
download | bcm5719-llvm-3427fac7c883efbb1097ac9ba13198b95c9fbccb.tar.gz bcm5719-llvm-3427fac7c883efbb1097ac9ba13198b95c9fbccb.zip |
Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the related code is reachable. This suppresses some
diagnostics that occur in unreachable code (e.g., -Warray-bound).
We only pay the cost of doing the reachability analysis when we issue one of these diagnostics.
llvm-svn: 126290
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 0827597abdf..0c39e132539 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -48,6 +48,7 @@ void FunctionScopeInfo::Clear() { SwitchStack.clear(); Returns.clear(); ErrorTrap.reset(); + PossiblyUnreachableDiags.clear(); } BlockScopeInfo::~BlockScopeInfo() { } @@ -639,9 +640,19 @@ void Sema::PopFunctionOrBlockScope(const AnalysisBasedWarnings::Policy *WP, // Issue any analysis-based warnings. if (WP && D) AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr); + else { + for (llvm::SmallVectorImpl<sema::PossiblyUnreachableDiag>::iterator + i = Scope->PossiblyUnreachableDiags.begin(), + e = Scope->PossiblyUnreachableDiags.end(); + i != e; ++i) { + const sema::PossiblyUnreachableDiag &D = *i; + Diag(D.Loc, D.PD); + } + } - if (FunctionScopes.back() != Scope) + if (FunctionScopes.back() != Scope) { delete Scope; + } } /// \brief Determine whether any errors occurred within this function/method/ |