diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2021-07-26 19:49:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-08-03 14:55:46 (GMT) |
commit | d4d44e86f6a144bc849ffd1439a51a87cbb0cc12 (patch) | |
tree | 8af73a1578bc1e8f501c890102b75bd296c58b15 /Source/cmConditionEvaluator.cxx | |
parent | cc6cdacc1860ab14a2980332626b0de826f1eb2b (diff) | |
download | CMake-d4d44e86f6a144bc849ffd1439a51a87cbb0cc12.zip CMake-d4d44e86f6a144bc849ffd1439a51a87cbb0cc12.tar.gz CMake-d4d44e86f6a144bc849ffd1439a51a87cbb0cc12.tar.bz2 |
Refactor: Reduce variables scope in `HandleLevel2`
Diffstat (limited to 'Source/cmConditionEvaluator.cxx')
-rw-r--r-- | Source/cmConditionEvaluator.cxx | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index ad2ba3f..eea7bde 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -503,10 +503,6 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, std::string& errorString, MessageType& status) { - std::string def_buf; - cmProp def; - cmProp def2; - for (auto arg = newArgs.begin(), argP1 = arg, argP2 = arg; arg != newArgs.end(); argP1 = ++arg) { @@ -515,8 +511,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, if (argP1 != newArgs.end() && argP2 != newArgs.end() && this->IsKeyword(keyMATCHES, *argP1)) { - def = this->GetDefinitionIfUnquoted(*arg); + cmProp def = this->GetDefinitionIfUnquoted(*arg); + std::string def_buf; if (!def) { def = &arg->GetValue(); } else if (cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_")) { @@ -526,8 +523,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, def = &def_buf; } - const auto& rex = argP2->GetValue(); this->Makefile.ClearMatches(); + + const auto& rex = argP2->GetValue(); cmsys::RegularExpression regEntry; if (!regEntry.compile(rex)) { std::ostringstream error; @@ -568,8 +566,8 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, this->IsKeyword(keyGREATER_EQUAL, *argP1) || this->IsKeyword(keyEQUAL, *argP1)) { - def = this->GetVariableOrString(*arg); - def2 = this->GetVariableOrString(*argP2); + cmProp def = this->GetVariableOrString(*arg); + cmProp def2 = this->GetVariableOrString(*argP2); double lhs; double rhs; @@ -597,8 +595,8 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, this->IsKeyword(keySTRGREATER_EQUAL, *argP1) || this->IsKeyword(keySTREQUAL, *argP1)) { - def = this->GetVariableOrString(*arg); - def2 = this->GetVariableOrString(*argP2); + cmProp def = this->GetVariableOrString(*arg); + cmProp def2 = this->GetVariableOrString(*argP2); const int val = (*def).compare(*def2); bool result; @@ -623,8 +621,8 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, this->IsKeyword(keyVERSION_GREATER_EQUAL, *argP1) || this->IsKeyword(keyVERSION_EQUAL, *argP1)) { - def = this->GetVariableOrString(*arg); - def2 = this->GetVariableOrString(*argP2); + cmProp def = this->GetVariableOrString(*arg); + cmProp def2 = this->GetVariableOrString(*argP2); cmSystemTools::CompareOp op; if (argP1->GetValue() == keyVERSION_LESS) { @@ -657,8 +655,8 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, if (this->Policy57Status != cmPolicies::OLD && this->Policy57Status != cmPolicies::WARN) { - def = this->GetVariableOrString(*arg); - def2 = this->Makefile.GetDefinition(argP2->GetValue()); + cmProp def = this->GetVariableOrString(*arg); + cmProp def2 = this->Makefile.GetDefinition(argP2->GetValue()); HandleBinaryOp(def2 && cm::contains(cmExpandedList(*def2, true), *def), arg, newArgs, argP1, argP2); |