[llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Thu Aug 5 04:28:45 PDT 2004



Changes in directory llvm/lib/VMCore:

Globals.cpp updated: 1.4 -> 1.5
---
Log message:

Make GlobalVariable constructor assert when an initializer is of
incorrect type.


---
Diffs of the changes:  (+5 -1)

Index: llvm/lib/VMCore/Globals.cpp
diff -u llvm/lib/VMCore/Globals.cpp:1.4 llvm/lib/VMCore/Globals.cpp:1.5
--- llvm/lib/VMCore/Globals.cpp:1.4	Tue Aug  3 21:27:17 2004
+++ llvm/lib/VMCore/Globals.cpp	Thu Aug  5 06:28:34 2004
@@ -76,7 +76,11 @@
                                const std::string &Name, Module *ParentModule)
   : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name),
     isConstantGlobal(constant) {
-  if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
+  if (Initializer) {
+    assert(Initializer->getType() == Ty &&
+           "Initializer should be the same type as the GlobalVariable!");
+    Operands.push_back(Use((Value*)Initializer, this));
+  }
 
   LeakDetector::addGarbageObject(this);
 






More information about the llvm-commits mailing list