Skip to content

Commit

Permalink
Fix for issue 1440 (#180) (#187)
Browse files Browse the repository at this point in the history
Through this commit Mbackslash will be the default option.
By default, escape characters are treated as regular characters unless Mnobackslash
is specified.

There is also the issue of treating both Mbackslash and Mnobackslash options independently.
This is addressed in this patch and the testcases in flang repository will test this feature.
  • Loading branch information
shivaramaarao authored Aug 7, 2024
1 parent 97b6ab9 commit 415352e
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions clang/lib/Driver/ToolChains/ClassicFlang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,35 @@ void ClassicFlang::ConstructJob(Compilation &C, const JobAction &JA,
}
}

// Treat backslashes as regular characters
for (auto Arg : Args.filtered(options::OPT_fno_backslash, options::OPT_Mbackslash)) {
Arg->claim();
if (auto *A =
Args.getLastArg(options::OPT_fno_backslash, options::OPT_Mbackslash,
options::OPT_fbackslash, options::OPT_Mnobackslash)) {
for (auto Arg :
Args.filtered(options::OPT_fno_backslash, options::OPT_Mbackslash,
options::OPT_fbackslash, options::OPT_Mnobackslash)) {
Arg->claim();
}
// Treat backslashes as regular characters
if (A->getOption().matches(options::OPT_fno_backslash) ||
A->getOption().matches(options::OPT_Mbackslash)) {
CommonCmdArgs.push_back("-x");
CommonCmdArgs.push_back("124");
CommonCmdArgs.push_back("0x40");
}
// Treat backslashes as C-style escape characters
if (A->getOption().matches(options::OPT_fbackslash) ||
A->getOption().matches(options::OPT_Mnobackslash)) {
CommonCmdArgs.push_back("-y");
CommonCmdArgs.push_back("124");
CommonCmdArgs.push_back("0x40");
}
} else {
// By default treat backslashes as regular characters
CommonCmdArgs.push_back("-x");
CommonCmdArgs.push_back("124");
CommonCmdArgs.push_back("0x40");
}

// Treat backslashes as C-style escape characters
for (auto Arg : Args.filtered(options::OPT_fbackslash, options::OPT_Mnobackslash)) {
Arg->claim();
CommonCmdArgs.push_back("-y");
CommonCmdArgs.push_back("124");
CommonCmdArgs.push_back("0x40");
}

// handle OpemMP options
if (auto *A = Args.getLastArg(options::OPT_mp, options::OPT_nomp,
options::OPT_fopenmp, options::OPT_fno_openmp)) {
Expand Down

0 comments on commit 415352e

Please sign in to comment.