aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Function.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-03 14:53:21 +0000
committerChris Lattner <sabre@nondot.org>2001-10-03 14:53:21 +0000
commitef9c23f2812322ae5c5f3140bfbcf92629d7ff47 (patch)
treec87db095661379f13a39bf1dee52af9ded6a23a3 /lib/VMCore/Function.cpp
parentda257162968820a7fd77a9df44e3f72090a7f13a (diff)
* Both Method & GlobalVariable now subclass GlobalValue
* ConstPoolPointerReference now represents a pointer to a GlobalValue * Methods name references are now explicit pointers to methods * Rename Value::GlobalVal to Value::GlobalVariableVal to avoid confusion git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r--lib/VMCore/Function.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 9eb8277a27..372d0d28b9 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -26,8 +26,8 @@ template class ValueHolder<MethodArgument, Method, Method>;
template class ValueHolder<BasicBlock , Method, Method>;
Method::Method(const MethodType *Ty, const string &name)
- : Value(Ty, Value::MethodVal, name), SymTabValue(this), BasicBlocks(this),
- ArgumentList(this, this) {
+ : GlobalValue(PointerType::get(Ty), Value::MethodVal, name),
+ SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) {
assert(::isa<MethodType>(Ty) && "Method signature must be of method type!");
Parent = 0;
}
@@ -62,8 +62,12 @@ void Method::setParent(Module *parent) {
setParentSymTab(Parent ? Parent->getSymbolTableSure() : 0);
}
+const MethodType *Method::getMethodType() const {
+ return cast<MethodType>(cast<PointerType>(getType())->getValueType());
+}
+
const Type *Method::getReturnType() const {
- return ((const MethodType *)getType())->getReturnType();
+ return getMethodType()->getReturnType();
}
// dropAllReferences() - This function causes all the subinstructions to "let
@@ -85,8 +89,8 @@ void Method::dropAllReferences() {
GlobalVariable::GlobalVariable(const Type *Ty, bool isConstant,
ConstPoolVal *Initializer = 0,
const string &Name = "")
- : User(Ty, Value::GlobalVal, Name), Parent(0), Constant(isConstant) {
- assert(Ty->isPointerType() && "Global Variables must be pointers!");
+ : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Name),
+ Parent(0), Constant(isConstant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
assert(!isConstant || hasInitializer() &&