summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanaa Elghobashi <hanaae@microsoft.com>2022-01-20 12:33:46 (GMT)
committerBrad King <brad.king@kitware.com>2022-01-20 16:46:46 (GMT)
commitd13c8d25e6b27f0f676d39f1ff6c9197a1f7aeb7 (patch)
treeb76c23f9f552e4d55da1a376ab48355897d111e1
parent410dd6cf611f31ebca74e1db4dc439e6fcaf34b4 (diff)
downloadCMake-d13c8d25e6b27f0f676d39f1ff6c9197a1f7aeb7.zip
CMake-d13c8d25e6b27f0f676d39f1ff6c9197a1f7aeb7.tar.gz
CMake-d13c8d25e6b27f0f676d39f1ff6c9197a1f7aeb7.tar.bz2
VS: Add support for ASAN -fsanitize=address flag
Fixes: #21081
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx9
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 685d34d..96dcf0b 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1468,6 +1468,10 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
if (this->IPOEnabledConfigurations.count(config) > 0) {
e1.Element("WholeProgramOptimization", "true");
}
+ if (this->ASanEnabledConfigurations.find(config) !=
+ this->ASanEnabledConfigurations.end()) {
+ e1.Element("EnableAsan", "true");
+ }
{
auto s = this->SpectreMitigation.find(config);
if (s != this->SpectreMitigation.end()) {
@@ -3075,6 +3079,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->IPOEnabledConfigurations.insert(configName);
}
+ // Check if ASan is enabled.
+ if (flags.find("/fsanitize=address") != std::string::npos) {
+ this->ASanEnabledConfigurations.insert(configName);
+ }
+
// Precompile Headers
std::string pchHeader =
this->GeneratorTarget->GetPchHeader(configName, linkLanguage);
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 8d2b77d..79aa5e8 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -229,6 +229,7 @@ private:
unsigned int NsightTegraVersion[4];
bool TargetCompileAsWinRT;
std::set<std::string> IPOEnabledConfigurations;
+ std::set<std::string> ASanEnabledConfigurations;
std::map<std::string, std::string> SpectreMitigation;
cmGlobalVisualStudio10Generator* const GlobalGenerator;
cmLocalVisualStudio10Generator* const LocalGenerator;