/// function is automatically inserted into the end of the function list for
/// the module.
///
- Function(const FunctionType *Ty, bool isInternal, const std::string &N = "",
- Module *M = 0);
+ Function(const FunctionType *Ty, LinkageTypes Linkage,
+ const std::string &N = "", Module *M = 0);
~Function();
// Specialize setName to handle symbol table majik...
///
virtual bool isExternal() const { return BasicBlocks.empty(); }
+ /// getIntrinsicID - This method returns the ID number of the specified
+ /// function, or LLVMIntrinsic::not_intrinsic if the function is not an
+ /// instrinsic, or if the pointer is null. This value is always defined to be
+ /// zero to allow easy checking for whether a function is intrinsic or not.
+ /// The particular intrinsic functions which correspond to this value are
+ /// defined in llvm/Intrinsics.h.
+ ///
+ unsigned getIntrinsicID() const;
+ bool isIntrinsic() const { return getIntrinsicID() != 0; }
+
+ /// deleteBody - This method deletes the body of the function, and converts
+ /// the linkage to external.
+ void deleteBody() {
+ dropAllReferences();
+ setLinkage(ExternalLinkage);
+ }
+
// getNext/Prev - Return the next or previous function in the list. These
// methods should never be used directly, and are only used to implement the
// function list as part of the module.
Function *getPrev() { return Prev; }
const Function *getPrev() const { return Prev; }
- /// Get the underlying elements of the Function... both the argument list and
- /// basic block list are empty for external functions.
+ /// Get the underlying elements of the Function... the basic block list is
+ /// empty for external functions.
///
const ArgumentListType &getArgumentList() const { return ArgumentList; }
ArgumentListType &getArgumentList() { return ArgumentList; }
const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
- const BasicBlock &getEntryNode() const { return front(); }
- BasicBlock &getEntryNode() { return front(); }
+ const BasicBlock &getEntryBlock() const { return front(); }
+ BasicBlock &getEntryBlock() { return front(); }
//===--------------------------------------------------------------------===//
// Symbol Table Accessing functions...
return V->getValueType() == Value::FunctionVal;
}
- /// dropAllReferences() - This function causes all the subinstructions to "let
+ /// dropAllReferences() - This method causes all the subinstructions to "let
/// go" of all references that they are maintaining. This allows one to
- /// 'delete' a whole class at a time, even though there may be circular
+ /// 'delete' a whole module at a time, even though there may be circular
/// references... first all references are dropped, and all use counts go to
/// zero. Then everything is delete'd for real. Note that no operations are
/// valid on an object that has "dropped all references", except operator
/// delete.
///
+ /// Since no other object in the module can have references into the body of a
+ /// function, dropping all references deletes the entire body of the function,
+ /// including any contained basic blocks.
+ ///
void dropAllReferences();
};