浏览代码

cmGeneratorExpression: Consolidate recognition of transitive properties

Brad King 1 年之前
父节点
当前提交
895efd4e7a

+ 16 - 8
Source/cmGeneratorExpressionDAGChecker.cxx

@@ -37,16 +37,19 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
   , Content(content)
   , Content(content)
   , Backtrace(std::move(backtrace))
   , Backtrace(std::move(backtrace))
 {
 {
-  const auto* top = this->Top;
-  this->CheckResult = this->CheckGraph();
+  if (parent) {
+    this->TopIsTransitiveProperty = parent->TopIsTransitiveProperty;
+  } else {
+#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) this->METHOD() ||
+    this->TopIsTransitiveProperty = (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
+      TEST_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(*)
+#undef TEST_TRANSITIVE_PROPERTY_METHOD
+  }
 
 
-#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() ||
+  this->CheckResult = this->CheckGraph();
 
 
-  if (this->CheckResult == DAG &&
-      (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
-        TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(*)
-#undef TEST_TRANSITIVE_PROPERTY_METHOD
-  {
+  if (this->CheckResult == DAG && this->EvaluatingTransitiveProperty()) {
+    const auto* top = this->Top;
     auto it = top->Seen.find(this->Target);
     auto it = top->Seen.find(this->Target);
     if (it != top->Seen.end()) {
     if (it != top->Seen.end()) {
       const std::set<std::string>& propSet = it->second;
       const std::set<std::string>& propSet = it->second;
@@ -139,6 +142,11 @@ bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnlyCMP0131()
   return this->Top->CMP0131;
   return this->Top->CMP0131;
 }
 }
 
 
+bool cmGeneratorExpressionDAGChecker::EvaluatingTransitiveProperty() const
+{
+  return this->TopIsTransitiveProperty;
+}
+
 bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const
 bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const
 {
 {
   // Corresponds to GenexEvaluator::EvaluateExpression.
   // Corresponds to GenexEvaluator::EvaluateExpression.

+ 2 - 0
Source/cmGeneratorExpressionDAGChecker.h

@@ -66,6 +66,7 @@ struct cmGeneratorExpressionDAGChecker
   void ReportError(cmGeneratorExpressionContext* context,
   void ReportError(cmGeneratorExpressionContext* context,
                    const std::string& expr);
                    const std::string& expr);
 
 
+  bool EvaluatingTransitiveProperty() const;
   bool EvaluatingGenexExpression() const;
   bool EvaluatingGenexExpression() const;
   bool EvaluatingPICExpression() const;
   bool EvaluatingPICExpression() const;
   bool EvaluatingCompileExpression() const;
   bool EvaluatingCompileExpression() const;
@@ -109,4 +110,5 @@ private:
   Result CheckResult;
   Result CheckResult;
   bool TransitivePropertiesOnly = false;
   bool TransitivePropertiesOnly = false;
   bool CMP0131 = false;
   bool CMP0131 = false;
+  bool TopIsTransitiveProperty = false;
 };
 };

+ 2 - 4
Source/cmGeneratorExpressionNode.cxx

@@ -2916,10 +2916,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
           return std::string();
           return std::string();
         }
         }
       } else {
       } else {
-#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() ||
-        assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
-          ASSERT_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(clang-tidy)
-#undef ASSERT_TRANSITIVE_PROPERTY_METHOD
+        assert(dagCheckerParent
+                 ->EvaluatingTransitiveProperty()); // NOLINT(clang-tidy)
       }
       }
     }
     }