Author: Andrzej Warzynski Date: 2021-01-19T17:47:40Z New Revision: cea3abc26f7cbc4ec4cf4cf73b4cce5f926420a9
URL: https://github.com/llvm/llvm-project/commit/cea3abc26f7cbc4ec4cf4cf73b4cce5f926420a9 DIFF: https://github.com/llvm/llvm-project/commit/cea3abc26f7cbc4ec4cf4cf73b4cce5f926420a9.diff LOG: [flang][driver] Move isFixedFormSuffix and isFreeFormSuffix to flangFrontend isFixedFormSuffix and isFreeFormSuffix should be defined in flangFrontend rather than flangFrontendTool library. That's for 2 reasons: * these methods are used in flangFrontend rather than flangFrontendTool * flangFrontendTool depends on flangFrontend As mentioned in the post-commit review for D94228, without this change shared library builds fail. Differential Revision: https://reviews.llvm.org/D94968 Added: Modified: flang/include/flang/Frontend/FrontendOptions.h flang/include/flang/FrontendTool/Utils.h flang/lib/Frontend/FrontendAction.cpp flang/lib/Frontend/FrontendOptions.cpp flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp Removed: ################################################################################ diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h index 7add145971cf..9bebf6c8f35d 100644 --- a/flang/include/flang/Frontend/FrontendOptions.h +++ b/flang/include/flang/Frontend/FrontendOptions.h @@ -35,6 +35,14 @@ enum ActionKind { /// EmitCodeGenOnly, EmitAssembly, (...) }; +/// \param suffix The file extension +/// \return True if the file extension should be processed as fixed form +bool isFixedFormSuffix(llvm::StringRef suffix); + +/// \param suffix The file extension +/// \return True if the file extension should be processed as free form +bool isFreeFormSuffix(llvm::StringRef suffix); + inline const char *GetActionKindName(const ActionKind ak) { switch (ak) { case InputOutputTest: diff --git a/flang/include/flang/FrontendTool/Utils.h b/flang/include/flang/FrontendTool/Utils.h index 7ee7568e21de..d62c03d8dc0b 100644 --- a/flang/include/flang/FrontendTool/Utils.h +++ b/flang/include/flang/FrontendTool/Utils.h @@ -14,8 +14,6 @@ #ifndef LLVM_FLANG_FRONTENDTOOL_UTILS_H #define LLVM_FLANG_FRONTENDTOOL_UTILS_H -#include "llvm/ADT/StringRef.h" - namespace Fortran::frontend { class CompilerInstance; @@ -33,14 +31,6 @@ std::unique_ptr<FrontendAction> CreateFrontendAction(CompilerInstance &ci); /// \return - True on success. bool ExecuteCompilerInvocation(CompilerInstance *flang); -/// \param suffix The file extension -/// \return True if the file extension should be processed as fixed form -bool isFixedFormSuffix(llvm::StringRef suffix); - -/// \param suffix The file extension -/// \return True if the file extension should be processed as free form -bool isFreeFormSuffix(llvm::StringRef suffix); - } // end namespace Fortran::frontend #endif // LLVM_FLANG_FRONTENDTOOL_UTILS_H diff --git a/flang/lib/Frontend/FrontendAction.cpp b/flang/lib/Frontend/FrontendAction.cpp index 6da1e6191036..dad2da683860 100644 --- a/flang/lib/Frontend/FrontendAction.cpp +++ b/flang/lib/Frontend/FrontendAction.cpp @@ -9,6 +9,7 @@ #include "flang/Frontend/FrontendAction.h" #include "flang/Frontend/CompilerInstance.h" #include "flang/Frontend/FrontendActions.h" +#include "flang/Frontend/FrontendOptions.h" #include "flang/FrontendTool/Utils.h" #include "llvm/Support/Errc.h" diff --git a/flang/lib/Frontend/FrontendOptions.cpp b/flang/lib/Frontend/FrontendOptions.cpp index 8c206b308176..1f2668fd1e85 100644 --- a/flang/lib/Frontend/FrontendOptions.cpp +++ b/flang/lib/Frontend/FrontendOptions.cpp @@ -7,10 +7,24 @@ //===----------------------------------------------------------------------===// #include "flang/Frontend/FrontendOptions.h" -#include "flang/FrontendTool/Utils.h" using namespace Fortran::frontend; +bool Fortran::frontend::isFixedFormSuffix(llvm::StringRef suffix) { + // Note: Keep this list in-sync with flang/test/lit.cfg.py + return suffix == "f" || suffix == "F" || suffix == "ff" || suffix == "for" || + suffix == "FOR" || suffix == "fpp" || suffix == "FPP"; +} + +bool Fortran::frontend::isFreeFormSuffix(llvm::StringRef suffix) { + // Note: Keep this list in-sync with flang/test/lit.cfg.py + // TODO: Add Cuda Fortan files (i.e. `*.cuf` and `*.CUF`). + return suffix == "f77" || suffix == "f90" || suffix == "F90" || + suffix == "ff90" || suffix == "f95" || suffix == "F95" || + suffix == "ff95" || suffix == "f03" || suffix == "F03" || + suffix == "f08" || suffix == "F08" || suffix == "f18" || suffix == "F18"; +} + InputKind FrontendOptions::GetInputKindForExtension(llvm::StringRef extension) { if (isFixedFormSuffix(extension) || isFreeFormSuffix(extension)) { return Language::Fortran; diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 6bc63b071a9c..50c9fca0b882 100644 --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -84,19 +84,4 @@ bool ExecuteCompilerInvocation(CompilerInstance *flang) { return success; } -bool isFixedFormSuffix(llvm::StringRef suffix) { - // Note: Keep this list in-sync with flang/test/lit.cfg.py - return suffix == "f" || suffix == "F" || suffix == "ff" || suffix == "for" || - suffix == "FOR" || suffix == "fpp" || suffix == "FPP"; -} - -bool isFreeFormSuffix(llvm::StringRef suffix) { - // Note: Keep this list in-sync with flang/test/lit.cfg.py - // TODO: Add Cuda Fortan files (i.e. `*.cuf` and `*.CUF`). - return suffix == "f77" || suffix == "f90" || suffix == "F90" || - suffix == "ff90" || suffix == "f95" || suffix == "F95" || - suffix == "ff95" || suffix == "f03" || suffix == "F03" || - suffix == "f08" || suffix == "F08" || suffix == "f18" || suffix == "F18"; -} - } // namespace Fortran::frontend _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits