[llvm] r270916 - [Error] Make ECError only constructible via errorCodeToError.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 14:24:42 PDT 2016


On Thu, May 26, 2016 at 2:15 PM, Lang Hames via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: lhames
> Date: Thu May 26 16:15:58 2016
> New Revision: 270916
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270916&view=rev
> Log:
> [Error] Make ECError only constructible via errorCodeToError.
>
> This enforces idiomatic usage of ECError removing the option to construct
> them
> using make_error.
>
>
> Modified:
>     llvm/trunk/include/llvm/Support/Error.h
>
> Modified: llvm/trunk/include/llvm/Support/Error.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=270916&r1=270915&r2=270916&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/Error.h (original)
> +++ llvm/trunk/include/llvm/Support/Error.h Thu May 26 16:15:58 2016
> @@ -835,9 +835,8 @@ private:
>  /// (or Expected) and you want to call code that still returns
>  /// std::error_codes.
>  class ECError : public ErrorInfo<ECError> {
> +  friend Error errorCodeToError(std::error_code);
>  public:
> -  ECError() = default;
> -  ECError(std::error_code EC) : EC(EC) {}
>    void setErrorCode(std::error_code EC) { this->EC = EC; }
>    std::error_code convertToErrorCode() const override { return EC; }
>    void log(raw_ostream &OS) const override { OS << EC.message(); }
> @@ -846,6 +845,8 @@ public:
>    static char ID;
>
>  protected:
> +  ECError() = default;
> +  ECError(std::error_code EC) : EC(EC) {}
>    std::error_code EC;
>  };
>
> @@ -853,7 +854,7 @@ protected:
>  inline Error errorCodeToError(std::error_code EC) {
>    if (!EC)
>      return Error::success();
> -  return make_error<ECError>(EC);
> +  return Error(llvm::make_unique<ECError>(ECError(EC)));
>

Do you have an extra "ECError" in there? Looks like it should be:

  return Error(llvm::make_unique<ECError>(EC));

?


>  }
>
>  /// Helper for converting an ECError to a std::error_code.
>
>
> _______________________________________________
> 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/20160526/f12182d4/attachment.html>


More information about the llvm-commits mailing list