Skip to content

Commit 2b582eb

Browse files
Address comments.
1 parent 2af97d5 commit 2b582eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,12 @@ verifyStructIndices(Type baseGEPType, unsigned indexPos,
821821

822822
return TypeSwitch<Type, LogicalResult>(baseGEPType)
823823
.Case<LLVMStructType>([&](LLVMStructType structType) -> LogicalResult {
824-
if (!isa<IntegerAttr>(indices[indexPos]))
824+
auto attr = dyn_cast<IntegerAttr>(indices[indexPos]);
825+
if (!attr)
825826
return emitOpError() << "expected index " << indexPos
826827
<< " indexing a struct to be constant";
827828

828-
int32_t gepIndex = cast<IntegerAttr>(indices[indexPos]).getInt();
829+
int32_t gepIndex = attr.getInt();
829830
ArrayRef<Type> elementTypes = structType.getBody();
830831
if (gepIndex < 0 ||
831832
static_cast<size_t>(gepIndex) >= elementTypes.size())

0 commit comments

Comments
 (0)