summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-08-26 14:25:54 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-26 14:28:32 (GMT)
commit17ce0c29ad6f344ac0e7f628028cf66a1cf19f55 (patch)
tree40b28eca7f0a219a996a27fba866015afcd439d7 /Source/cmGlobalGenerator.cxx
parent40bbe50e23c06232ccf1c49589dde5dd84e1ac31 (diff)
downloadCMake-17ce0c29ad6f344ac0e7f628028cf66a1cf19f55.zip
CMake-17ce0c29ad6f344ac0e7f628028cf66a1cf19f55.tar.gz
CMake-17ce0c29ad6f344ac0e7f628028cf66a1cf19f55.tar.bz2
cmGlobalGenerator: Fix CheckCompilerIdCompatibility local var lifetime
Save the value of the compiler id variable in storage we own so that mutating it based on a policy does not invalidate the local value for later comparisons. This was identified by Clang AddressSanitizer.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx11
1 files changed, 4 insertions, 7 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 9afc15a..6b001f2 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -924,12 +924,9 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
cmMakefile* mf, std::string const& lang) const
{
std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
- const char* compilerId = mf->GetDefinition(compilerIdVar);
- if (!compilerId) {
- return;
- }
+ std::string const compilerId = mf->GetSafeDefinition(compilerIdVar);
- if (strcmp(compilerId, "AppleClang") == 0) {
+ if (compilerId == "AppleClang") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0025)) {
case cmPolicies::WARN:
if (!this->CMakeInstance->GetIsInTryCompile() &&
@@ -959,7 +956,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
}
}
- if (strcmp(compilerId, "QCC") == 0) {
+ if (compilerId == "QCC") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0047)) {
case cmPolicies::WARN:
if (!this->CMakeInstance->GetIsInTryCompile() &&
@@ -995,7 +992,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
}
}
- if (strcmp(compilerId, "XLClang") == 0) {
+ if (compilerId == "XLClang") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0089)) {
case cmPolicies::WARN:
if (!this->CMakeInstance->GetIsInTryCompile() &&