summaryrefslogtreecommitdiff
path: root/lib/VMCore/Globals.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-30 21:31:26 +0000
committerChris Lattner <sabre@nondot.org>2006-09-30 21:31:26 +0000
commitadc95467e41d6c46793f665168468cbf348c3638 (patch)
tree8093c9dc84df3e6f62cdfb4e24e9cf0632e07d42 /lib/VMCore/Globals.cpp
parentcff1673182b239a8b8a53ac68fc48fe93161357e (diff)
downloadllvm-adc95467e41d6c46793f665168468cbf348c3638.tar.gz
llvm-adc95467e41d6c46793f665168468cbf348c3638.tar.bz2
llvm-adc95467e41d6c46793f665168468cbf348c3638.tar.xz
Add a version of the globalvariable ctor that inserts at a specific location.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Globals.cpp')
-rw-r--r--lib/VMCore/Globals.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index 3ea8265eba..e49f47766f 100644
--- a/lib/VMCore/Globals.cpp
+++ b/lib/VMCore/Globals.cpp
@@ -91,6 +91,27 @@ GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
ParentModule->getGlobalList().push_back(this);
}
+GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
+ Constant *InitVal,
+ const std::string &Name, GlobalVariable *Before)
+ : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal,
+ &Initializer, InitVal != 0, Link, Name),
+ isConstantGlobal(constant) {
+ if (InitVal) {
+ assert(InitVal->getType() == Ty &&
+ "Initializer should be the same type as the GlobalVariable!");
+ Initializer.init(InitVal, this);
+ } else {
+ Initializer.init(0, this);
+ }
+
+ LeakDetector::addGarbageObject(this);
+
+ if (Before)
+ Before->getParent()->getGlobalList().insert(Before, this);
+}
+
+
void GlobalVariable::setParent(Module *parent) {
if (getParent())
LeakDetector::addGarbageObject(this);