diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h --- a/flang/include/flang/Frontend/FrontendOptions.h +++ b/flang/include/flang/Frontend/FrontendOptions.h @@ -35,6 +35,14 @@ /// 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 --- 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 @@ /// \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 --- 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 --- 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 --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -84,19 +84,4 @@ 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