Skip to content

Commit b50e2c5

Browse files
shivaramaaraobryanpkc
authored andcommitted
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 35688ff commit b50e2c5

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
@@ -241,22 +241,35 @@ void ClassicFlang::ConstructJob(Compilation &C, const JobAction &JA,
241241
}
242242
}
243243

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

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

0 commit comments

Comments
 (0)