summaryrefslogtreecommitdiff
path: root/lib/VMCore
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
commit8243976b69aee92b26e67ef8a3ec505e924e408b (patch)
tree4628dfac42496dd1c59b57c516ac6db22c7d8584 /lib/VMCore
parenta2b5f45fed05b068aa70c85be9a70960d6996d0c (diff)
downloadllvm-8243976b69aee92b26e67ef8a3ec505e924e408b.tar.gz
llvm-8243976b69aee92b26e67ef8a3ec505e924e408b.tar.bz2
llvm-8243976b69aee92b26e67ef8a3ec505e924e408b.tar.xz
Make GlobalVariable constructor assert when an initializer is of
incorrect type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15519 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Globals.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp
index 2369d1c8ea..cfecbc91ce 100644
--- a/lib/VMCore/Globals.cpp
+++ b/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);