summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-04-13 15:49:12 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-04-18 09:29:43 (GMT)
commit38332fc4facce48d6eaefdf55886a3e1eb85e659 (patch)
tree0f53db8e52d346805c44b0b073d3314f1b9f5de2 /Source
parent40d17356811dcf9e525e6adf7bd723ee8c678ebe (diff)
downloadCMake-38332fc4facce48d6eaefdf55886a3e1eb85e659.zip
CMake-38332fc4facce48d6eaefdf55886a3e1eb85e659.tar.gz
CMake-38332fc4facce48d6eaefdf55886a3e1eb85e659.tar.bz2
cmGeneratorExpressionDAGChecker: introduce method Top()
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx61
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h12
2 files changed, 25 insertions, 48 deletions
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index c860c75..2cc63c1 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -48,12 +48,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
void cmGeneratorExpressionDAGChecker::Initialize()
{
- const cmGeneratorExpressionDAGChecker* top = this;
- const cmGeneratorExpressionDAGChecker* p = this->Parent;
- while (p) {
- top = p;
- p = p->Parent;
- }
+ const auto* top = this->Top();
this->CheckResult = this->CheckGraph();
#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() ||
@@ -144,60 +139,34 @@ cmGeneratorExpressionDAGChecker::CheckGraph() const
return DAG;
}
-bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly()
+bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() const
{
- const cmGeneratorExpressionDAGChecker* top = this;
- const cmGeneratorExpressionDAGChecker* parent = this->Parent;
- while (parent) {
- top = parent;
- parent = parent->Parent;
- }
-
- return top->TransitivePropertiesOnly;
+ return this->Top()->TransitivePropertiesOnly;
}
-bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression()
+bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const
{
return cmHasLiteralPrefix(this->Property, "TARGET_GENEX_EVAL:") ||
cmHasLiteralPrefix(this->Property, "GENEX_EVAL:");
}
-bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression()
+bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() const
{
- const cmGeneratorExpressionDAGChecker* top = this;
- const cmGeneratorExpressionDAGChecker* parent = this->Parent;
- while (parent) {
- top = parent;
- parent = parent->Parent;
- }
-
- return top->Property == "INTERFACE_POSITION_INDEPENDENT_CODE";
+ return this->Top()->Property == "INTERFACE_POSITION_INDEPENDENT_CODE";
}
-bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression()
+bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const
{
- const cmGeneratorExpressionDAGChecker* top = this;
- const cmGeneratorExpressionDAGChecker* parent = this->Parent;
- while (parent) {
- top = parent;
- parent = parent->Parent;
- }
-
- cm::string_view property(top->Property);
+ cm::string_view property(this->Top()->Property);
return property == "LINK_DIRECTORIES"_s || property == "LINK_OPTIONS"_s ||
property == "LINK_DEPENDS"_s;
}
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
- cmGeneratorTarget const* tgt)
+ cmGeneratorTarget const* tgt) const
{
- const cmGeneratorExpressionDAGChecker* top = this;
- const cmGeneratorExpressionDAGChecker* parent = this->Parent;
- while (parent) {
- top = parent;
- parent = parent->Parent;
- }
+ const auto* top = this->Top();
cm::string_view prop(top->Property);
@@ -212,7 +181,8 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
prop == "INTERFACE_LINK_LIBRARIES"_s;
}
-cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const
+cmGeneratorExpressionDAGChecker const* cmGeneratorExpressionDAGChecker::Top()
+ const
{
const cmGeneratorExpressionDAGChecker* top = this;
const cmGeneratorExpressionDAGChecker* parent = this->Parent;
@@ -220,7 +190,12 @@ cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const
top = parent;
parent = parent->Parent;
}
- return top->Target;
+ return top;
+}
+
+cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const
+{
+ return this->Top()->Target;
}
enum TransitiveProperty
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 2a06596..b58df03 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -66,10 +66,11 @@ struct cmGeneratorExpressionDAGChecker
void ReportError(cmGeneratorExpressionContext* context,
const std::string& expr);
- bool EvaluatingGenexExpression();
- bool EvaluatingPICExpression();
- bool EvaluatingLinkExpression();
- bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr);
+ bool EvaluatingGenexExpression() const;
+ bool EvaluatingPICExpression() const;
+ bool EvaluatingLinkExpression() const;
+
+ bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr) const;
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) bool METHOD() const;
@@ -77,9 +78,10 @@ struct cmGeneratorExpressionDAGChecker
#undef DECLARE_TRANSITIVE_PROPERTY_METHOD
- bool GetTransitivePropertiesOnly();
+ bool GetTransitivePropertiesOnly() const;
void SetTransitivePropertiesOnly() { this->TransitivePropertiesOnly = true; }
+ cmGeneratorExpressionDAGChecker const* Top() const;
cmGeneratorTarget const* TopTarget() const;
private: