Question about removeFromParent

I have Function
Function* F;
and one of its basic blocks BB

I want to insert this BB into a new function without remove it from the original
according that BList is the list of the basic blocks of the newFunction

BList.insert(BB);

but I don’t want to call BB->removeFromParent(); and without this method it give me error that BB is already in a container

is there another function that get copy without deleting?

Thank you in advance

I don’t think you can share a basic block between functions; you’ll need to make a copy of the existing block and put it into your new function. There is a CloneBasicBlock() function in llvm32/lib/Transforms/Utils/CloneFunction.cpp. That (or some other function in that file) may do what you want. – John T.