forked from OSchip/llvm-project
Improve fatal error message when an Attribute or Type wasn't initialized by a dialect (NFC)
The existing message hints that the dialect may not be loaded, but there is also the possibility that the dialect was loaded and the initialize() method didn't include the Type/Attribute.
This commit is contained in:
parent
49562d3dfe
commit
d0d991cd23
|
@ -179,10 +179,11 @@ public:
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!ctx->getAttributeUniquer().isParametricStorageInitialized(
|
if (!ctx->getAttributeUniquer().isParametricStorageInitialized(
|
||||||
T::getTypeID()))
|
T::getTypeID()))
|
||||||
llvm::report_fatal_error(llvm::Twine("can't create Attribute '") +
|
llvm::report_fatal_error(
|
||||||
llvm::getTypeName<T>() +
|
llvm::Twine("can't create Attribute '") + llvm::getTypeName<T>() +
|
||||||
"' because storage uniquer isn't initialized: "
|
"' because storage uniquer isn't initialized: the dialect was likely "
|
||||||
"the dialect was likely not loaded.");
|
"not loaded, or the attribute wasn't added with addAttributes<...>() "
|
||||||
|
"in the Dialect::initialize() method.");
|
||||||
#endif
|
#endif
|
||||||
return ctx->getAttributeUniquer().get<typename T::ImplType>(
|
return ctx->getAttributeUniquer().get<typename T::ImplType>(
|
||||||
[ctx](AttributeStorage *storage) {
|
[ctx](AttributeStorage *storage) {
|
||||||
|
@ -198,10 +199,11 @@ public:
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!ctx->getAttributeUniquer().isSingletonStorageInitialized(
|
if (!ctx->getAttributeUniquer().isSingletonStorageInitialized(
|
||||||
T::getTypeID()))
|
T::getTypeID()))
|
||||||
llvm::report_fatal_error(llvm::Twine("can't create Attribute '") +
|
llvm::report_fatal_error(
|
||||||
llvm::getTypeName<T>() +
|
llvm::Twine("can't create Attribute '") + llvm::getTypeName<T>() +
|
||||||
"' because storage uniquer isn't initialized: "
|
"' because storage uniquer isn't initialized: the dialect was likely "
|
||||||
"the dialect was likely not loaded.");
|
"not loaded, or the attribute wasn't added with addAttributes<...>() "
|
||||||
|
"in the Dialect::initialize() method.");
|
||||||
#endif
|
#endif
|
||||||
return ctx->getAttributeUniquer().get<typename T::ImplType>(T::getTypeID());
|
return ctx->getAttributeUniquer().get<typename T::ImplType>(T::getTypeID());
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,10 +170,11 @@ struct TypeUniquer {
|
||||||
get(MLIRContext *ctx, Args &&...args) {
|
get(MLIRContext *ctx, Args &&...args) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!ctx->getTypeUniquer().isParametricStorageInitialized(T::getTypeID()))
|
if (!ctx->getTypeUniquer().isParametricStorageInitialized(T::getTypeID()))
|
||||||
llvm::report_fatal_error(llvm::Twine("can't create type '") +
|
llvm::report_fatal_error(
|
||||||
llvm::getTypeName<T>() +
|
llvm::Twine("can't create type '") + llvm::getTypeName<T>() +
|
||||||
"' because storage uniquer isn't initialized: "
|
"' because storage uniquer isn't initialized: the dialect was likely "
|
||||||
"the dialect was likely not loaded.");
|
"not loaded, or the type wasn't added with addTypes<...>() "
|
||||||
|
"in the Dialect::initialize() method.");
|
||||||
#endif
|
#endif
|
||||||
return ctx->getTypeUniquer().get<typename T::ImplType>(
|
return ctx->getTypeUniquer().get<typename T::ImplType>(
|
||||||
[&](TypeStorage *storage) {
|
[&](TypeStorage *storage) {
|
||||||
|
@ -188,10 +189,11 @@ struct TypeUniquer {
|
||||||
get(MLIRContext *ctx) {
|
get(MLIRContext *ctx) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!ctx->getTypeUniquer().isSingletonStorageInitialized(T::getTypeID()))
|
if (!ctx->getTypeUniquer().isSingletonStorageInitialized(T::getTypeID()))
|
||||||
llvm::report_fatal_error(llvm::Twine("can't create type '") +
|
llvm::report_fatal_error(
|
||||||
llvm::getTypeName<T>() +
|
llvm::Twine("can't create type '") + llvm::getTypeName<T>() +
|
||||||
"' because storage uniquer isn't initialized: "
|
"' because storage uniquer isn't initialized: the dialect was likely "
|
||||||
"the dialect was likely not loaded.");
|
"not loaded, or the type wasn't added with addTypes<...>() "
|
||||||
|
"in the Dialect::initialize() method.");
|
||||||
#endif
|
#endif
|
||||||
return ctx->getTypeUniquer().get<typename T::ImplType>(T::getTypeID());
|
return ctx->getTypeUniquer().get<typename T::ImplType>(T::getTypeID());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue