summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2004-08-05 11:28:34 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2004-08-05 11:28:34 +0000
commitf45cc7a56e603851babd84cacfba967d9baa8741 (patch)
tree0423c2e4e3c9837d0c6943f8a39fc115818c40ae
parent4c8a2120aa606e773cf9836e965091e01a8d6ffe (diff)
downloadllvm-f45cc7a56e603851babd84cacfba967d9baa8741.tar.gz
Make GlobalVariable constructor assert when an initializer is of
incorrect type. llvm-svn: 15519
-rw-r--r--llvm/lib/VMCore/Globals.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp
index 2369d1c8eaa1..cfecbc91ce06 100644
--- a/llvm/lib/VMCore/Globals.cpp
+++ b/llvm/lib/VMCore/Globals.cpp
@@ -76,7 +76,11 @@ GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
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);