From b01e0c6191cf99cab65f870db8beb65ee66b93b3 Mon Sep 17 00:00:00 2001 From: DeLesley Hutchins Date: Wed, 15 Apr 2015 22:32:44 +0000 Subject: [PATCH] Fix for PR20402 in -Wconsumed. 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 | 2 +- test/SemaCXX/warn-consumed-analysis.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp index 967f3e1dbf..fa985ee02e 100644 --- a/lib/Analysis/Consumed.cpp +++ b/lib/Analysis/Consumed.cpp @@ -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); diff --git a/test/SemaCXX/warn-consumed-analysis.cpp b/test/SemaCXX/warn-consumed-analysis.cpp index 977b862a92..0a6aed6186 100644 --- a/test/SemaCXX/warn-consumed-analysis.cpp +++ b/test/SemaCXX/warn-consumed-analysis.cpp @@ -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) {} -- 2.50.1