diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-06-04 22:12:03 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-06-04 22:12:03 +0000 |
commit | 2b9e9e474c665152c48ec47797789148f9c652a8 (patch) | |
tree | 747659492b3a97d009b57fa475247a39facd887c /llvm/lib/IR | |
parent | 08b4728f5194cd03b1100b00d4d08ac2d468a400 (diff) | |
download | bcm5719-llvm-2b9e9e474c665152c48ec47797789148f9c652a8.tar.gz bcm5719-llvm-2b9e9e474c665152c48ec47797789148f9c652a8.zip |
IR: When creating a global variable, assert that its type is valid.
llvm-svn: 304690
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Globals.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index 17d27b016cf..2ddd78db631 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -293,6 +293,8 @@ GlobalVariable::GlobalVariable(Type *Ty, bool constant, LinkageTypes Link, InitVal != nullptr, Link, Name, AddressSpace), isConstantGlobal(constant), isExternallyInitializedConstant(isExternallyInitialized) { + assert(!Ty->isFunctionTy() && PointerType::isValidElementType(Ty) && + "invalid type for global variable"); setThreadLocalMode(TLMode); if (InitVal) { assert(InitVal->getType() == Ty && @@ -311,6 +313,8 @@ GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant, InitVal != nullptr, Link, Name, AddressSpace), isConstantGlobal(constant), isExternallyInitializedConstant(isExternallyInitialized) { + assert(!Ty->isFunctionTy() && PointerType::isValidElementType(Ty) && + "invalid type for global variable"); setThreadLocalMode(TLMode); if (InitVal) { assert(InitVal->getType() == Ty && |