CarolineConcatto updated this revision to Diff 244635. CarolineConcatto added a comment.
- [Clang]Rename flag and update the tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73951/new/ https://reviews.llvm.org/D73951 Files: clang/include/clang/Driver/Driver.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Flang.cpp clang/test/Driver/flang/clang-driver-2-frontend01.f90 clang/test/Driver/flang/flang-driver-2-frontend01.f90 clang/test/Driver/flang/flang-driver-2-frontend02.f90
Index: clang/test/Driver/flang/flang-driver-2-frontend02.f90 =================================================================== --- /dev/null +++ clang/test/Driver/flang/flang-driver-2-frontend02.f90 @@ -0,0 +1,14 @@ +! Check wich name of flang frontend is invoked by the driver + +! The flag -fortran-fe is passed by the driver. +! The flag has preference over the predefined frontend "flang". +! Therefore the driver invokes the FE given by the flag. + +! Copy clang to two temporary file. +! t1 is the driver name. t2 is the frontend name +! RUN: cp %clang %t1 +! RUN: cp %clang %t2 +! RUN: %t1 --driver-mode=flang -fortran-fe %basename_t.tmp2 -### %s 2>&1 | FileCheck --check-prefixes=ALL %s + +! The invocations should begin with <test-file-name>.tmp2 -fc1. +! ALL-LABEL: "{{[^"]*}}flang-driver-2-frontend02.f90.tmp2" "-fc1" Index: clang/test/Driver/flang/flang-driver-2-frontend01.f90 =================================================================== --- /dev/null +++ clang/test/Driver/flang/flang-driver-2-frontend01.f90 @@ -0,0 +1,11 @@ +! Check wich name of flang frontend is invoked by the driver + +! The flag -fortran-fe is NOT passed by the driver. +! Therefore, it uses the predefined frontend "flang". + +! Copy clang to a temporary file to be the driver name +! RUN: cp %clang %t1 +! RUN: %t1 --driver-mode=flang -### %s 2>&1 | FileCheck --check-prefixes=ALL %s + +! The invocations should begin with <test-file-name>.tmp1 -fc1. +! ALL-LABEL: "{{[^"]*}}flang" "-fc1" Index: clang/test/Driver/flang/clang-driver-2-frontend01.f90 =================================================================== --- /dev/null +++ clang/test/Driver/flang/clang-driver-2-frontend01.f90 @@ -0,0 +1,13 @@ +! Check wich name of flang frontend is invoked by the driver + +! The flag -fortran-fe is passed by the driver. +! The flag has preference over "flang" frontend. +! Therefore the driver invokes the FE given by the flag. + +! Copy clang to two temporary file +! t1 is the new frontend name. +! RUN: cp %clang %t1 +! RUN: %clang --driver-mode=flang -fortran-fe %basename_t.tmp1 -### %s 2>&1 | FileCheck --check-prefixes=ALL %s + +! The invocations should begin with <test-file-name>.tmp1 -fc1. +! ALL-LABEL: "{{[^"]*}}clang-driver-2-frontend01.f90.tmp1" "-fc1" Index: clang/lib/Driver/ToolChains/Flang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Flang.cpp +++ clang/lib/Driver/ToolChains/Flang.cpp @@ -11,7 +11,6 @@ #include "CommonArgs.h" #include "clang/Driver/Options.h" - #include <cassert> using namespace clang::driver; @@ -69,7 +68,13 @@ CmdArgs.push_back(Input.getFilename()); const auto& D = C.getDriver(); - const char* Exec = Args.MakeArgString(D.GetProgramPath("flang", TC)); + const std::string &customFortranName = D.getGenericFortranFE(); + const char *FortranName; + if (!customFortranName.empty()) + FortranName = customFortranName.c_str(); + else FortranName = "flang"; + + const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(FortranName)); C.addCommand(std::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs)); } Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -128,8 +128,8 @@ CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr), CCCPrintBindings(false), CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false), CCGenDiagnostics(false), - TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc), - CheckInputsExist(true), GenReproducer(false), + TargetTriple(TargetTriple), CCCGenericGCCName(""), GenericFortranFE(""), + Saver(Alloc), CheckInputsExist(true), GenReproducer(false), SuppressMissingInputWarning(false) { // Provide a sane fallback if no VFS is specified. if (!this->VFS) @@ -1088,6 +1088,10 @@ .Default(SaveTempsCwd); } + // Extract -ffc args. + if (const Arg *A = Args.getLastArg(options::OPT_fortran_fe)) + GenericFortranFE = A->getValue(); + setLTOMode(Args); // Process -fembed-bitcode= flags. Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -264,6 +264,8 @@ def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt, HelpText<"Name for native GCC compiler">, MetaVarName<"<gcc-path>">; +def fortran_fe : Separate<["-"], "fortran-fe">, InternalDriverOpt, + HelpText<"Name for native Fortran compiler">; class InternalDebugOpt : Group<internal_debug_Group>, Flags<[DriverOption, HelpHidden, CoreOption]>; Index: clang/include/clang/Driver/Driver.h =================================================================== --- clang/include/clang/Driver/Driver.h +++ clang/include/clang/Driver/Driver.h @@ -218,6 +218,9 @@ /// Name to use when invoking gcc/g++. std::string CCCGenericGCCName; + /// Name to use when invoking flang. + std::string GenericFortranFE; + /// Name of configuration file if used. std::string ConfigFile; @@ -310,6 +313,9 @@ /// Name to use when invoking gcc/g++. const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; } + /// Name to use when invoking flang. + const std::string &getGenericFortranFE() const { return GenericFortranFE; } + const std::string &getConfigFile() const { return ConfigFile; } const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits