forked from OSchip/llvm-project
Make GlobalVariable constructor assert when an initializer is of
incorrect type. llvm-svn: 15519
This commit is contained in:
parent
4c8a2120aa
commit
f45cc7a56e
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue