diff options
author | Chris Lattner <sabre@nondot.org> | 2001-09-18 04:01:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-09-18 04:01:05 +0000 |
commit | 3779864fcf9c2b1df53b4841c6d87e92b5bbce4a (patch) | |
tree | 6755ed22c12e875f46dbd2db30c964cf0a323239 /llvm/lib/VMCore/Function.cpp | |
parent | 7fb14f54f84ab9a49a3eaf50286f65cf24fbe37b (diff) | |
download | bcm5719-llvm-3779864fcf9c2b1df53b4841c6d87e92b5bbce4a.tar.gz bcm5719-llvm-3779864fcf9c2b1df53b4841c6d87e92b5bbce4a.zip |
Add support for global constants, and for initializers for constants
llvm-svn: 598
Diffstat (limited to 'llvm/lib/VMCore/Function.cpp')
-rw-r--r-- | llvm/lib/VMCore/Function.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 75a27781a90..47a85395a3f 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -82,12 +82,18 @@ void Method::dropAllReferences() { // GlobalVariable Implementation //===----------------------------------------------------------------------===// -GlobalVariable::GlobalVariable(const Type *Ty, const string &Name = "") - : Value(Ty, Value::GlobalVal, Name), Parent(0) { +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() && // No unsized array pointers - (!Ty->dyncastPointerType()->isArrayType() || - Ty->dyncastPointerType()->dyncastArrayType()->isSized()) && + (!Ty->castPointerType()->isArrayType() || + Ty->castPointerType()->castArrayType()->isSized()) && "Global Variables must be pointers to a sized type!"); + if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); + + assert(!isConstant || hasInitializer() && + "Globals Constants must have an initializer!"); } // Specialize setName to take care of symbol table majik |