[Cmake-commits] CMake branch, next, updated. v3.3.0-1657-g1aa0000

Stephen Kelly steveire at gmail.com
Sat Aug 1 01:54:17 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  1aa00000ee9cc3514467d66832d127aa955a99fb (commit)
       via  adce5f39a42fa780c07e23c2a89d6ec47f66331c (commit)
       via  8572cce92cb678eba225161478fbb8dff3bc15ee (commit)
       via  f95a1e6ebae47a3d2897d82f4485d1faf94bcb09 (commit)
       via  5fb814d7f968e10a6a02e2a78b7dccb7c34b026b (commit)
       via  af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9 (commit)
       via  6ae8b30bf4127011284a66541ed2116fcb45f007 (commit)
       via  a5fc17b5098ee27fd7ae457ca6c5743bacc384a7 (commit)
       via  0a01e6c6e7bd428ca0ec99a00924b5b498c6e637 (commit)
       via  f0005bb484bc2b85a169ef7816e33d8e2f16e109 (commit)
      from  383ae666d2bfad26165c87c9edfebea52c82119e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1aa00000ee9cc3514467d66832d127aa955a99fb
commit 1aa00000ee9cc3514467d66832d127aa955a99fb
Merge: 383ae66 adce5f3
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Aug 1 01:54:15 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Aug 1 01:54:15 2015 -0400

    Merge topic 'cmState-policies' into next
    
    adce5f39 cmState: Move PolicyState from cmMakefile.
    8572cce9 cmState: Record the end position of each directory.
    f95a1e6e cmLinkedTree: Add Clear API.
    5fb814d7 cmState: Add Type for policy scope.
    af0de01c cmState: Remove call stack parent tracking.
    6ae8b30b cmMakefile: Move policy barriers inside cmState scopes.
    a5fc17b5 cmMakefile: Re-order policy entries and barriers.
    0a01e6c6 cmState: Add Snapshot Type accessor.
    f0005bb4 Tests: Verify generate-time policy scope behavior.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=adce5f39a42fa780c07e23c2a89d6ec47f66331c
commit adce5f39a42fa780c07e23c2a89d6ec47f66331c
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jul 26 13:04:09 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:53:35 2015 +0200

    cmState: Move PolicyState from cmMakefile.
    
    Implement lexical scope checking in terms of the state stack instead
    of barriers.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9fb3d06..a0a36ec 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -192,9 +192,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
   this->StateSnapshot = this->StateSnapshot.GetState()
       ->CreatePolicyScopeSnapshot(this->StateSnapshot);
 
-  // Protect the directory-level policies.
-  this->PushPolicyBarrier();
-
   // Enter a policy level for this directory.
   this->PushPolicy();
 
@@ -239,11 +236,6 @@ cmMakefile::~cmMakefile()
   cmDeleteAll(this->FinalPassCommands);
   cmDeleteAll(this->FunctionBlockers);
   this->FunctionBlockers.clear();
-  if (this->PolicyStack.size() != 1)
-  {
-    cmSystemTools::Error("Internal CMake Error, Policy Stack has not been"
-      " popped properly");
-  }
 }
 
 //----------------------------------------------------------------------------
@@ -479,7 +471,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
         this->Makefile->ContextStack.back()->Name,
         this->Makefile->ContextStack.back()->Line,
         filenametoread);
-  this->Makefile->PushPolicyBarrier();
   if(!this->NoPolicyScope)
     {
     // Check CMP0011 to determine the policy scope type.
@@ -519,7 +510,8 @@ cmMakefile::IncludeScope::~IncludeScope()
     // one we pushed above.  If the entry is empty, then the included
     // script did not set any policies that might affect the includer so
     // we do not need to enforce the policy.
-    if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty())
+    if(this->CheckCMP0011
+       && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011())
       {
       this->CheckCMP0011 = false;
       }
@@ -535,9 +527,6 @@ cmMakefile::IncludeScope::~IncludeScope()
       }
     }
   this->Makefile->PopPolicyBarrier(this->ReportError);
-  this->Makefile->StateSnapshot =
-      this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot);
-  assert(this->Makefile->StateSnapshot.IsValid());
 
   this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
 }
@@ -646,19 +635,12 @@ public:
           this->Makefile->StateSnapshot, name, line, filenametoread);
     assert(this->Makefile->StateSnapshot.IsValid());
 
-    this->Makefile->PushPolicyBarrier();
-
     this->Makefile->PushFunctionBlockerBarrier();
   }
 
   ~ListFileScope()
   {
     this->Makefile->PopPolicyBarrier(this->ReportError);
-
-    this->Makefile->StateSnapshot =
-        this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot);
-    assert(this->Makefile->StateSnapshot.IsValid());
-
     this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
   }
 
@@ -1630,7 +1612,6 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
         this->ContextStack.back()->Name, this->ContextStack.back()->Line,
         fileName);
   assert(this->StateSnapshot.IsValid());
-  this->PushPolicyBarrier();
 
   this->Internal->PushDefinitions();
 
@@ -1650,8 +1631,6 @@ void cmMakefile::PopFunctionScope(bool reportError)
   this->PopPolicy();
 
   this->PopPolicyBarrier(reportError);
