aboutsummaryrefslogtreecommitdiff
path: root/flang/unittests/Frontend/CompilerInstanceTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-05-22[flang] Fix build after 9e306ad4 (#141134)Jan Svoboda1-3/+4
2024-09-17[flang] Tidy uses of raw_string_ostream (NFC)Youngsuk Kim1-1/+1
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
2023-12-13[flang] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2022-05-14[flang][driver] Switch to the MLIR coding style in the driver (nfc)Andrzej Warzynski1-3/+3
This patch re-factors the driver code in LLVM Flang (frontend + compiler) to use the MLIR style. For more context, please see: https://discourse.llvm.org/t/rfc-coding-style-in-the-driver/ Most changes here are rather self-explanatory. Accessors are renamed to be more consistent with the rest of LLVM (e.g. allSource --> getAllSources). Additionally, MLIR clang-tidy files are added in the affected directories. clang-tidy and clang-format files were copied from MLIR. Small additional changes are made to silence clang-tidy/clang-format warnings. [1] https://mlir.llvm.org/getting_started/DeveloperGuide/ Differential Revision: https://reviews.llvm.org/D125007
2021-01-20[flang][driver] Refactor one unit-test case to use fixtures (nfc)Andrzej Warzynski1-1/+1
Move the unit test from InputOutputTest.cpp to FrontendActionTest.cpp and re-implement it in terms of the FrontendActionTest fixture. This is just a small code clean-up and a continuation of: * https://reviews.llvm.org/D93544 Moving forward, we should try be implementing all unit-test cases for Flang's frontend actions in terms of FrontendActionTest. Reviewed By: sameeranjoshi Differential Revision: https://reviews.llvm.org/D94922
2020-11-02[flang][driver] Rename the accessors/mutators (NFC)Andrzej Warzynski1-1/+1
As per point 3 in [1]: ``` Accessor member functions are named with the non-public data member's name, less the trailing underscore. Mutator member functions are named set_... ``` Originally we just followed the LLVM's style, which is incompatible with Flang. This patch renames the accessors and mutators accordingly. `getDiagnostics` and `GetDiagnostics` are replaced with one accessor: `diagnostics`. `SetDiagnostics` was neither implemented nor used, so it's deleted. [1] https://github.com/llvm/llvm-project/blob/master/flang/docs/C++style.md#naming Differential Revision: https://reviews.llvm.org/D90300
2020-10-24[Flang][Driver] Add infrastructure for basic frontend actions and file I/OCaroline Concatto1-0/+46
This patch introduces the dependencies required to read and manage input files provided by the command line option. It also adds the infrastructure to create and write to output files. The output is sent to either stdout or a file (specified with the `-o` flag). Separately, in order to be able to test the code for file I/O, it adds infrastructure to create frontend actions. As a basic testable example, it adds the `InputOutputTest` FrontendAction. The sole purpose of this action is to read a file from the command line and print it either to stdout or the output file. This action is run by using the `-test-io` flag also introduced in this patch (available for `flang-new` and `flang-new -fc1`). With this patch: ``` flang-new -test-io input-file.f90 ``` will read input-file.f90 and print it in the output file. The `InputOutputTest` frontend action has been introduced primarily to facilitate testing. It is hidden from users (i.e. it's only displayed with `--help-hidden`). Currently Clang doesn’t have an equivalent action. `-test-io` is used to trigger the InputOutputTest action in the Flang frontend driver. This patch makes sure that “flang-new” forwards it to “flang-new -fc1" by creating a preprocessor job. However, in Flang.cpp, `-test-io` is passed to “flang-new -fc1” without `-E`. This way we make sure that the preprocessor is _not_ run in the frontend driver. This is the desired behaviour: `-test-io` should only read the input file and print it to the output stream. co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Differential Revision: https://reviews.llvm.org/D87989
2020-10-05[flang] Introduce DiagnosticConsumer classes in libflangFrontendAndrzej Warzynski1-2/+2
Currently Flang uses TextDiagnostic, TextDiagnosticPrinter & TestDiagnosticBuffer classes from Clang (more specifically, from libclangFrontend). This patch introduces simplified equivalents of these classes in Flang (i.e. it removes the dependency on libclangFrontend). Flang only needs these diagnostics classes for the compiler driver diagnostics. This is unlike in Clang in which similar diagnostic classes are used for e.g. Lexing/Parsing/Sema diagnostics. For this reason, the implementations introduced here are relatively basic. We can extend them in the future if this is required. This patch also enhances how the diagnostics are printed. In particular, this is the diagnostic that you'd get _before_ the changes introduced here (no text formatting): ``` $ bin/flang-new error: no input files ``` This is the diagnostic that you get _after_ the changes introduced here (in terminals that support it, the text is formatted - bold + red): ``` $ bin/flang-new flang-new: error: no input files ``` Tests are updated accordingly and options related to enabling/disabling color diagnostics are flagged as supported by Flang. Reviewed By: sameeranjoshi, CarolineConcatto Differential Revision: https://reviews.llvm.org/D87774
2020-09-24[flang][driver] Remove unnecessary includes in the unittest (NFC)Andrzej Warzynski1-5/+2
Differential Revision: https://reviews.llvm.org/D88219
2020-09-11[flang][driver] Add the new flang compiler and frontend driversCaroline Concatto1-0/+52
Summary: This is the first patch implementing the new Flang driver as outlined in [1], [2] & [3]. It creates Flang driver (`flang-new`) and Flang frontend driver (`flang-new -fc1`). These will be renamed as `flang` and `flang -fc1` once the current Flang throwaway driver, `flang`, can be replaced with `flang-new`. Currently only 2 options are supported: `-help` and `--version`. `flang-new` is implemented in terms of libclangDriver, defaulting the driver mode to `FlangMode` (added to libclangDriver in [4]). This ensures that the driver runs in Flang mode regardless of the name of the binary inferred from argv[0]. The design of the new Flang compiler and frontend drivers is inspired by it counterparts in Clang [3]. Currently, the new Flang compiler and frontend drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend. To identify Flang options, this patch adds FlangOption/FC1Option enums. Driver::printHelp is updated so that `flang-new` prints only Flang options. The new Flang driver is disabled by default. To enable it, set `-DBUILD_FLANG_NEW_DRIVER=ON` when configuring CMake and add clang to `LLVM_ENABLE_PROJECTS` (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”). [1] “RFC: new Flang driver - next steps” http://lists.llvm.org/pipermail/flang-dev/2020-July/000470.html [2] “RFC: Adding a fortran mode to the clang driver for flang” http://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html [3] “RFC: refactoring libclangDriver/libclangFrontend to share with Flang” http://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html [4] https://reviews.llvm.org/rG6bf55804924d5a1d902925ad080b1a2b57c5c75c co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Reviewed By: richard.barton.arm, sameeranjoshi Differential Revision: https://reviews.llvm.org/D86089