[LLVMdev] Users of llvm::error_code all inherit from _do_message (original) (raw)
Justin Bogner mail at justinbogner.com
Fri Mar 14 14:52:28 PDT 2014
- Previous message: [LLVMdev] StructReturnToPointer in poolalloc failing with LLVM 3.4
- Next message: [LLVMdev] Users of llvm::error_code all inherit from _do_message
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
There are several libraries in LLVM that create their own error_code
categories, so that they can return errors in a consistent way and with
convenient messages.
To do this, these libraries create an error category type that inherits
from _do_message
in system_error.h. There are a number of ways that
this is wrong:
From the name, it's quite clear that _do_message is an implementation detail.
The only function defined in _do_message is specifically intended for system errors that report via errno, which is not what the custom categories are doing.
As far as I can tell, the custom categories are only inheriting from _do_message is apparently to get around the fact that error_category's constructor is private, and that _do_message is a friend class of error_category.
If we want to continue using error_code the way we currently are, I think the right thing to do here is to make error_category's constructor protected and stop inheriting from _do_message. Would anyone object to that?
- Previous message: [LLVMdev] StructReturnToPointer in poolalloc failing with LLVM 3.4
- Next message: [LLVMdev] Users of llvm::error_code all inherit from _do_message
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]