[PATCH] error_code for dynamically generated error messages

kledzik at apple.com kledzik at apple.com
Thu May 22 16:32:06 PDT 2014


Michael, I can see how ErrorOr<> could be improved.  But should we block this on that improvement?  Or is can we do this in lld in a way that is easy to update once ErrorOr<> is improved?  For instance, use ErrorOr<void> for return types instead of error_code and have all dynamic error strings constructed though one utility function that can be rewritten later?

================
Comment at: lib/Core/Error.cpp:182
@@ +181,3 @@
+    if (_messages.empty())
+      _messages.push_back("Success");
+    _messages.push_back(msg);
----------------
Rui Ueyama wrote:
> What is this for?
The value of zero is reserved to mean "no error".  The zeroth slot in the vector is lazily allocated.

================
Comment at: lib/Core/Error.cpp:190
@@ +189,3 @@
+  std::vector<std::string> _messages;
+  llvm::sys::SmartMutex<true> _mutex;
+};
----------------
Rui Ueyama wrote:
> Why don't you use std::mutex and std::lock_guard?
No good reason.  Why does llvm have is own Mutex if we now use C++11 that has std::mutex?

http://reviews.llvm.org/D3881






More information about the llvm-commits mailing list