[LLVMdev] Why is BasicBlock's copy constructor private?
Trevor Harmon
trevor.w.harmon at nasa.gov
Thu Mar 25 17:04:40 PDT 2010
Hi,
LLVM provides basic graph traversal for its CFGs, but I need
additional operations, such as iterating over the edges. I thought I
would solve this problem using the Boost graph library. It should be
relatively simple to walk an LLVM CFG and add the BasicBlock objects
to a Boost graph declared as:
typedef boost::directed_graph<llvm::BasicBlock> Graph;
Once constructed, this automatically gives me access to all kinds of
sophisticated graph routines.
Unfortunately, the above code doesn't compile because Boost apparently
needs the class to have a copy constructor, and BasicBlock's copy
constructor is private. From BasicBlock.h:
class BasicBlock : ... {
private:
...
BasicBlock(const BasicBlock &); // Do not implement
void operator=(const BasicBlock &); // Do not implement
...
}
This causes a slew of errors related to Boost trying to call the copy
constructor and failing. Making the copy constructor public causes the
errors to disappear.
So why exactly is BasicBlock's copy constructor private? The ominous
"Do not implement" warning leads me to think there is some sort of
design issue that is preventing a copy constructor here. Is there any
possibility of working around it?
Thanks,
Trevor
More information about the llvm-dev
mailing list