Skip to content

Commit 088552b

Browse files
authored
Merge pull request #57 from vjayathirtha-nv/release_70
Enable contiguous pointer checks in flang with -fsanitize option.
2 parents 192cf99 + 58a3ec2 commit 088552b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

include/clang/Basic/Sanitizers.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
9393
SANITIZER("unreachable", Unreachable)
9494
SANITIZER("vla-bound", VLABound)
9595
SANITIZER("vptr", Vptr)
96+
// fortran contiguous pointer checks
97+
SANITIZER("discontiguous", Discontiguous)
9698

9799
// IntegerSanitizer
98100
SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)

lib/Driver/ToolChains/Flang.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ void FlangFrontend::ConstructJob(Compilation &C, const JobAction &JA,
185185
CommonCmdArgs.push_back("2");
186186
}
187187

188+
// Contiguous pointer checks
189+
if (Arg *A = Args.getLastArg(options::OPT_fsanitize_EQ)) {
190+
for (const StringRef &val : A->getValues()) {
191+
if (val.equals("discontiguous") || val.equals("undefined") ) {
192+
// -x 54 0x40 -x 54 0x80 -x 54 0x200
193+
UpperCmdArgs.push_back("-x");
194+
UpperCmdArgs.push_back("54");
195+
UpperCmdArgs.push_back("0x2c0");
196+
197+
// -fsanitze=discontiguous has no meaning in LLVM, only flang driver needs to
198+
// recognize it. However -fsanitize=undefined needs to be passed on for further
199+
// processing by the non-flang part of the driver.
200+
if (val.equals("discontiguous"))
201+
A->claim();
202+
break;
203+
}
204+
}
205+
}
206+
188207
// Treat backslashes as regular characters
189208
for (auto Arg : Args.filtered(options::OPT_fnobackslash, options::OPT_Mbackslash)) {
190209
Arg->claim();

0 commit comments

Comments
 (0)