forked from OSchip/llvm-project
Fix a bad interaction between -Wtautological-overlap-compare and delayed
diagnostics which caused delayed diagnostics on dead paths to be emitted. llvm-svn: 206232
This commit is contained in:
parent
81ab90f7ed
commit
e9fa266cba
|
@ -189,6 +189,9 @@ CFG *AnalysisDeclContext::getCFG() {
|
|||
|
||||
if (PM)
|
||||
addParentsForSyntheticStmts(cfg.get(), *PM);
|
||||
|
||||
// The Obersver should only observe one build of the CFG.
|
||||
getCFGBuildOptions().Observer = 0;
|
||||
}
|
||||
return cfg.get();
|
||||
}
|
||||
|
@ -205,6 +208,9 @@ CFG *AnalysisDeclContext::getUnoptimizedCFG() {
|
|||
|
||||
if (PM)
|
||||
addParentsForSyntheticStmts(completeCFG.get(), *PM);
|
||||
|
||||
// The Obersver should only observe one build of the CFG.
|
||||
getCFGBuildOptions().Observer = 0;
|
||||
}
|
||||
return completeCFG.get();
|
||||
}
|
||||
|
|
|
@ -1838,12 +1838,12 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
|
|||
.setAlwaysAdd(Stmt::AttributedStmtClass);
|
||||
}
|
||||
|
||||
// Install the logical handler for -Wtautological-overlap-compare
|
||||
std::unique_ptr<LogicalErrorHandler> LEH;
|
||||
if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
|
||||
D->getLocStart())) {
|
||||
LogicalErrorHandler LEH(S);
|
||||
AC.getCFGBuildOptions().Observer = &LEH;
|
||||
AC.getCFG();
|
||||
AC.getCFGBuildOptions().Observer = 0;
|
||||
LEH.reset(new LogicalErrorHandler(S));
|
||||
AC.getCFGBuildOptions().Observer = LEH.get();
|
||||
}
|
||||
|
||||
// Emit delayed diagnostics.
|
||||
|
@ -1991,6 +1991,13 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
|
|||
}
|
||||
}
|
||||
|
||||
// If none of the previous checks caused a CFG build, trigger one here
|
||||
// for -Wtautological-overlap-compare
|
||||
if (Diags.getDiagnosticLevel(diag::warn_tautological_overlap_comparison,
|
||||
D->getLocStart())) {
|
||||
AC.getCFG();
|
||||
}
|
||||
|
||||
// Collect statistics about the CFG if it was built.
|
||||
if (S.CollectStats && AC.isCFGBuilt()) {
|
||||
++NumFunctionsAnalyzed;
|
||||
|
|
|
@ -56,3 +56,9 @@ void f(int x) {
|
|||
if (x == (mydefine + 1) && x > 3) { }
|
||||
}
|
||||
|
||||
// Don't generate a warning here.
|
||||
void array_out_of_bounds() {
|
||||
int x;
|
||||
int buffer[4];
|
||||
x = (-7 > 0) ? (buffer[-7]) : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue