Files
2026-06-15 17:28:22 +02:00

47 lines
1.4 KiB
C++

//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "mlir/IR/Diagnostics.h"
#include "revng/Clift/Clift.h"
#include "revng/CliftImportModel/ImportModel.h"
template<typename CallableType>
static auto withContext(CallableType Callable) {
mlir::MLIRContext Context;
Context.loadDialect<clift::CliftDialect>();
const auto EmitError = [&]() -> mlir::InFlightDiagnostic {
return Context.getDiagEngine().emit(mlir::UnknownLoc::get(&Context),
mlir::DiagnosticSeverity::Remark);
};
return Callable(EmitError, &Context);
}
static bool verify(const model::TypeDefinition &ModelType,
const model::Binary &Binary,
const bool Assert) {
return withContext([&](const auto EmitError, mlir::MLIRContext *Context) {
return static_cast<bool>(clift::importType(EmitError, Context, ModelType));
});
}
static bool
verify(const model::Type &ModelType, const model::Binary &Binary, bool Assert) {
return withContext([&](const auto EmitError, mlir::MLIRContext *Context) {
return static_cast<bool>(clift::importType(EmitError, Context, ModelType));
});
}
static bool verify(const model::Binary &Tree, const bool Assert) {
return Tree.verify(Assert);
}
static bool checkSerialization(const TupleTree<model::Binary> &Tree) {
return true;
}
#include "revng/tests/unit/ModelType.inc"