@@ -1176,7 +1176,7 @@ Error createStringError(std::error_code EC, char const *Msg);
1176
1176
// / show more detailed information to the user.
1177
1177
class FileError final : public ErrorInfo<FileError> {
1178
1178
1179
- friend Error createFileError (std::string , Error);
1179
+ friend Error createFileError (const Twine & , Error);
1180
1180
1181
1181
public:
1182
1182
void log (raw_ostream &OS) const override {
@@ -1193,15 +1193,15 @@ class FileError final : public ErrorInfo<FileError> {
1193
1193
static char ID;
1194
1194
1195
1195
private:
1196
- FileError (std::string F, std::unique_ptr<ErrorInfoBase> E) {
1196
+ FileError (const Twine & F, std::unique_ptr<ErrorInfoBase> E) {
1197
1197
assert (E && " Cannot create FileError from Error success value." );
1198
1198
assert (!F.empty () &&
1199
1199
" The file name provided to FileError must not be empty." );
1200
- FileName = F;
1200
+ FileName = F. str () ;
1201
1201
Err = std::move (E);
1202
1202
}
1203
1203
1204
- static Error build (std::string F, Error E) {
1204
+ static Error build (const Twine & F, Error E) {
1205
1205
return Error (std::unique_ptr<FileError>(new FileError (F, E.takePayload ())));
1206
1206
}
1207
1207
@@ -1211,11 +1211,17 @@ class FileError final : public ErrorInfo<FileError> {
1211
1211
1212
1212
// / Concatenate a source file path and/or name with an Error. The resulting
1213
1213
// / Error is unchecked.
1214
- inline Error createFileError (std::string F, Error E) {
1214
+ inline Error createFileError (const Twine & F, Error E) {
1215
1215
return FileError::build (F, std::move (E));
1216
1216
}
1217
1217
1218
- Error createFileError (std::string F, ErrorSuccess) = delete;
1218
+ // / Concatenate a source file path and/or name with a std::error_code
1219
+ // / to form an Error object.
1220
+ inline Error createFileError (const Twine &F, std::error_code EC) {
1221
+ return createFileError (F, errorCodeToError (EC));
1222
+ }
1223
+
1224
+ Error createFileError (const Twine &F, ErrorSuccess) = delete;
1219
1225
1220
1226
// / Helper for check-and-exit error handling.
1221
1227
// /
0 commit comments