[PATCH] D105653: [IR] Don't accept nullptr as GEP element type
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 9 08:38:17 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5035e7be1a8a: [IR] Don't accept nullptr as GEP element type (authored by nikic).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105653/new/
https://reviews.llvm.org/D105653
Files:
llvm/include/llvm/IR/Instructions.h
Index: llvm/include/llvm/IR/Instructions.h
===================================================================
--- llvm/include/llvm/IR/Instructions.h
+++ llvm/include/llvm/IR/Instructions.h
@@ -956,13 +956,9 @@
const Twine &NameStr = "",
Instruction *InsertBefore = nullptr) {
unsigned Values = 1 + unsigned(IdxList.size());
- if (!PointeeType) {
- PointeeType =
- cast<PointerType>(Ptr->getType()->getScalarType())->getElementType();
- } else {
- assert(cast<PointerType>(Ptr->getType()->getScalarType())
- ->isOpaqueOrPointeeTypeMatches(PointeeType));
- }
+ assert(PointeeType && "Must specify element type");
+ assert(cast<PointerType>(Ptr->getType()->getScalarType())
+ ->isOpaqueOrPointeeTypeMatches(PointeeType));
return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
NameStr, InsertBefore);
}
@@ -972,13 +968,9 @@
const Twine &NameStr,
BasicBlock *InsertAtEnd) {
unsigned Values = 1 + unsigned(IdxList.size());
- if (!PointeeType) {
- PointeeType =
- cast<PointerType>(Ptr->getType()->getScalarType())->getElementType();
- } else {
- assert(cast<PointerType>(Ptr->getType()->getScalarType())
- ->isOpaqueOrPointeeTypeMatches(PointeeType));
- }
+ assert(PointeeType && "Must specify element type");
+ assert(cast<PointerType>(Ptr->getType()->getScalarType())
+ ->isOpaqueOrPointeeTypeMatches(PointeeType));
return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values,
NameStr, InsertAtEnd);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105653.357526.patch
Type: text/x-patch
Size: 1815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210709/9346b592/attachment.bin>
More information about the llvm-commits
mailing list