[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
This commit is contained in:
Andrzej Warzynski 2021-01-19 14:24:20 +00:00
parent 71b6b010e6
commit cea3abc26f
5 changed files with 24 additions and 26 deletions

View File

@ -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:

View File

@ -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

View File

@ -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"

View File

@ -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;

View File

@ -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