translate-c: change OutOfMemory → ASTUnitFailure

- return a better error when no diagnostics are available
master
Michael Dusan 2020-02-15 05:14:31 -05:00
parent b15958c557
commit 8583038640
No known key found for this signature in database
GPG Key ID: ED4C5BA849FA1B74
4 changed files with 5 additions and 1 deletions

View File

@ -92,6 +92,7 @@ const Error = extern enum {
InvalidCpuFeatures,
InvalidLlvmCpuFeaturesFormat,
UnknownApplicationBinaryInterface,
ASTUnitFailure,
};
const FILE = std.c.FILE;
@ -114,6 +115,7 @@ export fn stage2_translate_c(
out_errors_len.* = errors.len;
return Error.CCompileErrors;
},
error.ASTUnitFailure => return Error.ASTUnitFailure,
error.OutOfMemory => return Error.OutOfMemory,
};
return Error.None;

View File

@ -264,7 +264,7 @@ pub fn translate(
&errors.len,
resources_path,
) orelse {
if (errors.len == 0) return error.OutOfMemory;
if (errors.len == 0) return error.ASTUnitFailure;
return error.SemanticAnalyzeFail;
};
defer ZigClangASTUnit_delete(ast_unit);

View File

@ -64,6 +64,7 @@ const char *err_str(Error err) {
case ErrorInvalidCpuFeatures: return "invalid CPU features";
case ErrorInvalidLlvmCpuFeaturesFormat: return "invalid LLVM CPU features format";
case ErrorUnknownApplicationBinaryInterface: return "unknown application binary interface";
case ErrorASTUnitFailure: return "ASTUnit failure";
}
return "(invalid error)";
}

View File

@ -84,6 +84,7 @@ enum Error {
ErrorInvalidCpuFeatures,
ErrorInvalidLlvmCpuFeaturesFormat,
ErrorUnknownApplicationBinaryInterface,
ErrorASTUnitFailure,
};
// ABI warning