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/173828.diff 3 Files Affected: - (modified) clang/include/clang/Options/Options.td (+4) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1) - (modified) flang/lib/Frontend/CompilerInvocation.cpp (+24-2) ``````````diff diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index e55146f0c7823..296c22006057d 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -7316,6 +7316,10 @@ 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>; +// modify for dcc +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 2f5e93d139858..0570e830f26f3 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, // modify for dcc 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 b6c4e6303cdac..83d7d29fc13aa 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1526,10 +1526,32 @@ static bool parseLangOptionsArgs(CompilerInvocation &invoc, return success; } +// modify for dcc: begin +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; +} +// modify for dcc: end + bool CompilerInvocation::createFromArgs( - CompilerInvocation &invoc, llvm::ArrayRef<const char *> commandLineArgs, + CompilerInvocation &invoc, llvm::ArrayRef<const char *> commandLineArgs0, clang::DiagnosticsEngine &diags, const char *argv0) { - + // modify for dcc: begin + auto NewCommandLineArgs = + replaceClassicFlangArgs(commandLineArgs0); + llvm::ArrayRef<const char *> commandLineArgs = NewCommandLineArgs; + // modify for dcc: end + bool success = true; // Set the default triple for this CompilerInvocation. This might be `````````` </details> https://github.com/llvm/llvm-project/pull/173828 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
