diff options
author | Mike Stump <mrs@apple.com> | 2010-01-14 02:26:52 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2010-01-14 02:26:52 +0000 |
commit | cb4a4fb7810b46fd7d62f1f1e54299d2229cd8dc (patch) | |
tree | fa363b1cd28927acbc38b0e0bc1f323024abd020 | |
parent | f462989fe8d6f59ab2d7d0fe2b4b96292ce706ea (diff) |
Avoid snowballing errors into additional warnings. To do better, we'd
need an error term for the CFG. I suspect we'll always have to cope
with getCFG returning 0, though, I'd love to see even that possibility
removed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93411 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 948418b42a..40c3e754ad 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1329,11 +1329,14 @@ static void MarkLive(CFGBlock *e, llvm::BitVector &live) { /// CheckUnreachable - Check for unreachable code. void Sema::CheckUnreachable(AnalysisContext &AC) { + // We avoid checking when there are errors, as the CFG won't faithfully match + // the users code. + if (getDiagnostics().hasErrorOccurred()) + return; if (Diags.getDiagnosticLevel(diag::warn_unreachable) == Diagnostic::Ignored) return; CFG *cfg = AC.getCFG(); - // FIXME: They should never return 0, fix that, delete this code. if (cfg == 0) return; @@ -1363,7 +1366,6 @@ void Sema::CheckUnreachable(AnalysisContext &AC) { /// will return. Sema::ControlFlowKind Sema::CheckFallThrough(AnalysisContext &AC) { CFG *cfg = AC.getCFG(); - // FIXME: They should never return 0, fix that, delete this code. if (cfg == 0) // FIXME: This should be NeverFallThrough return NeverFallThroughOrReturn; |