OpaqueType: model verification and name import

Teach Clift's verify-against-model and ImportDescriptiveInfo
visitors about types whose handle has the OpaqueType rank: the
verifier rejects non-struct types with such handles, and the name
importer fills in the type's mutable name with
NameBuilder::opaqueTypeName based on the wrapped byte size.
This commit is contained in:
Pietro Fezzardi
2026-05-08 11:37:10 +02:00
parent 21063f1844
commit 2f692127f9
2 changed files with 16 additions and 0 deletions
@@ -217,6 +217,10 @@ public:
return visitHelperStructType(mlir::cast<clift::StructAttr>(Attr), *L);
}
if (auto L = pipeline::locationFromString(rr::OpaqueType, T.getHandle())) {
return visitOpaqueType(mlir::cast<clift::StructAttr>(Attr), *L);
}
revng_abort("Unsupported type location");
}
@@ -390,6 +394,13 @@ private:
return mlir::success();
}
mlir::LogicalResult
visitOpaqueType(clift::StructAttr ST,
const pipeline::Location<decltype(rr::OpaqueType)> &L) {
ST.getMutableName().setValue(NameBuilder.opaqueTypeName(ST.getSize()));
return mlir::success();
}
//===----------------------- Operation name import ----------------------===//
auto getModelFunction(llvm::StringRef Handle) {
+5
View File
@@ -233,6 +233,11 @@ private:
return error() << "Clift ModuleOp contains a non-struct type with "
"an ArtificialStruct handle: '"
<< Type.getHandle() << "'";
} else if (auto L = GetLocation(ranks::OpaqueType)) {
if (not mlir::isa<clift::StructType>(Type))
return error() << "Clift ModuleOp contains a non-struct type with "
"an OpaqueType handle: '"
<< Type.getHandle() << "'";
} else {
return error() << "Clift ModuleOp contains a DefinedType with "
"an invalid handle: '"