MLIR  16.0.0git
FileUtilities.h
Go to the documentation of this file.
1 //===- FileUtilities.h - utilities for working with files -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Common utilities for working with files.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_SUPPORT_FILEUTILITIES_H_
14 #define MLIR_SUPPORT_FILEUTILITIES_H_
15 
16 #include <memory>
17 #include <string>
18 
19 namespace llvm {
20 class MemoryBuffer;
21 class ToolOutputFile;
22 class StringRef;
23 } // namespace llvm
24 
25 namespace mlir {
26 
27 /// Open the file specified by its name for reading. Write the error message to
28 /// `errorMessage` if errors occur and `errorMessage` is not nullptr.
29 std::unique_ptr<llvm::MemoryBuffer>
30 openInputFile(llvm::StringRef inputFilename,
31  std::string *errorMessage = nullptr);
32 
33 /// Open the file specified by its name for writing. Write the error message to
34 /// `errorMessage` if errors occur and `errorMessage` is not nullptr.
35 std::unique_ptr<llvm::ToolOutputFile>
36 openOutputFile(llvm::StringRef outputFilename,
37  std::string *errorMessage = nullptr);
38 
39 } // namespace mlir
40 
41 #endif // MLIR_SUPPORT_FILEUTILITIES_H_
Include the generated interface declarations.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:221
std::unique_ptr< llvm::ToolOutputFile > openOutputFile(llvm::StringRef outputFilename, std::string *errorMessage=nullptr)
Open the file specified by its name for writing.
std::unique_ptr< llvm::MemoryBuffer > openInputFile(llvm::StringRef inputFilename, std::string *errorMessage=nullptr)
Open the file specified by its name for reading.