[clang][driver] Add basic --driver-mode=flang support for fortran

Authored by peterwaller-arm on Jun 10 2019, 6:12 AM.


[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

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

  • 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