[llvm] r264469 - [Object] Make MachOObjectFile's constructor private, provide a static create
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 10:51:26 PDT 2016
On Mon, Mar 28, 2016 at 4:50 AM, Rafael EspĂndola <
llvm-commits at lists.llvm.org> wrote:
> On 25 March 2016 at 17:59, Lang Hames via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: lhames
> > Date: Fri Mar 25 16:59:14 2016
> > New Revision: 264469
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=264469&view=rev
> > Log:
> > [Object] Make MachOObjectFile's constructor private, provide a static
> create
> > method instead.
> >
> > This is not quite a named constructor: Construction may fail, and
> > MachOObjectFiles are usually passed by unique_ptr anyway, so create
> > returns an Expected<std::unique_ptr<MachOObjectFile>>.
>
> This is awesome.
>
> > + if (Magic == "\xFE\xED\xFA\xCE")
> > + return expectedToErrorOr(
> > + MachOObjectFile::create(Buffer, false, false));
> > + else if (Magic == "\xCE\xFA\xED\xFE")
> > + return expectedToErrorOr(
> > + MachOObjectFile::create(Buffer, true, false));
> > + else if (Magic == "\xFE\xED\xFA\xCF")
> > + return expectedToErrorOr(
> > + MachOObjectFile::create(Buffer, false, true));
> > + else if (Magic == "\xCF\xFA\xED\xFE")
> > + return expectedToErrorOr(
> > + MachOObjectFile::create(Buffer, true, true));
> > + //else
> > + return object_error::parse_failed;
>
> You don't need the "else if" now that the returns are unconditional.
>
Good call - got that in r264599 (figured I'd pick up the slack since Lang's
out of town for a bit)
>
> Cheers,
> Rafael
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160328/b2b59fbf/attachment.html>
More information about the llvm-commits
mailing list