mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
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:
@@ -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) {
|
||||
|
||||
@@ -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: '"
|
||||
|
||||
Reference in New Issue
Block a user