[llvm] [Support] Add WrappedError class (PR #191706)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 05:43:11 PDT 2026
aokblast wrote:
> I feel this is a one-consumer hack dressed up as a general primitive... I think we should close this one, focus on 191708, and if we find a generalizable pattern, reopen this PR.
>
> For 191708, we can introduce this helper
>
> ```c++
> void ObjDumper::reportUniqueWarning(const Twine &Key,
> const Twine &Message) const {
> SmallString<128> KeyStorage;
> if (!Warnings.insert(Key.toStringRef(KeyStorage).str()).second)
> return; // duplicate — drop it
> reportWarning(createStringError(object::object_error::parse_failed, Message),
> ObjName);
> }
> ```
This helper is not enough, readelf pass WarnHandler to functions in Support/ELF.h since it also want to catch and deduplicate the error from ELF class. I think it would be better if we have some wrapped error stuff instead of modifying WarnHandler to accept two strings. See: https://github.com/llvm/llvm-project/pull/191707
https://github.com/llvm/llvm-project/pull/191706
More information about the llvm-commits
mailing list