[PATCH] D88381: [Flang][Driver]Add PrintPreprocessedInput action `-E`

Caroline via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 27 10:33:18 PDT 2020


CarolineConcatto created this revision.
Herald added subscribers: cfe-commits, dang, mgorny.
Herald added a reviewer: DavidTruby.
Herald added a reviewer: sscalpone.
Herald added a project: clang.
CarolineConcatto requested review of this revision.

This patch runs Preprocess and PrintProcess actions for Fortran
files.

It makes use of Fortran::parser to run preprocessing for Fortran file and
print them. The two functions are:
`Fortran::parser::Prescan`  and
`Fortran::parser::DumpCookedChars`

This patch assumes that all files need to run preprocessing before running
other action. The PrintPreprocessedInput only prints the files. This is
compatible with the through away driver.

It does not map the driver options(clang::driver::options) to
Fortran::parser::options to be used by Fortran::parser::Prescan.
However, it sets Frotran::parser::options to:
`searchDirectories ` to the current directory
`encoding` to UTF_8
`isFixedForm`
These default settings are compatible with the trough away driver.
Further work needs to be done in CompilerInvocation to read and map
clang::driver::options to Fortran::parser::options.

Depends on D87989 <https://reviews.llvm.org/D87989>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88381

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendAction.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Frontend/Inputs/hello-world.c
  flang/test/Frontend/print-preprocess-C-file.f90
  flang/test/Frontend/print-preprocessed-file.f90
  flang/unittests/Frontend/CMakeLists.txt
  flang/unittests/Frontend/CompilerInstanceTest.cpp
  flang/unittests/Frontend/PrintPreprocessedTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88381.294557.patch
Type: text/x-patch
Size: 17719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200927/90289faf/attachment-0001.bin>


More information about the cfe-commits mailing list