llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-flang-driver Author: None (TZT123-a11y) <details> <summary>Changes</summary> To maintain backward compatibility with the classic Flang compiler, support for the -Mextend compilation option has been added. Classic Flang uses the -Mextend option to allow fixed-format Fortran code to have a 132-column extended length, while modern Flang (based on LLVM) uses the -ffixed-line-length=132 option to achieve the same functionality. --- Full diff: https://github.com/llvm/llvm-project/pull/173833.diff 3 Files Affected: - (modified) clang/include/clang/Options/Options.td (+3) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1) - (modified) flang/lib/Frontend/CompilerInvocation.cpp (+20-1) ``````````diff diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index 8cd31a3be109a..9b99a1e90ceaa 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -7333,6 +7333,9 @@ def ffixed_line_length_EQ : Joined<["-"], "ffixed-line-length=">, Group<f_Group> DocBrief<[{Set column after which characters are ignored in typical fixed-form lines in the source file}]>; def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, Group<f_Group>, Alias<ffixed_line_length_EQ>; +def Mextend : Flag<["-"], "Mextend">, Group<f_Group>, + HelpText<"Classic Flang compat: Allow 132-column lines in fixed form">, + Visibility<[FC1Option, FlangOption]>; def fconvert_EQ : Joined<["-"], "fconvert=">, Group<f_Group>, HelpText<"Set endian conversion of data for unformatted files">; def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group<f_Group>, diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 558a27e5adcc5..bc65d392699cf 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -38,6 +38,7 @@ void Flang::addFortranDialectOptions(const ArgList &Args, ArgStringList &CmdArgs) const { Args.addAllArgs(CmdArgs, {options::OPT_ffixed_form, options::OPT_ffree_form, + options::OPT_Mextend, options::OPT_ffixed_line_length_EQ, options::OPT_fopenacc, options::OPT_finput_charset_EQ, diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index dd25cdc0e5707..7046e7eb6a690 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1546,10 +1546,29 @@ static bool parseLangOptionsArgs(CompilerInvocation &invoc, return success; } +static llvm::SmallVector<const char *> +replaceClassicFlangArgs(llvm::ArrayRef<const char *> CommandLineArgs) { + llvm::SmallVector<const char *> NewArgs; + for (auto Arg : CommandLineArgs) { + // Process -mextend -> mapping to -ffixed-line-length=132 + if (std::strcmp(Arg, "-Mextend") == 0) { + NewArgs.push_back("-ffixed-line-length=132"); + } + else { + NewArgs.push_back(Arg); + } + } + return NewArgs; +} + bool CompilerInvocation::createFromArgs( - CompilerInvocation &invoc, llvm::ArrayRef<const char *> commandLineArgs, + CompilerInvocation &invoc, llvm::ArrayRef<const char *> commandLineArgs0, clang::DiagnosticsEngine &diags, const char *argv0) { + auto NewCommandLineArgs = + replaceClassicFlangArgs(commandLineArgs0); + llvm::ArrayRef<const char *> commandLineArgs = NewCommandLineArgs; + bool success = true; // Set the default triple for this CompilerInvocation. This might be `````````` </details> https://github.com/llvm/llvm-project/pull/173833 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
