[C++11] Use 'nullptr'.
[oota-llvm.git] / unittests / ADT / SCCIteratorTest.cpp
index 1151da0837338e2826f58e0bd4497291640b02f6..3f1ba1c5843f66d20ec4e4a981227109ca9a94c9 100644 (file)
@@ -7,10 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <limits.h>
-#include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/SCCIterator.h"
+#include "llvm/ADT/GraphTraits.h"
 #include "gtest/gtest.h"
+#include <limits.h>
 
 using namespace llvm;
 
@@ -33,7 +33,7 @@ public:
   class NodeSubset {
     typedef unsigned char BitVector; // Where the limitation N <= 8 comes from.
     BitVector Elements;
-    NodeSubset(BitVector e) : Elements(e) {};
+    NodeSubset(BitVector e) : Elements(e) {}
   public:
     /// NodeSubset - Default constructor, creates an empty subset.
     NodeSubset() : Elements(0) {
@@ -213,7 +213,7 @@ public:
           // Return a pointer to it.
           return FirstNode + i;
       assert(false && "Dereferencing end iterator!");
-      return 0; // Avoid compiler warning.
+      return nullptr; // Avoid compiler warning.
     }
   };
 
@@ -249,14 +249,12 @@ TEST(SCCIteratorTest, AllSmallGraphs) {
   // create graphs for which every node has a self-edge.
 #define NUM_NODES 4
 #define NUM_GRAPHS (NUM_NODES * (NUM_NODES - 1))
+  typedef Graph<NUM_NODES> GT;
 
-  /// GraphDescriptor - Enumerate all graphs using NUM_GRAPHS bits.
-  unsigned GraphDescriptor = 0;
-  assert(NUM_GRAPHS <= sizeof(unsigned) * CHAR_BIT && "Too many graphs!");
-
-  do {
-    typedef Graph<NUM_NODES> GT;
-
+  /// Enumerate all graphs using NUM_GRAPHS bits.
+  assert(NUM_GRAPHS < sizeof(unsigned) * CHAR_BIT && "Too many graphs!");
+  for (unsigned GraphDescriptor = 0; GraphDescriptor < (1U << NUM_GRAPHS);
+       ++GraphDescriptor) {
     GT G;
 
     // Add edges as specified by the descriptor.
@@ -279,7 +277,7 @@ TEST(SCCIteratorTest, AllSmallGraphs) {
     GT::NodeSubset NodesInSomeSCC;
 
     for (scc_iterator<GT> I = scc_begin(G), E = scc_end(G); I != E; ++I) {
-      std::vector<GT::NodeType*> &SCC = *I;
+      const std::vector<GT::NodeType *> &SCC = *I;
 
       // Get the nodes in this SCC as a NodeSubset rather than a vector.
       GT::NodeSubset NodesInThisSCC;
@@ -342,9 +340,7 @@ TEST(SCCIteratorTest, AllSmallGraphs) {
     // Finally, check that the nodes in some SCC are exactly those that are
     // reachable from the initial node.
     EXPECT_EQ(NodesInSomeSCC, G.NodesReachableFrom(0));
-
-    ++GraphDescriptor;
-  } while (GraphDescriptor && GraphDescriptor < (1U << NUM_GRAPHS));
+  }
 }
 
 }