[llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp
Chris Lattner
sabre at nondot.org
Sat Sep 30 14:31:43 PDT 2006
Changes in directory llvm/lib/VMCore:
Globals.cpp updated: 1.13 -> 1.14
---
Log message:
Add a version of the globalvariable ctor that inserts at a specific location.
---
Diffs of the changes: (+21 -0)
Globals.cpp | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+)
Index: llvm/lib/VMCore/Globals.cpp
diff -u llvm/lib/VMCore/Globals.cpp:1.13 llvm/lib/VMCore/Globals.cpp:1.14
--- llvm/lib/VMCore/Globals.cpp:1.13 Mon Jan 23 22:13:11 2006
+++ llvm/lib/VMCore/Globals.cpp Sat Sep 30 16:31:26 2006
@@ -91,6 +91,27 @@
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);
More information about the llvm-commits
mailing list