From 2f692127f9d06da0df29f8f735ec152c4f4c8dd9 Mon Sep 17 00:00:00 2001 From: Pietro Fezzardi Date: Fri, 8 May 2026 11:37:10 +0200 Subject: [PATCH] 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. --- lib/CliftImportModel/ImportDescriptiveInfo.cpp | 11 +++++++++++ lib/CliftImportModel/Verify.cpp | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/lib/CliftImportModel/ImportDescriptiveInfo.cpp b/lib/CliftImportModel/ImportDescriptiveInfo.cpp index a5c750cc7..c11f9e423 100644 --- a/lib/CliftImportModel/ImportDescriptiveInfo.cpp +++ b/lib/CliftImportModel/ImportDescriptiveInfo.cpp @@ -217,6 +217,10 @@ public: return visitHelperStructType(mlir::cast(Attr), *L); } + if (auto L = pipeline::locationFromString(rr::OpaqueType, T.getHandle())) { + return visitOpaqueType(mlir::cast(Attr), *L); + } + revng_abort("Unsupported type location"); } @@ -390,6 +394,13 @@ private: return mlir::success(); } + mlir::LogicalResult + visitOpaqueType(clift::StructAttr ST, + const pipeline::Location &L) { + ST.getMutableName().setValue(NameBuilder.opaqueTypeName(ST.getSize())); + return mlir::success(); + } + //===----------------------- Operation name import ----------------------===// auto getModelFunction(llvm::StringRef Handle) { diff --git a/lib/CliftImportModel/Verify.cpp b/lib/CliftImportModel/Verify.cpp index e445af4db..b1c16b997 100644 --- a/lib/CliftImportModel/Verify.cpp +++ b/lib/CliftImportModel/Verify.cpp @@ -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(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: '"