[llvm] r304690 - IR: When creating a global variable, assert that its type is valid.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 4 15:12:03 PDT 2017
Author: pcc
Date: Sun Jun 4 17:12:03 2017
New Revision: 304690
URL: http://llvm.org/viewvc/llvm-project?rev=304690&view=rev
Log:
IR: When creating a global variable, assert that its type is valid.
Modified:
llvm/trunk/lib/IR/Globals.cpp
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=304690&r1=304689&r2=304690&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Sun Jun 4 17:12:03 2017
@@ -293,6 +293,8 @@ GlobalVariable::GlobalVariable(Type *Ty,
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
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 &&
More information about the llvm-commits
mailing list