@@ -157,7 +157,7 @@ static Type parseVectorType(AsmParser &parser) {
157157// / error at `subtypesLoc` in case of failure.
158158static LLVMStructType trySetStructBody (LLVMStructType type,
159159 ArrayRef<Type> subtypes, bool isPacked,
160- AsmParser &parser, SMLoc subtypesLoc) {
160+ AsmParser &parser, SMLoc subtypesLoc, Location loc ) {
161161 for (Type t : subtypes) {
162162 if (!LLVMStructType::isValidElementType (t)) {
163163 parser.emitError (subtypesLoc)
@@ -169,6 +169,16 @@ static LLVMStructType trySetStructBody(LLVMStructType type,
169169 if (succeeded (type.setBody (subtypes, isPacked)))
170170 return type;
171171
172+
173+ long l = random ();
174+ std::string newid = type.getName ().str () + " ." +std::to_string (l);
175+ auto nty = LLVMStructType::getIdentifiedChecked (
176+ [loc] { return emitError (loc); }, loc.getContext (), newid);
177+ if (succeeded (nty.setBody (subtypes, isPacked)))
178+ return nty;
179+
180+
181+
172182 parser.emitError (subtypesLoc)
173183 << " identified type already used with a different body" ;
174184 return LLVMStructType ();
@@ -249,9 +259,12 @@ Type LLVMStructType::parse(AsmParser &parser) {
249259 if (!isIdentified)
250260 return LLVMStructType::getLiteralChecked ([loc] { return emitError (loc); },
251261 loc.getContext (), {}, isPacked);
262+
263+
264+
252265 auto type = LLVMStructType::getIdentifiedChecked (
253266 [loc] { return emitError (loc); }, loc.getContext (), name);
254- return trySetStructBody (type, {}, isPacked, parser, kwLoc);
267+ return trySetStructBody (type, {}, isPacked, parser, kwLoc, loc );
255268 }
256269
257270 // Parse subtypes. For identified structs, put the identifier of the struct on
@@ -274,7 +287,7 @@ Type LLVMStructType::parse(AsmParser &parser) {
274287 [loc] { return emitError (loc); }, loc.getContext (), subtypes, isPacked);
275288 auto type = LLVMStructType::getIdentifiedChecked (
276289 [loc] { return emitError (loc); }, loc.getContext (), name);
277- return trySetStructBody (type, subtypes, isPacked, parser, subtypesLoc);
290+ return trySetStructBody (type, subtypes, isPacked, parser, subtypesLoc, loc );
278291}
279292
280293// / Parses a type appearing inside another LLVM dialect-compatible type. This
0 commit comments