-  this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
-  assert(this->StateSnapshot.IsValid());
 
   this->PopFunctionBlockerBarrier(reportError);
 
@@ -1675,7 +1654,6 @@ void cmMakefile::PushMacroScope(std::string const& fileName,
         this->ContextStack.back()->Name, this->ContextStack.back()->Line,
         fileName);
   assert(this->StateSnapshot.IsValid());
-  this->PushPolicyBarrier();
 
   this->PushFunctionBlockerBarrier();
 
@@ -1687,9 +1665,6 @@ void cmMakefile::PopMacroScope(bool reportError)
   this->PopPolicy();
   this->PopPolicyBarrier(reportError);
 
-  this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
-  assert(this->StateSnapshot.IsValid());
-
   this->PopFunctionBlockerBarrier(reportError);
 }
 
@@ -1710,7 +1685,6 @@ public:
     this->Makefile->StateSnapshot.SetListFile(currentStart);
     this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
         ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
-    this->Makefile->PushPolicyBarrier();
     this->Makefile->PushFunctionBlockerBarrier();
 
     this->GG = mf->GetGlobalGenerator();
@@ -1727,8 +1701,6 @@ public:
   {
     this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
     this->Makefile->PopPolicyBarrier(this->ReportError);
-    this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
-        ->Pop(this->Makefile->StateSnapshot);
 #if defined(CMAKE_BUILD_WITH_CMAKE)
     this->GG->GetFileLockPool().PopFileScope();
 #endif
@@ -4759,30 +4731,7 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const
 cmPolicies::PolicyStatus
 cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
 {
-  cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
-
-  if(status == cmPolicies::REQUIRED_ALWAYS ||
-     status == cmPolicies::REQUIRED_IF_USED)
-    {
-    return status;
-    }
-
-  cmLocalGenerator* lg = this->LocalGenerator;
-  while(lg)
-    {
-    cmMakefile const* mf = lg->GetMakefile();
-    for(PolicyStackType::const_reverse_iterator psi =
-        mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi)
-      {
-      if(psi->IsDefined(id))
-        {
-        status = psi->Get(id);
-        return status;
-        }
-      }
-    lg = lg->GetParent();
-    }
-  return status;
+  return this->StateSnapshot.GetPolicy(id);
 }
 
 //----------------------------------------------------------------------------
@@ -4831,15 +4780,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
     return false;
     }
 
-  // Update the policy stack from the top to the top-most strong entry.
-  bool previous_was_weak = true;
-  for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin();
-      previous_was_weak && psi != this->PolicyStack.rend(); ++psi)
-    {
-    psi->Set(id, status);
-    previous_was_weak = psi->Weak;
-    }
-
+  this->StateSnapshot.SetPolicy(id, status);
   return true;
 }
 
@@ -4850,7 +4791,6 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak,
 {
   this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
       ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
-  this->Makefile->PushPolicyBarrier();
   this->Makefile->PushPolicy(weak, pm);
 }
 
