[llvm-commits] [PATCH] New Path API design.
Michael Spencer
bigcheesegs at gmail.com
Fri Nov 19 11:56:02 PST 2010
Attached is my design for a new filesystem library to replace sys::Path. It is
based on the TR2 filesystem proposal, which is based on boost. The interface
looks similar, but has been significantly changed to remove exceptions.
These are the main changes:
* Use error_code instead of filesystem_error exceptions. This is a significant
change to the API, which is why...
* Functions always place their results into reference arguments and return an
error_code. The alternative of returning the result and then the error_code
as a function argument has also been considered; however, this allows for
function chains in which we loose the original error_code by the time the
statement is over.
* Remove the actual path class. Instead Twine, StringRef, and SmallString are
used depending on the argument. This makes the main part of the path API
stateless, and removes all that std::string allocation and copying we had
before.
The only LLVM specific functions that remain have kept their name, but have
adopted the new return error_code semantics.
These are:
error_code GetSystemLibraryPaths(SmallVectorImpl<SmallString<64> > &result);
error_code GetBitcodeLibraryPaths(SmallVectorImpl<SmallString<64> > &result);
error_code FindLibrary(Twine short_name, SmallVectorImpl<char> &result);
error_code GetMainExecutable(const char *argv0, void *MainAddr,
SmallVectorImpl<char> &result);
The rest of the old Path functions are no longer needed except for the map and
unmap functions which I really need to take a look at for what I'll need in the
object library in addition to what they already provide.
My plan is to first get an agreement over the API. Then commit the header. Then
the implementations. The final and longest step will be actually transitioning
over to the use of this API.
Attached is a overview of the API with extra comments where needed. I
welcome any
and all comments on it.
- Michael Spencer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filesystem-design.patch
Type: application/octet-stream
Size: 12154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101119/0de2fb20/attachment.obj>
More information about the llvm-commits
mailing list