]> granicus.if.org Git - clang/commitdiff
Fix for PR20402 in -Wconsumed.
authorDeLesley Hutchins <delesley@google.com>
Wed, 15 Apr 2015 22:32:44 +0000 (22:32 +0000)
committerDeLesley Hutchins <delesley@google.com>
Wed, 15 Apr 2015 22:32:44 +0000 (22:32 +0000)
https://llvm.org/bugs/show_bug.cgi?id=20402
Patch by Chris Wailes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235051 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/Consumed.cpp
test/SemaCXX/warn-consumed-analysis.cpp

index 967f3e1dbfb6c5bdfe63010d16b5f0f6911b644b..fa985ee02e590b315a49590f3dc72ddd46afaebf 100644 (file)
@@ -1442,7 +1442,7 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {
                                                            CurrStates,
                                                            WarningsHandler);
             
-            if (BlockInfo.allBackEdgesVisited(*SI, CurrBlock))
+            if (BlockInfo.allBackEdgesVisited(CurrBlock, *SI))
               BlockInfo.discardInfo(*SI);
           } else {
             BlockInfo.addInfo(*SI, CurrStates, OwnershipTaken);
index 977b862a92b5088f930c90478269583807fe669d..0a6aed61862654d5426c55d298d57f32685ea21f 100644 (file)
@@ -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) {}