[cfe-commits] r93411 - /cfe/trunk/lib/Sema/SemaDecl.cpp

Mike Stump mrs at apple.com
Wed Jan 13 18:26:52 PST 2010


Author: mrs
Date: Wed Jan 13 20:26:52 2010
New Revision: 93411

URL: http://llvm.org/viewvc/llvm-project?rev=93411&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=93411&r1=93410&r2=93411&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan 13 20:26:52 2010
@@ -1329,11 +1329,14 @@
 
 /// 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 @@
 /// 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;





More information about the cfe-commits mailing list