[cfe-commits] r50132 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Tue Apr 22 22:03:19 PDT 2008


Author: kremenek
Date: Wed Apr 23 00:03:18 2008
New Revision: 50132

URL: http://llvm.org/viewvc/llvm-project?rev=50132&view=rev
Log:
Remove false path where the default branch in a switch statement would
always be taken even if it was not feasible.

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=50132&r1=50131&r2=50132&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Apr 23 00:03:18 2008
@@ -562,6 +562,7 @@
 
   APSInt V1(bits, false);
   APSInt V2 = V1;
+  bool DefaultFeasible = false;
   
   for (iterator I = builder.begin(), EI = builder.end(); I != EI; ++I) {
 
@@ -617,8 +618,10 @@
       isFeasible = false;
       StNew = Assume(DefaultSt, Res, false, isFeasible);
       
-      if (isFeasible)
+      if (isFeasible) {
+        DefaultFeasible = true;
         DefaultSt = StNew;
+      }
 
       // Concretize the next value in the range.
       if (V1 == V2)
@@ -632,7 +635,7 @@
   
   // If we reach here, than we know that the default branch is
   // possible.  
-  builder.generateDefaultCaseNode(DefaultSt);
+  if (DefaultFeasible) builder.generateDefaultCaseNode(DefaultSt);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list