OSDN Git Service

Fix assert that doesn't check anything.
authorWeverything <rtrieu@google.com>
Fri, 24 Jan 2020 00:03:31 +0000 (16:03 -0800)
committerWeverything <rtrieu@google.com>
Fri, 24 Jan 2020 03:02:00 +0000 (19:02 -0800)
Move the assert that checks for the end iterator inside the loop which
actually moves over the elements.  This allows it to check that the
iteration stays within the range.

llvm/lib/Analysis/SyncDependenceAnalysis.cpp

index 8447dc8..c16daa9 100644 (file)
@@ -244,12 +244,12 @@ struct DivergencePropagator {
     );
 
     auto ItBeginRPO = FuncRPOT.begin();
+    auto ItEndRPO = FuncRPOT.end();
 
     // skip until term (TODO RPOT won't let us start at @term directly)
-    for (; *ItBeginRPO != &RootBlock; ++ItBeginRPO) {}
-
-    auto ItEndRPO = FuncRPOT.end();
-    assert(ItBeginRPO != ItEndRPO);
+    for (; *ItBeginRPO != &RootBlock; ++ItBeginRPO) {
+      assert(ItBeginRPO != ItEndRPO && "Unable to find RootBlock");
+    }
 
     // propagate definitions at the immediate successors of the node in RPO
     auto ItBlockRPO = ItBeginRPO;