[clang][driver] Add basic --driver-mode=flang support for fortran
authorPeter Waller <peter.waller@arm.com>
Mon, 10 Jun 2019 13:12:43 +0000 (14:12 +0100)
committerPeter Waller <peter.waller@arm.com>
Wed, 30 Oct 2019 10:42:22 +0000 (10:42 +0000)
commit6bf55804924d5a1d902925ad080b1a2b57c5c75c
treec3e6f970ee38439b687e088f4cf4ac17ebce174d
parenta795bd96454402bbb4f5fcd186d4b112c8010000
[clang][driver] Add basic --driver-mode=flang support for fortran

This patch adds a new Flang mode. When in Flang mode, the driver will
invoke flang for fortran inputs instead of falling back to the GCC
toolchain as it would otherwise do.

The behaviour of other driver modes are left unmodified to preserve
backwards compatibility.

It is intended that a soon to be implemented binary in the flang project
will import libclangDriver and run the clang driver in the new flang
mode.

Please note that since the binary invoked by the driver is under
development, there will no doubt be further tweaks necessary in future
commits.

* Initial support is added for basic driver phases
  * -E, -fsyntax-only, -emit-llvm -S, -emit-llvm, -S, (none specified)
  * -### tests are added for all of the above
  * This is more than is supported by f18 so far, which will emit errors
    for those options which are unimplemented.

* A test is added that ensures that clang gives a reasonable error
  message if flang is not available in the path (without -###).

* Test that the driver accepts multiple inputs in --driver-mode=flang.

* Test that a combination of C and Fortran inputs run both clang and
  flang in --driver-mode=flang.

* clang/test/Driver/fortran.f95 is fixed to use the correct fortran
  comment character.

Differential revision: https://reviews.llvm.org/D63607
18 files changed:
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/ToolChain.h
clang/include/clang/Driver/Types.h
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Flang.cpp [new file with mode: 0644]
clang/lib/Driver/ToolChains/Flang.h [new file with mode: 0644]
clang/lib/Driver/Types.cpp
clang/test/Driver/flang/Inputs/one.f90 [new file with mode: 0644]
clang/test/Driver/flang/Inputs/other.c [new file with mode: 0644]
clang/test/Driver/flang/Inputs/two.f90 [new file with mode: 0644]
clang/test/Driver/flang/flang.F90 [new file with mode: 0644]
clang/test/Driver/flang/flang.f90 [new file with mode: 0644]
clang/test/Driver/flang/multiple-inputs-mixed.f90 [new file with mode: 0644]
clang/test/Driver/flang/multiple-inputs.f90 [new file with mode: 0644]
clang/test/Driver/fortran.f95
clang/test/Driver/lit.local.cfg