[PATCH] D120002: [lld] Make error handling functions opaque

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 20:30:39 PST 2022


MaskRay created this revision.
MaskRay added reviewers: lld-macho, inglorion, int3.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The inline `lld::error` expands to two function calls `errorHandler` and `error`
where the latter is opaque. Move the functions to .cpp files to decrease code
size.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120002

Files:
  lld/Common/ErrorHandler.cpp
  lld/include/lld/Common/ErrorHandler.h


Index: lld/include/lld/Common/ErrorHandler.h
===================================================================
--- lld/include/lld/Common/ErrorHandler.h
+++ lld/include/lld/Common/ErrorHandler.h
@@ -143,17 +143,13 @@
 /// Returns the default error handler.
 ErrorHandler &errorHandler();
 
-inline void error(const Twine &msg) { errorHandler().error(msg); }
-inline void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args) {
-  errorHandler().error(msg, tag, args);
-}
-[[noreturn]] inline void fatal(const Twine &msg) { errorHandler().fatal(msg); }
-inline void log(const Twine &msg) { errorHandler().log(msg); }
-inline void message(const Twine &msg, llvm::raw_ostream &s = outs()) {
-  errorHandler().message(msg, s);
-}
-inline void warn(const Twine &msg) { errorHandler().warn(msg); }
-inline uint64_t errorCount() { return errorHandler().errorCount; }
+void error(const Twine &msg);
+void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args);
+[[noreturn]] void fatal(const Twine &msg);
+void log(const Twine &msg);
+void message(const Twine &msg, llvm::raw_ostream &s = outs());
+void warn(const Twine &msg);
+uint64_t errorCount();
 
 [[noreturn]] void exitLld(int val);
 
Index: lld/Common/ErrorHandler.cpp
===================================================================
--- lld/Common/ErrorHandler.cpp
+++ lld/Common/ErrorHandler.cpp
@@ -53,6 +53,18 @@
 
 ErrorHandler &lld::errorHandler() { return context().e; }
 
+void lld::error(const Twine &msg) { errorHandler().error(msg); }
+void lld::error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args) {
+  errorHandler().error(msg, tag, args);
+}
+void lld::fatal(const Twine &msg) { errorHandler().fatal(msg); }
+void lld::log(const Twine &msg) { errorHandler().log(msg); }
+void lld::message(const Twine &msg, llvm::raw_ostream &s) {
+  errorHandler().message(msg, s);
+}
+void lld::warn(const Twine &msg) { errorHandler().warn(msg); }
+uint64_t lld::errorCount() { return errorHandler().errorCount; }
+
 raw_ostream &lld::outs() {
   ErrorHandler &e = errorHandler();
   return e.outs();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120002.409476.patch
Type: text/x-patch
Size: 2086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220217/46e84759/attachment.bin>


More information about the llvm-commits mailing list