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.
This commit is contained in:
parent
40bbe50e23
commit
17ce0c29ad
@ -924,12 +924,9 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
|
|||||||
cmMakefile* mf, std::string const& lang) const
|
cmMakefile* mf, std::string const& lang) const
|
||||||
{
|
{
|
||||||
std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
|
std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
|
||||||
const char* compilerId = mf->GetDefinition(compilerIdVar);
|
std::string const compilerId = mf->GetSafeDefinition(compilerIdVar);
|
||||||
if (!compilerId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(compilerId, "AppleClang") == 0) {
|
if (compilerId == "AppleClang") {
|
||||||
switch (mf->GetPolicyStatus(cmPolicies::CMP0025)) {
|
switch (mf->GetPolicyStatus(cmPolicies::CMP0025)) {
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
if (!this->CMakeInstance->GetIsInTryCompile() &&
|
if (!this->CMakeInstance->GetIsInTryCompile() &&
|
||||||
@ -959,7 +956,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(compilerId, "QCC") == 0) {
|
if (compilerId == "QCC") {
|
||||||
switch (mf->GetPolicyStatus(cmPolicies::CMP0047)) {
|
switch (mf->GetPolicyStatus(cmPolicies::CMP0047)) {
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
if (!this->CMakeInstance->GetIsInTryCompile() &&
|
if (!this->CMakeInstance->GetIsInTryCompile() &&
|
||||||
@ -995,7 +992,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(compilerId, "XLClang") == 0) {
|
if (compilerId == "XLClang") {
|
||||||
switch (mf->GetPolicyStatus(cmPolicies::CMP0089)) {
|
switch (mf->GetPolicyStatus(cmPolicies::CMP0089)) {
|
||||||
case cmPolicies::WARN:
|
case cmPolicies::WARN:
|
||||||
if (!this->CMakeInstance->GetIsInTryCompile() &&
|
if (!this->CMakeInstance->GetIsInTryCompile() &&
|
||||||
|
Loading…
Reference in New Issue
Block a user