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 | d70684f7585a85c4248c1c224059478108741c70 (patch) | |
tree | 17d40698895d1c3efb8655ec7059be714bb940e7 /lib/VMCore/Function.cpp | |
parent | 1781acab34447ad679c5c952ec12c942fb63f887 (diff) |
Add support for global constants, and for initializers for constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@598 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r-- | lib/VMCore/Function.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 75a27781a9..47a85395a3 100644 --- a/lib/VMCore/Function.cpp +++ b/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 |