[PATCH] D99292: [flang][driver] Add support for `-cpp/-nocpp`
Andrzej Warzynski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 24 12:21:37 PDT 2021
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added subscribers: jansvoboda11, dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This patch adds support for the `-cpp` and `-nocpp` flags. The
implemented semantics match f18 (i.e. the "throwaway" driver), but are
different to gfortran. In Flang the preprocessor is always run and
`-cpp/-nocpp` are only used to control whether standard macro
predefinitions are added or not. In practice this is sufficient to model
gfortran`s `-cpp/-nocpp`.
In the absence of `-cpp/-nocpp`, the driver will use the extension of
the input file to decide whether to include the standard macro
predefinitions. gfortran's documentation [1] was used to decide which
file extension to use for this. The extension for:
- predefined-macros-compiler-version.f90
had to be updated accordingly.
The logic mentioned above was added in FrontendAction::BeginSourceFile.
That's relatively late in the driver set-up, but this roughly where the
name of the input file becomes available. The logic for deciding between
fixed and free form works in an a similar way and was also moved to
FrontendAction::BeginSourceFile for consistency (and to reduce
code-duplication).
[1] https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99292
Files:
clang/include/clang/Driver/Options.td
flang/include/flang/Frontend/CompilerInvocation.h
flang/include/flang/Frontend/FrontendOptions.h
flang/include/flang/Frontend/PreprocessorOptions.h
flang/lib/Frontend/CompilerInstance.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendAction.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/Frontend/FrontendOptions.cpp
flang/test/Driver/cpp_nocpp.F90
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/predefined-macros-compiler-version.F90
flang/test/Driver/predefined-macros-compiler-version.f90
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99292.333085.patch
Type: text/x-patch
Size: 14667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210324/68f8008a/attachment.bin>
More information about the cfe-commits
mailing list