@@ -4859,25 +4799,18 @@ cmMakefile::PolicyPushPop::~PolicyPushPop()
 {
   this->Makefile->PopPolicy();
   this->Makefile->PopPolicyBarrier(this->ReportError);
-  this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
-      ->Pop(this->Makefile->StateSnapshot);
 }
 
 //----------------------------------------------------------------------------
 void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm)
 {
-  // Allocate a new stack entry.
-  this->PolicyStack.push_back(PolicyStackEntry(pm, weak));
+  this->StateSnapshot.PushPolicy(pm, weak);
 }
 
 //----------------------------------------------------------------------------
 void cmMakefile::PopPolicy()
 {
-  if(this->PolicyStack.size() > this->PolicyBarriers.back())
-    {
-    this->PolicyStack.pop_back();
-    }
-  else
+  if (!this->StateSnapshot.PopPolicy())
     {
     this->IssueMessage(cmake::FATAL_ERROR,
                        "cmake_policy POP without matching PUSH");
@@ -4885,17 +4818,9 @@ void cmMakefile::PopPolicy()
 }
 
 //----------------------------------------------------------------------------
-void cmMakefile::PushPolicyBarrier()
-{
-  this->PolicyBarriers.push_back(this->PolicyStack.size());
-}
-
-//----------------------------------------------------------------------------
 void cmMakefile::PopPolicyBarrier(bool reportError)
 {
-  // Remove any extra entries pushed on the barrier.
-  PolicyStackType::size_type barrier = this->PolicyBarriers.back();
-  while(this->PolicyStack.size() > barrier)
+  while (!this->StateSnapshot.CanPopPolicyScope())
     {
     if(reportError)
       {
@@ -4906,8 +4831,8 @@ void cmMakefile::PopPolicyBarrier(bool reportError)
     this->PopPolicy();
     }
 
-  // Remove the barrier.
-  this->PolicyBarriers.pop_back();
+  this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
+  assert(this->StateSnapshot.IsValid());
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 1e5c301..173914e 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -909,7 +909,6 @@ private:
   void PushPolicy(bool weak = false,
                   cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
   void PopPolicy();
-  void PushPolicyBarrier();
   void PopPolicyBarrier(bool reportError = true);
   friend class cmCMakePolicyCommand;
   class IncludeScope;
@@ -919,18 +918,6 @@ private:
   class BuildsystemFileScope;
   friend class BuildsystemFileScope;
 
-  // stack of policy settings
-  struct PolicyStackEntry: public cmPolicies::PolicyMap
-  {
-    typedef cmPolicies::PolicyMap derived;
-    PolicyStackEntry(bool w = false): derived(), Weak(w) {}
-    PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {}
-    PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
-    bool Weak;
-  };
-  typedef std::vector<PolicyStackEntry> PolicyStackType;
-  PolicyStackType PolicyStack;
-  std::vector<PolicyStackType::size_type> PolicyBarriers;
 
   // CMP0053 == old
   cmake::MessageType ExpandVariablesInStringOld(
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index ea8d147..492a4d0 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -21,6 +21,9 @@
 struct cmState::SnapshotDataType
 {
   cmState::PositionType DirectoryParent;
+  cmLinkedTree<cmState::PolicyStackEntry>::iterator Policies;
+  cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyRoot;
+  cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyScope;
   cmState::SnapshotType SnapshotType;
   cmLinkedTree<std::string>::iterator ExecutionListFile;
   cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator
@@ -32,6 +35,15 @@ struct cmState::SnapshotDataType
   std::vector<std::string>::size_type CompileOptionsPosition;
 };
 
+struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap
+{
+  typedef cmPolicies::PolicyMap derived;
+  PolicyStackEntry(bool w = false): derived(), Weak(w) {}
+  PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {}
+  PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
+  bool Weak;
+};
+
 struct cmState::BuildsystemDirectoryStateType
 {
   cmState::PositionType DirectoryEnd;
@@ -256,6 +268,13 @@ cmState::Snapshot cmState::Reset()
   it->DirectoryEnd = pos;
   }
 
+  this->PolicyStack.Clear();
+  pos->Policies = this->PolicyStack.Root();
+  pos->PolicyRoot = this->PolicyStack.Root();
+  pos->PolicyScope = this->PolicyStack.Root();
+  assert(pos->Policies.IsValid());
+  assert(pos->PolicyRoot.IsValid());
+
   this->DefineProperty
     ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
      "", "", true);
@@ -726,6 +745,11 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
   pos->CompileDefinitionsPosition = 0;
   pos->CompileOptionsPosition = 0;
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->Policies = this->PolicyStack.Root();
+  pos->PolicyRoot = this->PolicyStack.Root();
+  pos->PolicyScope = this->PolicyStack.Root();
+  assert(pos->Policies.IsValid());
+  assert(pos->PolicyRoot.IsValid());
   return cmState::Snapshot(this, pos);
 }
 
@@ -747,6 +771,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
       this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->Policies = originSnapshot.Position->Policies;
+  pos->PolicyRoot = originSnapshot.Position->Policies;
+  pos->PolicyScope = originSnapshot.Position->Policies;
+  assert(pos->Policies.IsValid());
+  assert(pos->PolicyRoot.IsValid());
   return cmState::Snapshot(this, pos);
 }
 
@@ -764,6 +793,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
@@ -782,6 +812,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
@@ -799,6 +830,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
@@ -816,15 +848,18 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
-cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot)
+cmState::Snapshot
+cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot)
 {
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
                                                *originSnapshot.Position);
   pos->SnapshotType = PolicyScopeType;
   pos->BuildSystemDirectory->DirectoryEnd = pos;
+  pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
@@ -1004,6 +1039,90 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
   return snapshot;
 }
 
+void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak)
+{
+  PositionType pos = this->Position;
+  pos->Policies =
+      this->State->PolicyStack.Extend(pos->Policies,
+                                      PolicyStackEntry(entry, weak));
+}
+
+bool cmState::Snapshot::PopPolicy()
+{
+  PositionType pos = this->Position;
+  if (pos->Policies == pos->PolicyScope)
+    {
+    return false;
+    }
+  ++pos->Policies;
+  return true;
+}
+
+bool cmState::Snapshot::CanPopPolicyScope()
+{
+  PositionType pos = this->Position;
+  bool ok = (pos->Policies == pos->PolicyScope);
+  return ok;
+}
+
+void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id,
+                                  cmPolicies::PolicyStatus status)
+{
+  // Update the policy stack from the top to the top-most strong entry.
+  bool previous_was_weak = true;
+  for(cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies;
+      previous_was_weak && psi != this->Position->PolicyRoot; ++psi)
+    {
+    psi->Set(id, status);
+    previous_was_weak = psi->Weak;
+    }
+}
+
+cmPolicies::PolicyStatus
+cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const
+{
+  cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
+
+  if(status == cmPolicies::REQUIRED_ALWAYS ||
+     status == cmPolicies::REQUIRED_IF_USED)
+    {
+    return status;
+    }
+
+  cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir =
+      this->Position->BuildSystemDirectory;
+
+  while (true)
+    {
+    assert(dir.IsValid());
+    cmLinkedTree<PolicyStackEntry>::iterator leaf =
+        dir->DirectoryEnd->Policies;
+    cmLinkedTree<PolicyStackEntry>::iterator root =
+        dir->DirectoryEnd->PolicyRoot;
+    for( ; leaf != root; ++leaf)
+      {
+      if(leaf->IsDefined(id))
+        {
+        status = leaf->Get(id);
+        return status;
+        }
+      }
+    cmState::PositionType e = dir->DirectoryEnd;
+    cmState::PositionType p = e->DirectoryParent;
+    if (p == this->State->SnapshotData.Root())
+      {
+      break;
+      }
+    dir = p->BuildSystemDirectory;
+    }
+  return status;
+}
+
+bool cmState::Snapshot::HasDefinedPolicyCMP0011()
+{
+  return !this->Position->Policies->IsEmpty();
+}
+
 static const std::string cmPropertySentinal = std::string();
 
 template<typename T, typename U, typename V>
