<div dir="ltr">Any more comments on this?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 22, 2013 at 12:35 AM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><div class="im">On Mon, Jan 21, 2013 at 9:56 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Mon, Jan 21, 2013 at 8:28 AM, Alexey Samsonov <<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>> wrote:<br>
> Hi rsmith, kcc,<br>
><br>
> This patch changes the behavior of Clang driver for command line like<br>
> "clang++ -fsanitize=init-order a.cc": now it ignores -fsanitize=init-order argument and<br>
> warns that it's unused w/o "-fsanitize=address" (instead of reporting an error).<br>
<br>
</div>So if I understand correctly, the same warning is produced for all<br>
these variants:<br>
-fsanitize=init-order<br>
-fno-sanitize=address -fsanitize=init-order<br>
-fsanitize=address,init-order -fno-sanitize=address<br></blockquote><div><br></div></div><div>Yes. </div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Could we specifically special case for situations like the last one?<br>
(or at least the last two) & make those silent (no warning) while<br>
possibly still producing an error for the first? Maybe that's<br>
difficult with our options parsing & not worth the hassle but I<br>
figured I'd check/ask.<br></blockquote><div><br></div></div><div>Hm, interesting. We can somehow hack sanitizer option parsing to</div><div>deal with this and clearly distinguish the first and the last case, but</div>
<div>we deviation from current behavior ("-fsanitize" enables some set of sanitizers,</div><div>"-fno-sanitize'" disables some set) may make things less clear.</div><div>E.g. if "-fsanitize=address,init-order -fno-sanitize=address" is "no sanitizing",</div>
<div>then what should "-fsanitize=address,init-order -fno-sanitize=address -fsanitize=address"</div><div>expand into?</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><br>
> As a rationale, consider the case when one wants to optionally build a large project<br>
> with ASan, but disable instrumentation for specific files. Previously, adding<br>
> "-fno-sanitize=address" to a file-specific compile options would produce<br>
> an error when building the whole project with "-fsanitize=address,init-order",<br>
> so we'd have to go and fix all "-fno-sanitize=..." occurences to contain<br>
> all possible features of ASan.<br>
><br>
> <a href="http://llvm-reviews.chandlerc.com/D315" target="_blank">http://llvm-reviews.chandlerc.com/D315</a><br>
><br>
> Files:<br>
> lib/Driver/Tools.cpp<br>
> lib/Driver/SanitizerArgs.h<br>
> test/Driver/fsanitize.c<br>
> include/clang/Basic/DiagnosticGroups.td<br>
> include/clang/Basic/DiagnosticDriverKinds.td<br>
><br>
> Index: lib/Driver/Tools.cpp<br>
> ===================================================================<br>
> --- lib/Driver/Tools.cpp<br>
> +++ lib/Driver/Tools.cpp<br>
> @@ -1475,10 +1475,10 @@<br>
><br>
> // If -fsanitize contains extra features of ASan, it should also<br>
> // explicitly contain -fsanitize=address.<br>
> - if (NeedsAsan && ((Kind & Address) == 0))<br>
> - D.Diag(diag::err_drv_argument_only_allowed_with)<br>
> - << lastArgumentForKind(D, Args, NeedsAsanRt)<br>
> - << "-fsanitize=address";<br>
> + if (((Kind & Address) == 0) && ((Kind & AddressFull) != 0))<br>
> + D.Diag(diag::warn_drv_unused_sanitizer)<br>
> + << lastArgumentForKind(D, Args, AddressFull)<br>
> + << "-fsanitize=address";<br>
><br>
> // Parse -f(no-)sanitize-blacklist options.<br>
> if (Arg *BLArg = Args.getLastArg(options::OPT_fsanitize_blacklist,<br>
> Index: lib/Driver/SanitizerArgs.h<br>
> ===================================================================<br>
> --- lib/Driver/SanitizerArgs.h<br>
> +++ lib/Driver/SanitizerArgs.h<br>
> @@ -33,7 +33,7 @@<br>
> #define SANITIZER(NAME, ID) ID = 1 << SO_##ID,<br>
> #define SANITIZER_GROUP(NAME, ID, ALIAS) ID = ALIAS,<br>
> #include "clang/Basic/Sanitizers.def"<br>
> - NeedsAsanRt = AddressFull,<br>
> + NeedsAsanRt = Address,<br>
> NeedsTsanRt = Thread,<br>
> NeedsMsanRt = Memory,<br>
> NeedsUbsanRt = (Undefined & ~Bounds) | Integer<br>
> Index: test/Driver/fsanitize.c<br>
> ===================================================================<br>
> --- test/Driver/fsanitize.c<br>
> +++ test/Driver/fsanitize.c<br>
> @@ -31,7 +31,10 @@<br>
> // CHECK-ASAN-TSAN: '-faddress-sanitizer' not allowed with '-fthread-sanitizer'<br>
><br>
> // RUN: %clang -target x86_64-linux-gnu -fsanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-EXTRA-ASAN<br>
> -// CHECK-ONLY-EXTRA-ASAN: argument '-fsanitize=init-order' only allowed with '-fsanitize=address'<br>
> +// CHECK-ONLY-EXTRA-ASAN: '-fsanitize=init-order' is ignored in absence of '-fsanitize=address'<br>
> +<br>
> +// RUN: %clang -target x86_64-linux-gnu -Wno-unused-sanitize-argument -fsanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-WNO-UNUSED-SANITIZE-ARGUMENT<br>
> +// CHECK-WNO-UNUSED-SANITIZE-ARGUMENT-NOT: '-fsanitize=init-order' is ignored in absence of '-fsanitize=address'<br>
><br>
> // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS<br>
> // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'<br>
> Index: include/clang/Basic/DiagnosticGroups.td<br>
> ===================================================================<br>
> --- include/clang/Basic/DiagnosticGroups.td<br>
> +++ include/clang/Basic/DiagnosticGroups.td<br>
> @@ -270,7 +270,9 @@<br>
> def UnnamedTypeTemplateArgs : DiagGroup<"unnamed-type-template-args",<br>
> [CXX98CompatUnnamedTypeTemplateArgs]>;<br>
> def UnusedArgument : DiagGroup<"unused-argument">;<br>
> -def UnusedCommandLineArgument : DiagGroup<"unused-command-line-argument">;<br>
> +def UnusedSanitizeArgument : DiagGroup<"unused-sanitize-argument">;<br>
> +def UnusedCommandLineArgument : DiagGroup<"unused-command-line-argument",<br>
> + [UnusedSanitizeArgument]>;<br>
> def UnusedComparison : DiagGroup<"unused-comparison">;<br>
> def UnusedExceptionParameter : DiagGroup<"unused-exception-parameter">;<br>
> def UnneededInternalDecl : DiagGroup<"unneeded-internal-declaration">;<br>
> Index: include/clang/Basic/DiagnosticDriverKinds.td<br>
> ===================================================================<br>
> --- include/clang/Basic/DiagnosticDriverKinds.td<br>
> +++ include/clang/Basic/DiagnosticDriverKinds.td<br>
> @@ -123,6 +123,8 @@<br>
> def warn_drv_empty_joined_argument : Warning<<br>
> "joined argument expects additional value: '%0'">,<br>
> InGroup<UnusedCommandLineArgument>;<br>
> +def warn_drv_unused_sanitizer : Warning<"'%0' is ignored in absence of '%1'">,<br>
> + InGroup<UnusedSanitizeArgument>;<br>
> def warn_drv_clang_unsupported : Warning<<br>
> "the clang compiler does not support '%0'">;<br>
> def warn_drv_deprecated_arg : Warning<<br>
><br>
</div></div>> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div>