[lld] [ELF] Add context-aware diagnostic functions (PR #112319)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 22:00:58 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);
----------------
MaskRay wrote:
We prefer `errorOrWarn` to `error` and the former is used much more. The lengthy name problem can now be "fixed" as we are switching to `Err`.
I agree that we need a replacement for `lld::error` as well. Do you have a suggestion for the name?
https://github.com/llvm/llvm-project/pull/112319
More information about the llvm-commits
mailing list