Author: delesley
Date: Wed Apr 15 17:32:44 2015
New Revision: 235051

URL: http://llvm.org/viewvc/llvm-project?rev=235051&view=rev
Log:
Fix for PR20402 in -Wconsumed.
https://llvm.org/bugs/show_bug.cgi?id=20402
Patch by Chris Wailes.

Modified:
    cfe/trunk/lib/Analysis/Consumed.cpp
    cfe/trunk/test/SemaCXX/warn-consumed-analysis.cpp

Modified: cfe/trunk/lib/Analysis/Consumed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=235051&r1=235050&r2=235051&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Wed Apr 15 17:32:44 2015
@@ -1442,7 +1442,7 @@ void ConsumedAnalyzer::run(AnalysisDeclC
                                                            CurrStates,
                                                            WarningsHandler);
             
-            if (BlockInfo.allBackEdgesVisited(*SI, CurrBlock))
+            if (BlockInfo.allBackEdgesVisited(CurrBlock, *SI))
               BlockInfo.discardInfo(*SI);
           } else {
             BlockInfo.addInfo(*SI, CurrStates, OwnershipTaken);

Modified: cfe/trunk/test/SemaCXX/warn-consumed-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-consumed-analysis.cpp?rev=235051&r1=235050&r2=235051&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-consumed-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-consumed-analysis.cpp Wed Apr 15 17:32:44 2015
@@ -638,6 +638,18 @@ void testWhileLoop1() {
   *var0; // expected-warning {{invalid invocation of method 'operator*' on 
object 'var0' while it is in the 'consumed' state}}
 }
 
+// Tests if state information is correctly discarded for certain shapes of 
CFGs.
+void testSwitchGOTO(void) {
+       int a;
+
+       LABEL0:
+       switch (a)
+       case 0:
+               goto LABEL0;
+
+       goto LABEL0;
+}
+
 typedef const int*& IntegerPointerReference;
 void testIsRValueRefishAndCanonicalType(IntegerPointerReference a) {}
 


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to