[all-commits] [llvm/llvm-project] 7809fa: [flang][driver] Add support for `-D`, `-U`

Faris via All-commits all-commits at lists.llvm.org
Wed Jan 6 08:22:23 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7809fa20400000fd40b4a4b56696c7fbcd0f0fa9
      https://github.com/llvm/llvm-project/commit/7809fa20400000fd40b4a4b56696c7fbcd0f0fa9
  Author: Faris Rehman <faris.rehman at arm.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Flang.cpp
    M clang/lib/Driver/ToolChains/Flang.h
    M flang/include/flang/Frontend/CompilerInstance.h
    M flang/include/flang/Frontend/CompilerInvocation.h
    A flang/include/flang/Frontend/PreprocessorOptions.h
    M flang/lib/Frontend/CompilerInstance.cpp
    M flang/lib/Frontend/CompilerInvocation.cpp
    M flang/test/Flang-Driver/driver-help-hidden.f90
    M flang/test/Flang-Driver/driver-help.f90
    A flang/test/Flang-Driver/macro_def_undef.f90
    A flang/test/Flang-Driver/macro_multiline.f90

  Log Message:
  -----------
  [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




More information about the All-commits mailing list