Make GlobalVariable constructor assert when an initializer is of

incorrect type.

llvm-svn: 15519
This commit is contained in:
Alkis Evlogimenos 2004-08-05 11:28:34 +00:00
parent 4c8a2120aa
commit f45cc7a56e
1 changed files with 5 additions and 1 deletions

View File

@ -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);