[Mlir-commits] [mlir] [mlir] Add support for multi-parts diagnostics (PR #217804)
lonely eagle
llvmlistbot at llvm.org
Thu Sep 24 07:45:46 PDT 2026
linuxlonelyeagle wrote:
> I'm seeing a compiler error:
>
> ```
> .../mlir/lib/IR/Diagnostics.cpp:209:10: error: could not convert ‘strs’ from ‘SmallVector<[...],2>’ to ‘SmallVector<[...],1>’
> 209 | return strs;
> | ^~~~
> | |
> | SmallVector<[...],2>
> ```
>
> This patch seems to fix the problem:
>
> ```diff
> diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h
> index aae14b3d6e9e..ee96ac32b82d 100644
> --- a/mlir/include/mlir/IR/Diagnostics.h
> +++ b/mlir/include/mlir/IR/Diagnostics.h
> @@ -264,7 +264,7 @@ public:
>
> /// Converts each message part to a separate string. Returns a single string
> /// if the diagnostic has not been divided into multiple parts.
> - SmallVector<std::string> strs() const;
> + SmallVector<std::string, 2> strs() const;
>
> /// Attaches a note to this diagnostic. A new location may be optionally
> /// provided, if not, then the location defaults to the one specified for this
> diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
> index 81e666db4856..16dab0ceacb3 100644
> --- a/mlir/lib/IR/Diagnostics.cpp
> +++ b/mlir/lib/IR/Diagnostics.cpp
> @@ -192,7 +192,7 @@ std::string Diagnostic::str() const {
> }
>
> /// Converts each message part to a separate string.
> -SmallVector<std::string> Diagnostic::strs() const {
> +SmallVector<std::string, 2> Diagnostic::strs() const {
> SmallVector<std::string, 2> strs;
> size_t numMessageParts = messagePartEnds.size();
> ```
>
> Is it just me who sees this?
The issue you mentioned here has already been resolved in https://github.com/llvm/llvm-project/pull/226011.
https://github.com/llvm/llvm-project/pull/217804
More information about the Mlir-commits
mailing list