Files
revng-revng/tests/unit/CliftType.cpp
T
2024-05-29 15:43:35 +02:00

48 lines
1.6 KiB
C++

//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "mlir/IR/Diagnostics.h"
#include "revng-c/mlir/Dialect/Clift/IR/Clift.h"
#include "revng-c/mlir/Dialect/Clift/Utils/ImportModel.h"
template<typename CallableType>
static auto withContext(CallableType Callable) {
mlir::MLIRContext Context;
Context.loadDialect<mlir::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::Type &ModelType, const bool Assert) {
return withContext([&](const auto EmitError, mlir::MLIRContext &Context) {
return static_cast<bool>(mlir::clift::importModelType(EmitError,
Context,
ModelType));
});
}
static bool verify(const model::QualifiedType &ModelType, bool Assert) {
return withContext([&](const auto EmitError, mlir::MLIRContext &Context) {
return static_cast<bool>(mlir::clift::importModelType(EmitError,
Context,
ModelType));
});
}
static bool verify(const model::Binary &Tree, const bool Assert) {
return Tree.verify(false);
}
static bool checkSerialization(const TupleTree<model::Binary> &Tree) {
return true;
}
#include "revng/tests/unit/ModelType.inc"