Skip to content

Commit 415352e

Browse files
Fix for issue 1440 (#180) (#187)
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.
1 parent 97b6ab9 commit 415352e

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

clang/lib/Driver/ToolChains/ClassicFlang.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,35 @@ void ClassicFlang::ConstructJob(Compilation &C, const JobAction &JA,
240240
}
241241
}
242242

243-
// Treat backslashes as regular characters
244-
for (auto Arg : Args.filtered(options::OPT_fno_backslash, options::OPT_Mbackslash)) {
245-
Arg->claim();
243+
if (auto *A =
244+
Args.getLastArg(options::OPT_fno_backslash, options::OPT_Mbackslash,
245+
options::OPT_fbackslash, options::OPT_Mnobackslash)) {
246+
for (auto Arg :
247+
Args.filtered(options::OPT_fno_backslash, options::OPT_Mbackslash,
248+
options::OPT_fbackslash, options::OPT_Mnobackslash)) {
249+
Arg->claim();
250+
}
251+
// Treat backslashes as regular characters
252+
if (A->getOption().matches(options::OPT_fno_backslash) ||
253+
A->getOption().matches(options::OPT_Mbackslash)) {
254+
CommonCmdArgs.push_back("-x");
255+
CommonCmdArgs.push_back("124");
256+
CommonCmdArgs.push_back("0x40");
257+
}
258+
// Treat backslashes as C-style escape characters
259+
if (A->getOption().matches(options::OPT_fbackslash) ||
260+
A->getOption().matches(options::OPT_Mnobackslash)) {
261+
CommonCmdArgs.push_back("-y");
262+
CommonCmdArgs.push_back("124");
263+
CommonCmdArgs.push_back("0x40");
264+
}
265+
} else {
266+
// By default treat backslashes as regular characters
246267
CommonCmdArgs.push_back("-x");
247268
CommonCmdArgs.push_back("124");
248269
CommonCmdArgs.push_back("0x40");
249270
}
250271

251-
// Treat backslashes as C-style escape characters
252-
for (auto Arg : Args.filtered(options::OPT_fbackslash, options::OPT_Mnobackslash)) {
253-
Arg->claim();
254-
CommonCmdArgs.push_back("-y");
255-
CommonCmdArgs.push_back("124");
256-
CommonCmdArgs.push_back("0x40");
257-
}
258-
259272
// handle OpemMP options
260273
if (auto *A = Args.getLastArg(options::OPT_mp, options::OPT_nomp,
261274
options::OPT_fopenmp, options::OPT_fno_openmp)) {

0 commit comments

Comments
 (0)