15 #include "llvm/Support/Alignment.h"
16 #include "llvm/Support/FileUtilities.h"
17 #include "llvm/Support/MemoryBuffer.h"
18 #include "llvm/Support/ToolOutputFile.h"
22 static std::unique_ptr<llvm::MemoryBuffer>
24 std::optional<llvm::Align> alignment) {
25 auto fileOrErr = llvm::MemoryBuffer::getFileOrSTDIN(
26 inputFilename,
false,
true,
28 if (std::error_code error = fileOrErr.getError()) {
30 *errorMessage =
"cannot open input file '" + inputFilename.str() +
31 "': " + error.message();
35 return std::move(*fileOrErr);
37 std::unique_ptr<llvm::MemoryBuffer>
42 std::unique_ptr<llvm::MemoryBuffer>
44 std::string *errorMessage) {
48 std::unique_ptr<llvm::ToolOutputFile>
50 std::error_code error;
51 auto result = std::make_unique<llvm::ToolOutputFile>(outputFilename, error,
52 llvm::sys::fs::OF_None);
55 *errorMessage =
"cannot open output file '" + outputFilename.str() +
56 "': " + error.message();
static std::unique_ptr< llvm::MemoryBuffer > openInputFileImpl(StringRef inputFilename, std::string *errorMessage, std::optional< llvm::Align > alignment)
Include the generated interface declarations.
std::unique_ptr< llvm::MemoryBuffer > openInputFile(llvm::StringRef inputFilename, std::string *errorMessage=nullptr)
Open the file specified by its name for reading.
std::unique_ptr< llvm::ToolOutputFile > openOutputFile(llvm::StringRef outputFilename, std::string *errorMessage=nullptr)
Open the file specified by its name for writing.