[PATCH] D49824: [Support] Introduce createStringError helper function

Lang Hames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 25 17:37:56 PDT 2018


lhames added a comment.

In https://reviews.llvm.org/D49824#1176015, @vleschuk wrote:

> In https://reviews.llvm.org/D49824#1176004, @JDevlieghere wrote:
>
> > Can you add a test for the case where no `Vals` are provided? I remember something about that requiring an overload without the variadic template arguments.
>
>
> Do you mean something like that the following?
>
>   logAllUnhandledErrors(createStringError("bar"), S, "");                         
>   EXPECT_EQ(S.str(), "bar\n") ;
>   
>
> I can add it but it will result in compiler warnings "warning: format string is not a string literal (potentially insecure) [-Wformat-security]" which is not looking good. We can temporary disable warnings for this test using compiler-specific pragmas but it will be very messy...


You can add an overload for the degenerate case to fix this:

  Error createStringError(std::error_code EC, char const *Msg) {
    return make_error<StringError>(Msg, EC);
  }


https://reviews.llvm.org/D49824





More information about the llvm-commits mailing list