[lld] [ELF] Add context-aware diagnostic functions (PR #112319)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 10:15:47 PDT 2024
================
@@ -679,6 +681,25 @@ static inline void internalLinkerError(StringRef loc, const Twine &msg) {
llvm::getBugReportMsg());
}
+struct ELFSyncStream : SyncStream {
+ Ctx &ctx;
+ ELFSyncStream(Ctx &ctx, DiagLevel level)
+ : SyncStream(*ctx.e, level), ctx(ctx) {}
+};
+
+template <typename T>
+std::enable_if_t<!std::is_pointer_v<std::remove_reference_t<T>>,
+ const ELFSyncStream &>
+operator<<(const ELFSyncStream &s, T &&v) {
+ s.os << std::forward<T>(v);
+ return s;
+}
+
+ELFSyncStream Log(Ctx &ctx);
+ELFSyncStream Warn(Ctx &ctx);
+ELFSyncStream Err(Ctx &ctx);
----------------
smithp35 wrote:
If `Err` is the default, then perhaps `ErrAlways` for the non downgradeable variety. If it isn't as common it could have a longer name.
Alternatives: `ForceErr`, `PermErr`, `AlwaysErr`.
https://github.com/llvm/llvm-project/pull/112319
More information about the llvm-commits
mailing list