Index: include/llvm/Support/Error.h =================================================================== --- include/llvm/Support/Error.h +++ include/llvm/Support/Error.h @@ -1171,7 +1171,7 @@ /// show more detailed information to the user. class FileError final : public ErrorInfo { - template + template friend Error createFileError(std::string, Err); public: @@ -1207,7 +1207,10 @@ /// Concatenate a source file path and/or name with an Error. The resulting /// Error is unchecked. -template +template ::value && + !std::is_base_of::value, + Err>::type> inline Error createFileError(std::string F, Err E) { return FileError::build(F, std::move(E)); } Index: unittests/Support/ErrorTest.cpp =================================================================== --- unittests/Support/ErrorTest.cpp +++ unittests/Support/ErrorTest.cpp @@ -874,6 +874,8 @@ }, ""); #endif + consumeError(createFileError("file.bin", Error::success())); + Error E1 = make_error(1); Error FE1 = createFileError("file.bin", std::move(E1)); EXPECT_EQ(toString(std::move(FE1)).compare("'file.bin': CustomError {1}"), 0);