[flang][driver] Add support for `-D`, `-U`

Authored by FarisRehman on Jan 6 2021, 7:42 AM.


[flang][driver] Add support for -D, -U

Add support for options -D and -U in the new Flang driver.

Summary of changes:

  • Create PreprocessorOptions, to be used by the driver then translated into Fortran::parser::Options
  • Create CompilerInvocation::setFortranOpts to pass preprocessor options into the parser options
  • Add a dedicated method, Flang::AddPreprocessingOptions, to extract preprocessing options from the driver arguments into the preprocessor command arguments

Macros specified like -DName will default to definition 1.

When defining macros, the new driver will drop anything after an
end-of-line character. This is consistent with gfortran and clang, but
different to what currently f18 does. However, flang (which is a bash
wrapper for f18), also drops everything after an end-of-line character.
So gfortran-like behaviour felt like the natural choice. Test is added
to demonstrate this behaviour.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D93401