Skip to content

Commit

Permalink
Merge pull request #57 from vjayathirtha-nv/release_70
Browse files Browse the repository at this point in the history
Enable contiguous pointer checks in flang with -fsanitize option.
  • Loading branch information
schweitzpgi authored Feb 15, 2019
2 parents 192cf99 + 58a3ec2 commit 088552b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/clang/Basic/Sanitizers.def
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
SANITIZER("unreachable", Unreachable)
SANITIZER("vla-bound", VLABound)
SANITIZER("vptr", Vptr)
// fortran contiguous pointer checks
SANITIZER("discontiguous", Discontiguous)

// IntegerSanitizer
SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
Expand Down
19 changes: 19 additions & 0 deletions lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,25 @@ void FlangFrontend::ConstructJob(Compilation &C, const JobAction &JA,
CommonCmdArgs.push_back("2");
}

// Contiguous pointer checks
if (Arg *A = Args.getLastArg(options::OPT_fsanitize_EQ)) {
for (const StringRef &val : A->getValues()) {
if (val.equals("discontiguous") || val.equals("undefined") ) {
// -x 54 0x40 -x 54 0x80 -x 54 0x200
UpperCmdArgs.push_back("-x");
UpperCmdArgs.push_back("54");
UpperCmdArgs.push_back("0x2c0");

// -fsanitze=discontiguous has no meaning in LLVM, only flang driver needs to
// recognize it. However -fsanitize=undefined needs to be passed on for further
// processing by the non-flang part of the driver.
if (val.equals("discontiguous"))
A->claim();
break;
}
}
}

// Treat backslashes as regular characters
for (auto Arg : Args.filtered(options::OPT_fnobackslash, options::OPT_Mbackslash)) {
Arg->claim();
Expand Down

0 comments on commit 088552b

Please sign in to comment.