Skip to content

Commit b85ff3a

Browse files
committed
more fixes
1 parent c307946 commit b85ff3a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

mlir/lib/CAPI/Dialect/LLVM.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
127127

128128
MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
129129
MlirAttribute const *operations) {
130-
SmallVector<Attribute, 2> attrStorage;
130+
SmallVector<Attribute> attrStorage;
131131
attrStorage.reserve(nOperations);
132132

133133
return wrap(DIExpressionAttr::get(
@@ -154,24 +154,16 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
154154
uint32_t line, MlirAttribute scope, MlirAttribute baseType, int64_t flags,
155155
uint64_t sizeInBits, uint64_t alignInBits, intptr_t nElements,
156156
MlirAttribute const *elements) {
157-
SmallVector<Attribute, 2> elementsStorage;
157+
SmallVector<Attribute> elementsStorage;
158158
elementsStorage.reserve(nElements);
159159

160-
ArrayRef<Attribute> tempList =
161-
unwrapList(nElements, elements, elementsStorage);
162-
163-
SmallVector<DINodeAttr, 2> diNodesStorage;
164-
diNodesStorage.reserve(tempList.size());
165-
166-
for (auto attr : tempList) {
167-
diNodesStorage.push_back(attr.cast<DINodeAttr>());
168-
}
169-
170160
return wrap(DICompositeTypeAttr::get(
171161
unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
172162
cast<DIFileAttr>(unwrap(file)), line, cast<DIScopeAttr>(unwrap(scope)),
173163
cast<DITypeAttr>(unwrap(baseType)), DIFlags(flags), sizeInBits,
174-
alignInBits, diNodesStorage));
164+
alignInBits,
165+
llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
166+
[](Attribute a) { return a.cast<DINodeAttr>(); })));
175167
}
176168

177169
MlirAttribute mlirLLVMDIDerivedTypeAttrGet(MlirContext ctx, unsigned int tag,
@@ -259,7 +251,7 @@ MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
259251
unsigned int callingConvention,
260252
intptr_t nTypes,
261253
MlirAttribute const *types) {
262-
SmallVector<Attribute, 2> attrStorage;
254+
SmallVector<Attribute> attrStorage;
263255
attrStorage.reserve(nTypes);
264256

265257
return wrap(DISubroutineTypeAttr::get(

0 commit comments

Comments
 (0)