diff options
author | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2021-08-20 10:25:11 +0000 |
---|---|---|
committer | Andrzej Warzynski <andrzej.warzynski@arm.com> | 2021-08-21 15:18:48 +0000 |
commit | 787c443a8da7add81d8ff7d430afcac16a1e4b0c (patch) | |
tree | 6a27dc7a99398957306ccb77e9e4dfad174c8987 /flang/CMakeLists.txt | |
parent | 2cc1198e36d042f9a5cd8d66773d7e85d1d0c62f (diff) | |
download | llvm-787c443a8da7add81d8ff7d430afcac16a1e4b0c.tar.gz |
[flang] Refine output file generation
This patch cleans-up the file generation code in Flang's frontend
driver. It improves the layering between
`CompilerInstance::CreateDefaultOutputFile`,
`CompilerInstance::CreateOutputFile` and their various clients.
* Rename `CreateOutputFile` as `CreateOutputFileImpl` and make it
private. This method is an implementation detail.
* Instead of passing an `std::error_code` out parameter into
`CreateOutputFileImpl`, have it return Expected<>. This is a bit shorter
and idiomatic LLVM.
* Make `CreateDefaultOutputFile` (which calls `CreateOutputFileImpl`)
issue an error when file creation fails. The error code from
`CreateOutputFileImpl` is used to generate a meaningful diagnostic
message.
* Remove error reporting from `PrintPreprocessedAction::ExecuteAction`.
This is only for cases when output file generation fails. This is
handled in `CreateDefaultOutputFile` instead (see the previous point).
* Inline `AddOutputFile` into its only caller,
`CreateDefaultOutputFile`.
* Switch from `lvm::buffer_ostream` to `llvm::buffer_unique_ostream>`
for non-seekable output streams. This simplifies the logic in the driver
and was introduced for this very reason in [1]
* Moke sure that the diagnostics from the prescanner when running `-E`
(`PrintPreprocessedAction::ExecuteAction`) are printed before the actual
output is generated.
* Update comments, add test.
NOTE: This patch relands [2]. As suggested by Michael Kruse in the
post-commit/post-revert review, I've added the following:
```
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
```
in Flang's `lit.site.cfg.py.in`. This way, `%errc_ENOENT` in
output-paths.f90 gets the correct value on Windows as well as on Linux.
[1] https://reviews.llvm.org/D93260
[2] fd21d1e198e381a2b9e7af1701044462b2d386cd
Reviewed By: ashermancinelli
Differential Revision: https://reviews.llvm.org/D108390
Diffstat (limited to 'flang/CMakeLists.txt')
-rw-r--r-- | flang/CMakeLists.txt | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f17816ee29b8..f5e602b6b844 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -72,6 +72,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) include(AddLLVM) include(HandleLLVMOptions) include(VersionFromVCS) + include(GetErrcMessages) include(AddClang) @@ -132,6 +133,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) "Generate build targets for the Flang unit tests." ON) + get_errc_messages(LLVM_LIT_ERRC_MESSAGES) + #Handle unittests when out-of-tree #LLVM_BUILD_MAIN_SRC_DIR - Path to llvm source when out-of-tree. set(FLANG_GTEST_AVAIL 0) |