diff --git a/Source/cmState.h b/Source/cmState.h
index 63b60ef..07aa2a5 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -17,6 +17,7 @@
 #include "cmPropertyMap.h"
 #include "cmLinkedTree.h"
 #include "cmAlgorithms.h"
+#include "cmPolicies.h"
 
 class cmake;
 class cmCommand;
@@ -24,6 +25,7 @@ class cmCommand;
 class cmState
 {
   struct SnapshotDataType;
+  struct PolicyStackEntry;
   struct BuildsystemDirectoryStateType;
   typedef cmLinkedTree<SnapshotDataType>::iterator PositionType;
   friend class Snapshot;
@@ -61,6 +63,13 @@ public:
 
     void InitializeFromParent();
 
+    void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
+    cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const;
+    bool HasDefinedPolicyCMP0011();
+    void PushPolicy(cmPolicies::PolicyMap entry, bool weak);
+    bool PopPolicy();
+    bool CanPopPolicyScope();
+
     cmState* GetState() const;
 
     Directory GetDirectory() const;
@@ -257,6 +266,7 @@ private:
 
   cmLinkedTree<std::string> ExecutionListFiles;
 
+  cmLinkedTree<PolicyStackEntry> PolicyStack;
   cmLinkedTree<SnapshotDataType> SnapshotData;
 
   std::vector<std::string> SourceDirectoryComponents;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8572cce92cb678eba225161478fbb8dff3bc15ee
commit 8572cce92cb678eba225161478fbb8dff3bc15ee
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Aug 1 07:20:26 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:39:56 2015 +0200

    cmState: Record the end position of each directory.
    
    At generate time, variables and policies are determined from the end
    state of the cmMakefile.

diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 68f5c18..ea8d147 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -34,6 +34,8 @@ struct cmState::SnapshotDataType
 
 struct cmState::BuildsystemDirectoryStateType
 {
+  cmState::PositionType DirectoryEnd;
+
   std::string Location;
   std::string OutputLocation;
 
@@ -239,6 +241,9 @@ cmState::Snapshot cmState::Reset()
   this->GlobalProperties.clear();
   this->PropertyDefinitions.clear();
 
+  PositionType pos = this->SnapshotData.Truncate();
+  this->ExecutionListFiles.Truncate();
+
   {
   cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
       this->BuildsystemDirectory.Truncate();
@@ -248,9 +253,8 @@ cmState::Snapshot cmState::Reset()
   it->CompileDefinitionsBacktraces.clear();
   it->CompileOptions.clear();
   it->CompileOptionsBacktraces.clear();
+  it->DirectoryEnd = pos;
   }
-  PositionType pos = this->SnapshotData.Truncate();
-  this->ExecutionListFiles.Truncate();
 
   this->DefineProperty
     ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
@@ -721,6 +725,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
   pos->IncludeDirectoryPosition = 0;
   pos->CompileDefinitionsPosition = 0;
   pos->CompileOptionsPosition = 0;
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -741,6 +746,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
   pos->ExecutionListFile =
       this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile);
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -757,6 +763,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
   pos->SnapshotType = FunctionCallType;
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -774,6 +781,7 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
   pos->SnapshotType = MacroCallType;
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -790,6 +798,7 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
   pos->SnapshotType = CallStackType;
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -806,6 +815,7 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
   pos->SnapshotType = InlineListFileType;
   pos->ExecutionListFile = this->ExecutionListFiles.Extend(
         originSnapshot.Position->ExecutionListFile, fileName);
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -814,6 +824,7 @@ cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSna
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
                                                *originSnapshot.Position);
   pos->SnapshotType = PolicyScopeType;
+  pos->BuildSystemDirectory->DirectoryEnd = pos;
   return cmState::Snapshot(this, pos);
 }
 
@@ -828,6 +839,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
       prevPos->BuildSystemDirectory->CompileDefinitions.size();
   prevPos->CompileOptionsPosition =
       prevPos->BuildSystemDirectory->CompileOptions.size();
+  prevPos->BuildSystemDirectory->DirectoryEnd = prevPos;
 
   return Snapshot(this, prevPos);
 }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f95a1e6ebae47a3d2897d82f4485d1faf94bcb09
commit f95a1e6ebae47a3d2897d82f4485d1faf94bcb09
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jun 14 01:38:57 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:39:56 2015 +0200

    cmLinkedTree: Add Clear API.

diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index df00b30..3bcb940 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -155,6 +155,12 @@ public:
     return iterator(this, 1);
   }
 
+  void Clear()
+  {
+    this->UpPositions.clear();
+    this->Data.clear();
+  }
+
 private:
   T& GetReference(PositionType pos)
   {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5fb814d7f968e10a6a02e2a78b7dccb7c34b026b
commit 5fb814d7f968e10a6a02e2a78b7dccb7c34b026b
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jul 26 12:56:10 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:39:56 2015 +0200

    cmState: Add Type for policy scope.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2c854dd..9fb3d06 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -189,6 +189,9 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
   this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
   this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
 
+  this->StateSnapshot = this->StateSnapshot.GetState()
+      ->CreatePolicyScopeSnapshot(this->StateSnapshot);
+
   // Protect the directory-level policies.
   this->PushPolicyBarrier();
 
@@ -1705,6 +1708,8 @@ public:
         this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
     currentStart += "/CMakeLists.txt";
     this->Makefile->StateSnapshot.SetListFile(currentStart);
+    this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
+        ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
     this->Makefile->PushPolicyBarrier();
     this->Makefile->PushFunctionBlockerBarrier();
 
@@ -1722,6 +1727,8 @@ public:
   {
     this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
     this->Makefile->PopPolicyBarrier(this->ReportError);
+    this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
+        ->Pop(this->Makefile->StateSnapshot);
 #if defined(CMAKE_BUILD_WITH_CMAKE)
     this->GG->GetFileLockPool().PopFileScope();
 #endif
@@ -4841,6 +4848,8 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak,
                                          cmPolicies::PolicyMap const& pm):
   Makefile(m), ReportError(true)
 {
+  this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
+      ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
   this->Makefile->PushPolicyBarrier();
   this->Makefile->PushPolicy(weak, pm);
 }
@@ -4850,6 +4859,8 @@ cmMakefile::PolicyPushPop::~PolicyPushPop()
 {
   this->Makefile->PopPolicy();
   this->Makefile->PopPolicyBarrier(this->ReportError);
+  this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
+      ->Pop(this->Makefile->StateSnapshot);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index a7df040..68f5c18 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -809,6 +809,14 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
   return cmState::Snapshot(this, pos);
 }
 
+cmState::Snapshot cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot)
+{
+  PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
+                                               *originSnapshot.Position);
+  pos->SnapshotType = PolicyScopeType;
+  return cmState::Snapshot(this, pos);
+}
+
 cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
 {
   PositionType pos = originSnapshot.Position;
@@ -959,13 +967,22 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
   assert(this->Position != this->State->SnapshotData.Root());
 
   Snapshot snapshot;
-  if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType)
+  PositionType parentPos = this->Position;
+  while(parentPos->SnapshotType == cmState::PolicyScopeType)
+    {
+    ++parentPos;
+    }
+  if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType)
     {
     return snapshot;
     }
 
-  PositionType parentPos = this->Position;
   ++parentPos;
+  while(parentPos->SnapshotType == cmState::PolicyScopeType)
+    {
+    ++parentPos;
+    }
+
   if (parentPos == this->State->SnapshotData.Root())
     {
     return snapshot;
diff --git a/Source/cmState.h b/Source/cmState.h
index 23fbc79..63b60ef 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -37,7 +37,8 @@ public:
     FunctionCallType,
     MacroCallType,
     CallStackType,
-    InlineListFileType
+    InlineListFileType,
+    PolicyScopeType
   };
 
   class Directory;
@@ -148,6 +149,7 @@ public:
                                         const std::string& entryPointCommand,
                                         long entryPointLine,
                                         std::string const& fileName);
+  Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot);
   Snapshot Pop(Snapshot originSnapshot);
 
   enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9
commit af0de01c6b3395fb1dba5d2ee0a94c19a9b464e9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Aug 1 07:29:36 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:31:08 2015 +0200

    cmState: Remove call stack parent tracking.
    
    This was added at a time when I thought the cmState would report errors,
    but that is not the direction it is going.  The ordering of the stack of
    scopes is canonical and clients are required to maintain it.

diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index a466471..a7df040 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -20,7 +20,6 @@
 
 struct cmState::SnapshotDataType
 {
-  cmState::PositionType CallStackParent;
   cmState::PositionType DirectoryParent;
   cmState::SnapshotType SnapshotType;
   cmLinkedTree<std::string>::iterator ExecutionListFile;
@@ -732,7 +731,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
 {
   assert(originSnapshot.IsValid());
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position);
-  pos->CallStackParent = originSnapshot.Position;
   pos->EntryPointLine = entryPointLine;
   pos->EntryPointCommand = entryPointCommand;
   pos->DirectoryParent = originSnapshot.Position;
@@ -754,7 +752,6 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
 {
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
                                                *originSnapshot.Position);
-  pos->CallStackParent = originSnapshot.Position;
   pos->EntryPointLine = entryPointLine;
   pos->EntryPointCommand = entryPointCommand;
   pos->SnapshotType = FunctionCallType;
@@ -772,7 +769,6 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
 {
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
                                                *originSnapshot.Position);
-  pos->CallStackParent = originSnapshot.Position;
   pos->EntryPointLine = entryPointLine;
   pos->EntryPointCommand = entryPointCommand;
   pos->SnapshotType = MacroCallType;
@@ -789,7 +785,6 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
 {
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
                                                *originSnapshot.Position);
-  pos->CallStackParent = originSnapshot.Position;
   pos->EntryPointLine = entryPointLine;
   pos->EntryPointCommand = entryPointCommand;
   pos->SnapshotType = CallStackType;
@@ -806,7 +801,6 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
 {
   PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
                                                *originSnapshot.Position);
-  pos->CallStackParent = originSnapshot.Position;
   pos->EntryPointLine = entryPointLine;
   pos->EntryPointCommand = entryPointCommand;
   pos->SnapshotType = InlineListFileType;
@@ -827,11 +821,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
   prevPos->CompileOptionsPosition =
       prevPos->BuildSystemDirectory->CompileOptions.size();
 
-  if (prevPos == this->SnapshotData.Root())
-    {
-    return Snapshot(this, prevPos);
-    }
-  return Snapshot(this, originSnapshot.Position->CallStackParent);
+  return Snapshot(this, prevPos);
 }
 
 cmState::Snapshot::Snapshot(cmState* state)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ae8b30bf4127011284a66541ed2116fcb45f007
commit 6ae8b30bf4127011284a66541ed2116fcb45f007
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Jul 28 08:09:49 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:18:34 2015 +0200

    cmMakefile: Move policy barriers inside cmState scopes.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 16404cd..2c854dd 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -468,6 +468,14 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
   Makefile(mf), NoPolicyScope(noPolicyScope),
   CheckCMP0011(false), ReportError(true)
 {
+  this->Makefile->PushFunctionBlockerBarrier();
+
+  this->Makefile->StateSnapshot =
+      this->Makefile->GetState()->CreateCallStackSnapshot(
+        this->Makefile->StateSnapshot,
+        this->Makefile->ContextStack.back()->Name,
+        this->Makefile->ContextStack.back()->Line,
+        filenametoread);
   this->Makefile->PushPolicyBarrier();
   if(!this->NoPolicyScope)
     {
@@ -497,27 +505,11 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
         break;
       }
     }
-
-  this->Makefile->PushFunctionBlockerBarrier();
-
-  this->Makefile->StateSnapshot =
-      this->Makefile->GetState()->CreateCallStackSnapshot(
-        this->Makefile->StateSnapshot,
-        this->Makefile->ContextStack.back()->Name,
-        this->Makefile->ContextStack.back()->Line,
-        filenametoread);
 }
 
 //----------------------------------------------------------------------------
 cmMakefile::IncludeScope::~IncludeScope()
 {
-  this->Makefile->StateSnapshot =
-      this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot);
-  assert(this->Makefile->StateSnapshot.IsValid());
-
-  this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
-  // Enforce matching policy scopes inside the included file.
-
   if(!this->NoPolicyScope)
     {
     // If we need to enforce policy CMP0011 then the top entry is the
@@ -540,6 +532,11 @@ cmMakefile::IncludeScope::~IncludeScope()
       }
     }
   this->Makefile->PopPolicyBarrier(this->ReportError);
+  this->Makefile->StateSnapshot =
+      this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot);
+  assert(this->Makefile->StateSnapshot.IsValid());
+
+  this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
 }
 
 //----------------------------------------------------------------------------
@@ -634,8 +631,6 @@ public:
   ListFileScope(cmMakefile* mf, std::string const& filenametoread)
     : Makefile(mf), ReportError(true)
   {
-    this->Makefile->PushPolicyBarrier();
-
     long line = 0;
     std::string name;
     if (!this->Makefile->ContextStack.empty())
@@ -647,17 +642,21 @@ public:
         this->Makefile->GetState()->CreateInlineListFileSnapshot(
           this->Makefile->StateSnapshot, name, line, filenametoread);
     assert(this->Makefile->StateSnapshot.IsValid());
+
+    this->Makefile->PushPolicyBarrier();
+
     this->Makefile->PushFunctionBlockerBarrier();
   }
 
   ~ListFileScope()
   {
+    this->Makefile->PopPolicyBarrier(this->ReportError);
+
     this->Makefile->StateSnapshot =
         this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot);
     assert(this->Makefile->StateSnapshot.IsValid());
 
     this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
-    this->Makefile->PopPolicyBarrier(this->ReportError);
   }
 
   void Quiet() { this->ReportError = false; }
@@ -1628,6 +1627,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
         this->ContextStack.back()->Name, this->ContextStack.back()->Line,
         fileName);
   assert(this->StateSnapshot.IsValid());
+  this->PushPolicyBarrier();
 
   this->Internal->PushDefinitions();
 
@@ -1639,15 +1639,14 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
 
   this->PushFunctionBlockerBarrier();
 
