38 function_ref<InFlightDiagnostic()> emitError) {
40 SmallString<128> outputFilename(dirname);
42 auto outputDir = llvm::sys::path::parent_path(outputFilename);
45 std::error_code error = llvm::sys::fs::create_directories(outputDir);
47 emitError() <<
"cannot create output directory \"" << outputDir
48 <<
"\": " << error.message();
53 std::string errorMessage;
54 auto output = mlir::openOutputFile(outputFilename, &errorMessage);
56 emitError() << errorMessage;
std::unique_ptr< llvm::ToolOutputFile > createOutputFile(StringRef filename, StringRef dirname, function_ref< InFlightDiagnostic()> emitError)
Creates an output file with the given filename in the specified directory.
void appendPossiblyAbsolutePath(llvm::SmallVectorImpl< char > &base, const llvm::Twine &suffix)
Append a path to an existing path, replacing it if the other path is absolute.