15#include "mlir/IR/Diagnostics.h"
16#include "mlir/Support/FileUtilities.h"
17#include "llvm/Support/FileSystem.h"
18#include "llvm/Support/Path.h"
27 const llvm::Twine &suffix) {
28 if (llvm::sys::path::is_absolute(suffix)) {
30 suffix.toVector(base);
32 llvm::sys::path::append(base, suffix);
39 StringRef aRef(a.data(), a.size());
40 size_t e = std::min(aRef.size(), b.size());
48 auto sep = llvm::sys::path::get_separator();
49 StringRef sepRef(sep);
50 while (!a.empty() && !StringRef(a.data(), a.size()).ends_with(sepRef))
54std::unique_ptr<llvm::ToolOutputFile>
56 function_ref<InFlightDiagnostic()> emitError) {
58 SmallString<128> outputFilename(dirname);
60 auto outputDir = llvm::sys::path::parent_path(outputFilename);
63 std::error_code error = llvm::sys::fs::create_directories(outputDir);
65 emitError() <<
"cannot create output directory \"" << outputDir
66 <<
"\": " << error.message();
71 std::string errorMessage;
72 auto output = mlir::openOutputFile(outputFilename, &errorMessage);
74 emitError() << errorMessage;
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void makeCommonDirectoryPrefix(llvm::SmallVectorImpl< char > &a, StringRef b)
Truncate a in place to the longest common directory prefix of a and b, ensuring that the result ends ...
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.