CarolineConcatto updated this revision to Diff 261451.
CarolineConcatto marked 3 inline comments as done.
CarolineConcatto added a comment.

This patch updates the flag name from ffc-fortran-name to cfc-fortran-name,
where cfc stands for custom frontend compiler.

Moreover, the tests need pruning to test cfc-frotran-name flag output.
The tests check if the flang frontend being called is "flang" or the
one passed by the flag -cfc-fortran-name.


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/custom_frontend_flang.f90
  clang/test/Driver/flang/driver-2-frontend01.f90
  clang/test/Driver/flang/driver-2-frontend02.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
===================================================================
--- clang/test/Driver/flang/flang-driver-2-frontend02.f90
+++ /dev/null
@@ -1,19 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name has flang, but the flag -ffc-fortran-name is passed by the driver.
-! The flag has preference over any other name that the Driver may have.
-! Therefore the driver invokes the FE given by the flag.
-
-! The invocations should begin with <test-file-name>.tmp2 -fc1.
-! ALL-LABEL: "{{[^"]*}}flang-driver-2-frontend02.f90.tmp2" "-fc1"
-
-! 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 -ffc-fortran-name %basename_t.tmp2 -### %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}flang-driver-2-frontend02.f90"{{$}}
Index: clang/test/Driver/flang/flang-driver-2-frontend01.f90
===================================================================
--- clang/test/Driver/flang/flang-driver-2-frontend01.f90
+++ /dev/null
@@ -1,16 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name has flang, therefore the Driver invokes FE
-! with the same name as the driver.
-
-! The invocations should begin with <test-file-name>.tmp1 -fc1.
-! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
-
-! 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,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}flang-driver-2-frontend01.f90"{{$}}
Index: clang/test/Driver/flang/driver-2-frontend02.f90
===================================================================
--- clang/test/Driver/flang/driver-2-frontend02.f90
+++ /dev/null
@@ -1,19 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name is a randon name. It does not contain flang or clang,
-! but the driver gives a flag with the desired FE to be used.
-! Therefore it should use the FE given by the flag.
-
-! The invocations should begin with <path-test-name>.tmp2 -fc1.
-! ALL-LABEL: "{{[^"]*}}driver-2-frontend02.f90.tmp2" "-fc1"
-
-! 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 -### -ffc-fortran-name %basename_t.tmp2 %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}driver-2-frontend02.f90"{{$}}
Index: clang/test/Driver/flang/driver-2-frontend01.f90
===================================================================
--- clang/test/Driver/flang/driver-2-frontend01.f90
+++ /dev/null
@@ -1,18 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name is a randon name. It does not contain flag, flang or clang,
-! therefore the driver invokes flang FE.
-
-! The invocations should begin with flang -fc1.
-! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
-
-! Copy clang to two temporary file
-! t1 is the new driver name.
-! RUN: cp %clang %t1
-! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}driver-2-frontend01.f90"{{$}}
-
Index: clang/test/Driver/flang/custom_frontend_flang.f90
===================================================================
--- /dev/null
+++ clang/test/Driver/flang/custom_frontend_flang.f90
@@ -0,0 +1,10 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! The flag -cfc-flang-name is passed by the driver.
+! The flag has preference over "flang" frontend.
+! Therefore the driver invokes the FE given by the flag.
+
+! RUN: %clang --driver-mode=flang -cfc-flang-name alternative_fortran_frontend -### %s 2>&1 | FileCheck %s
+
+! The invocations should begin with <test-file-name>.tmp1 -fc1.
+! CHECK: "{{[^"]*}}alternative_fortran_frontend" "-fc1"
Index: clang/test/Driver/flang/clang-driver-2-frontend01.f90
===================================================================
--- clang/test/Driver/flang/clang-driver-2-frontend01.f90
+++ /dev/null
@@ -1,18 +0,0 @@
-! Check wich name of flang frontend is invoked by the driver
-
-! Driver name has clang, but the flag -ffc-fortran-name is passed by the driver.
-! The flag has preference over any other name that the Driver may have.
-! Therefore the driver invokes the FE given by the flag.
-
-! The invocations should begin with <test-file-name>.tmp1 -fc1.
-! ALL-LABEL: "{{[^"]*}}clang-driver-2-frontend01.f90.tmp1" "-fc1"
-
-! Copy clang to two temporary file
-! t1 is the new frontend name.
-! RUN: cp %clang %t1
-! RUN: %clang --driver-mode=flang -ffc-fortran-name %basename_t.tmp1 -### %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
-! CHECK-EMIT-OBJ-DAG: "-emit-obj"
-! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
-
-! Should end in the input file.
-! ALL: "{{.*}}clang-driver-2-frontend01.f90"{{$}}
Index: clang/lib/Driver/ToolChains/Flang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -68,7 +68,7 @@
   CmdArgs.push_back(Input.getFilename());
 
   const auto& D = C.getDriver();
-  const std::string &customFortranName = D.getFFCGenericFortranName();
+  const std::string &customFortranName = D.getGenericFortranFE();
   const char *FortranName;
   if (!customFortranName.empty())
     FortranName = customFortranName.c_str();
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -129,7 +129,7 @@
       CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
       CCCPrintBindings(false), CCPrintOptions(false), CCPrintHeaders(false),
       CCLogDiagnostics(false), CCGenDiagnostics(false),
-      TargetTriple(TargetTriple), CCCGenericGCCName(""), FFCGenericFortranName(""),
+      TargetTriple(TargetTriple), CCCGenericGCCName(""), GenericFortranFE(""),
       Saver(Alloc), CheckInputsExist(true), GenReproducer(false),
       SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no VFS is specified.
@@ -1089,9 +1089,9 @@
                     .Default(SaveTempsCwd);
   }
 
-  // Extract -ffc args.
-  if (const Arg *A = Args.getLastArg(options::OPT_fcc_fortran_name))
-    FFCGenericFortranName = A->getValue();
+  // Extract -cfc args.
+  if (const Arg *A = Args.getLastArg(options::OPT_cfc_flang_name))
+    GenericFortranFE = A->getValue();
 
   setLTOMode(Args);
 
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -264,8 +264,8 @@
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
   HelpText<"Name for native GCC compiler">,
   MetaVarName<"<gcc-path>">;
-def fcc_fortran_name : Separate<["-"], "ffc-fortran-name">, InternalDriverOpt,
-  HelpText<"Name for native Fortran compiler">;
+def cfc_flang_name : Separate<["-"], "cfc-flang-name">, InternalDriverOpt,
+  HelpText<"Name for a custom frontend compiler(cfc) for flang">;
 
 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
@@ -219,7 +219,7 @@
   std::string CCCGenericGCCName;
 
   /// Name to use when invoking flang.
-  std::string FFCGenericFortranName;
+  std::string GenericFortranFE;
 
   /// Name of configuration file if used.
   std::string ConfigFile;
@@ -314,7 +314,7 @@
   const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
 
   /// Name to use when invoking flang.
-  const std::string &getFFCGenericFortranName() const { return FFCGenericFortranName; }
+  const std::string &getGenericFortranFE() const { return GenericFortranFE; }
 
   const std::string &getConfigFile() const { return ConfigFile; }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to