-  this->PushPolicyBarrier();
   this->PushPolicy(true, pm);
 }
 
 void cmMakefile::PopFunctionScope(bool reportError)
 {
   this->PopPolicy();
-  this->PopPolicyBarrier(reportError);
 
+  this->PopPolicyBarrier(reportError);
   this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
   assert(this->StateSnapshot.IsValid());
 
@@ -1673,10 +1672,10 @@ void cmMakefile::PushMacroScope(std::string const& fileName,
         this->ContextStack.back()->Name, this->ContextStack.back()->Line,
         fileName);
   assert(this->StateSnapshot.IsValid());
+  this->PushPolicyBarrier();
 
   this->PushFunctionBlockerBarrier();
 
-  this->PushPolicyBarrier();
   this->PushPolicy(true, pm);
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a5fc17b5098ee27fd7ae457ca6c5743bacc384a7
commit a5fc17b5098ee27fd7ae457ca6c5743bacc384a7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jul 26 16:16:43 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:18:34 2015 +0200

    cmMakefile: Re-order policy entries and barriers.
    
    Make the barriers surround the entries.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 4bdc9d5..16404cd 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -189,12 +189,12 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
   this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
   this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
 
-  // Enter a policy level for this directory.
-  this->PushPolicy();
-
   // Protect the directory-level policies.
   this->PushPolicyBarrier();
 
+  // Enter a policy level for this directory.
+  this->PushPolicy();
+
   // push empty loop block
   this->PushLoopBlockBarrier();
 
@@ -468,6 +468,7 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
   Makefile(mf), NoPolicyScope(noPolicyScope),
   CheckCMP0011(false), ReportError(true)
 {
+  this->Makefile->PushPolicyBarrier();
   if(!this->NoPolicyScope)
     {
     // Check CMP0011 to determine the policy scope type.
@@ -497,8 +498,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
       }
     }
 
-  // The included file cannot pop our policy scope.
-  this->Makefile->PushPolicyBarrier();
   this->Makefile->PushFunctionBlockerBarrier();
 
   this->Makefile->StateSnapshot =
@@ -518,7 +517,6 @@ cmMakefile::IncludeScope::~IncludeScope()
 
   this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
   // Enforce matching policy scopes inside the included file.
-  this->Makefile->PopPolicyBarrier(this->ReportError);
 
   if(!this->NoPolicyScope)
     {
@@ -541,6 +539,7 @@ cmMakefile::IncludeScope::~IncludeScope()
       this->EnforceCMP0011();
       }
     }
+  this->Makefile->PopPolicyBarrier(this->ReportError);
 }
 
 //----------------------------------------------------------------------------
@@ -1640,14 +1639,14 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
 
   this->PushFunctionBlockerBarrier();
 
-  this->PushPolicy(true, pm);
   this->PushPolicyBarrier();
+  this->PushPolicy(true, pm);
 }
 
 void cmMakefile::PopFunctionScope(bool reportError)
 {
-  this->PopPolicyBarrier(reportError);
   this->PopPolicy();
+  this->PopPolicyBarrier(reportError);
 
   this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
   assert(this->StateSnapshot.IsValid());
@@ -1677,14 +1676,14 @@ void cmMakefile::PushMacroScope(std::string const& fileName,
 
   this->PushFunctionBlockerBarrier();
 
-  this->PushPolicy(true, pm);
   this->PushPolicyBarrier();
+  this->PushPolicy(true, pm);
 }
 
 void cmMakefile::PopMacroScope(bool reportError)
 {
-  this->PopPolicyBarrier(reportError);
   this->PopPolicy();
+  this->PopPolicyBarrier(reportError);
 
   this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
   assert(this->StateSnapshot.IsValid());
@@ -4843,15 +4842,15 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak,
                                          cmPolicies::PolicyMap const& pm):
   Makefile(m), ReportError(true)
 {
-  this->Makefile->PushPolicy(weak, pm);
   this->Makefile->PushPolicyBarrier();
+  this->Makefile->PushPolicy(weak, pm);
 }
 
 //----------------------------------------------------------------------------
 cmMakefile::PolicyPushPop::~PolicyPushPop()
 {
-  this->Makefile->PopPolicyBarrier(this->ReportError);
   this->Makefile->PopPolicy();
+  this->Makefile->PopPolicyBarrier(this->ReportError);
 }
 
 //----------------------------------------------------------------------------

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0a01e6c6e7bd428ca0ec99a00924b5b498c6e637
commit 0a01e6c6e7bd428ca0ec99a00924b5b498c6e637
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Jul 26 12:54:16 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:18:34 2015 +0200

    cmState: Add Snapshot Type accessor.

diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index d8f8306..a466471 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -847,6 +847,11 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position)
 
 }
 
