//
//===----------------------------------------------------------------------===//
-#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;
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) {
// 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.
- uint16_t GraphDescriptor = 0;
- assert(NUM_GRAPHS <= sizeof(uint16_t) * 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.
- uint16_t DescriptorCopy = GraphDescriptor;
+ unsigned DescriptorCopy = GraphDescriptor;
for (unsigned i = 0; i != NUM_NODES; ++i)
for (unsigned j = 0; j != NUM_NODES; ++j) {
// Always add a self-edge.
// 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 && (unsigned)GraphDescriptor < (1U << NUM_GRAPHS));
+ }
}
}