Fix sanitizer coverage support in the win32 driver.
--dependent-lib arguments for the sanitizer libraries must be emitted when
coverage is enabled w/o any sanitizers.
llvm-svn: 272735
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 4d30a1b..8720322e 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -622,6 +622,28 @@
CmdArgs.push_back(Args.MakeArgString(F.second));
}
+ if (TC.getTriple().isOSWindows() && needsUbsanRt()) {
+ // Instruct the code generator to embed linker directives in the object file
+ // that cause the required runtime libraries to be linked.
+ CmdArgs.push_back(Args.MakeArgString(
+ "--dependent-lib=" + TC.getCompilerRT(Args, "ubsan_standalone")));
+ if (types::isCXX(InputType))
+ CmdArgs.push_back(Args.MakeArgString(
+ "--dependent-lib=" + TC.getCompilerRT(Args, "ubsan_standalone_cxx")));
+ }
+ if (TC.getTriple().isOSWindows() && needsStatsRt()) {
+ CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
+ TC.getCompilerRT(Args, "stats_client")));
+
+ // The main executable must export the stats runtime.
+ // FIXME: Only exporting from the main executable (e.g. based on whether the
+ // translation unit defines main()) would save a little space, but having
+ // multiple copies of the runtime shouldn't hurt.
+ CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
+ TC.getCompilerRT(Args, "stats")));
+ addIncludeLinkerOption(TC, Args, CmdArgs, "__sanitizer_stats_register");
+ }
+
if (Sanitizers.empty())
return;
CmdArgs.push_back(Args.MakeArgString("-fsanitize=" + toString(Sanitizers)));
@@ -673,28 +695,6 @@
if (Sanitizers.has(Memory) || Sanitizers.has(Address))
CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
- if (TC.getTriple().isOSWindows() && needsUbsanRt()) {
- // Instruct the code generator to embed linker directives in the object file
- // that cause the required runtime libraries to be linked.
- CmdArgs.push_back(Args.MakeArgString(
- "--dependent-lib=" + TC.getCompilerRT(Args, "ubsan_standalone")));
- if (types::isCXX(InputType))
- CmdArgs.push_back(Args.MakeArgString(
- "--dependent-lib=" + TC.getCompilerRT(Args, "ubsan_standalone_cxx")));
- }
- if (TC.getTriple().isOSWindows() && needsStatsRt()) {
- CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
- TC.getCompilerRT(Args, "stats_client")));
-
- // The main executable must export the stats runtime.
- // FIXME: Only exporting from the main executable (e.g. based on whether the
- // translation unit defines main()) would save a little space, but having
- // multiple copies of the runtime shouldn't hurt.
- CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
- TC.getCompilerRT(Args, "stats")));
- addIncludeLinkerOption(TC, Args, CmdArgs, "__sanitizer_stats_register");
- }
-
// Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
// enabled.
if (Sanitizers.hasOneOf(CFIClasses) && !TC.getTriple().isOSWindows() &&