+cmState::SnapshotType cmState::Snapshot::GetType() const
+{
+  return this->Position->SnapshotType;
+}
+
 const char* cmState::Directory::GetCurrentSource() const
 {
   return this->DirectoryState->Location.c_str();
diff --git a/Source/cmState.h b/Source/cmState.h
index 0d5300f..23fbc79 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -56,6 +56,7 @@ public:
     bool IsValid() const;
     Snapshot GetBuildsystemDirectoryParent() const;
     Snapshot GetCallStackParent() const;
+    SnapshotType GetType() const;
 
     void InitializeFromParent();
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0005bb484bc2b85a169ef7816e33d8e2f16e109
commit f0005bb484bc2b85a169ef7816e33d8e2f16e109
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Aug 1 07:16:40 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Aug 1 07:18:21 2015 +0200

    Tests: Verify generate-time policy scope behavior.
    
    If some day there are no policies checked through the makefile at generate time,
    this can be fixed.

diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 607e799..c4579d7 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -145,6 +145,7 @@ add_RunCMake_test(TargetSources)
 add_RunCMake_test(find_dependency)
 add_RunCMake_test(CompileDefinitions)
 add_RunCMake_test(CompileFeatures)
+add_RunCMake_test(PolicyScope)
 add_RunCMake_test(WriteCompilerDetectionHeader)
 if(NOT WIN32)
   add_RunCMake_test(PositionIndependentCode)
diff --git a/Tests/RunCMake/PolicyScope/CMakeLists.txt b/Tests/RunCMake/PolicyScope/CMakeLists.txt
new file mode 100644
index 0000000..667561e
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake b/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake
new file mode 100644
index 0000000..d6c021f
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(parent-dir-generate-time)
+run_cmake(dir-in-macro-generate-time)
diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt
new file mode 100644
index 0000000..d223f42
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time-stderr.txt
@@ -0,0 +1,5 @@
+CMake Warning \(dev\) at dir1/CMakeLists.txt:5 \(target_compile_definitions\):
+  Policy CMP0044 is not set: Case sensitive <LANG>_COMPILER_ID generator
+  expressions.  Run "cmake --help-policy CMP0044" for policy details.  Use
+  the cmake_policy command to set the policy and suppress this warning.
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake
new file mode 100644
index 0000000..04a7c2c
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake
@@ -0,0 +1,2 @@
+
+include(dir-in-macro-include.cmake)
diff --git a/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake b/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake
new file mode 100644
index 0000000..fd326f1
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake
@@ -0,0 +1,6 @@
+
+enable_language(CXX)
+
+# This does not affect dir1 despite being set before the add_subdirectory.
+cmake_policy(SET CMP0044 NEW)
+add_subdirectory(dir1)
diff --git a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt
new file mode 100644
index 0000000..16bcb36
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+
+add_library(foo STATIC foo.cpp)
+string(TOLOWER ${CMAKE_CXX_COMPILER_ID} compiler_id)
+target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:${compiler_id}>)
diff --git a/Tests/RunCMake/PolicyScope/dir1/foo.cpp b/Tests/RunCMake/PolicyScope/dir1/foo.cpp
new file mode 100644
index 0000000..766b775
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/dir1/foo.cpp
@@ -0,0 +1,5 @@
+
+int main()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt b/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/parent-dir-generate-time-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake b/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake
new file mode 100644
index 0000000..a0842f7
--- /dev/null
+++ b/Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake
@@ -0,0 +1,7 @@
+
+enable_language(CXX)
+
+add_subdirectory(dir1)
+
+# This affects dir1 despite being set after the add_subdirectory.
+cmake_policy(SET CMP0044 NEW)

-----------------------------------------------------------------------

Summary of changes:
 Source/cmLinkedTree.h                              |    6 +
 Source/cmMakefile.cxx                              |  130 ++++-----------
 Source/cmMakefile.h                                |   13 --
 Source/cmState.cxx                                 |  173 ++++++++++++++++++--
 Source/cmState.h                                   |   15 +-
 Tests/RunCMake/CMakeLists.txt                      |    1 +
 .../RunCMake/{Ninja => PolicyScope}/CMakeLists.txt |    2 +-
 Tests/RunCMake/PolicyScope/RunCMakeTest.cmake      |    4 +
 .../dir-in-macro-generate-time-result.txt}         |    0
 .../dir-in-macro-generate-time-stderr.txt}         |    4 +-
 .../PolicyScope/dir-in-macro-generate-time.cmake   |    2 +
 .../PolicyScope/dir-in-macro-include.cmake         |    6 +
 Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt     |    5 +
 .../PolicyScope/dir1/foo.cpp}                      |    0
 .../parent-dir-generate-time-result.txt}           |    0
 .../PolicyScope/parent-dir-generate-time.cmake     |    7 +
 16 files changed, 237 insertions(+), 131 deletions(-)
 copy Tests/RunCMake/{Ninja => PolicyScope}/CMakeLists.txt (66%)
 create mode 100644 Tests/RunCMake/PolicyScope/RunCMakeTest.cmake
 copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => PolicyScope/dir-in-macro-generate-time-result.txt} (100%)
 copy Tests/RunCMake/{GeneratorExpression/CMP0044-WARN-stderr.txt => PolicyScope/dir-in-macro-generate-time-stderr.txt} (69%)
 create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-generate-time.cmake
 create mode 100644 Tests/RunCMake/PolicyScope/dir-in-macro-include.cmake
 create mode 100644 Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt
 copy Tests/{CTestTestCycle/simple.cxx => RunCMake/PolicyScope/dir1/foo.cpp} (100%)
 copy Tests/RunCMake/{CMP0022/CMP0022-WARN-empty-old-result.txt => PolicyScope/parent-dir-generate-time-result.txt} (100%)
 create mode 100644 Tests/RunCMake/PolicyScope/parent-dir-generate-time.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list