[lld] [ELF] Add context-aware diagnostic functions (PR #112319)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 16:35:45 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);
----------------
aganea wrote:
Agree with the above. I think we should add a comment before these 4 functions, to explain in which situation they should be used, and what are the expectations.
https://github.com/llvm/llvm-project/pull/112319
More information about the llvm-commits
mailing list