diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-01-28 07:20:44 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-01-28 07:20:44 +0000 |
commit | 3e335c118140c40b264a26b13e44af368514cb87 (patch) | |
tree | 840e7144138179adf8c208dc34037c1a06bda57e /lib/Driver/Tools.cpp | |
parent | b8d2441144557c1b20b89b524d7ac54dbfaac0db (diff) |
Print warning instead of error if optional ASan features are enabled w/o specifying -fsanitize=address
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r-- | lib/Driver/Tools.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 69340e62ae..e4be6935ea 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1447,7 +1447,8 @@ static bool UseRelaxAll(Compilation &C, const ArgList &Args) { SanitizerArgs::SanitizerArgs(const Driver &D, const ArgList &Args) : Kind(0), BlacklistFile(""), MsanTrackOrigins(false), AsanZeroBaseShadow(false) { - + unsigned AllKinds = 0; // All kinds of sanitizers that were turned on + // at least once (possibly, disabled further). for (ArgList::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) { unsigned Add, Remove; if (!parse(D, Args, *I, Add, Remove, true)) @@ -1455,6 +1456,7 @@ SanitizerArgs::SanitizerArgs(const Driver &D, const ArgList &Args) (*I)->claim(); Kind |= Add; Kind &= ~Remove; + AllKinds |= Add; } // Only one runtime library can be used at once. @@ -1475,11 +1477,12 @@ SanitizerArgs::SanitizerArgs(const Driver &D, const ArgList &Args) << lastArgumentForKind(D, Args, NeedsMsanRt); // If -fsanitize contains extra features of ASan, it should also - // explicitly contain -fsanitize=address. - if (NeedsAsan && ((Kind & Address) == 0)) - D.Diag(diag::err_drv_argument_only_allowed_with) - << lastArgumentForKind(D, Args, NeedsAsanRt) - << "-fsanitize=address"; + // explicitly contain -fsanitize=address (probably, turned off later in the + // command line). + if ((Kind & AddressFull) != 0 && (AllKinds & Address) == 0) + D.Diag(diag::warn_drv_unused_sanitizer) + << lastArgumentForKind(D, Args, AddressFull) + << "-fsanitize=address"; // Parse -f(no-)sanitize-blacklist options. if (Arg *BLArg = Args.getLastArg(options::OPT_fsanitize_blacklist, |