[Cmake-commits] CMake branch, next, updated. v3.2.2-2884-gf5c8a97

Stephen Kelly steveire at gmail.com
Sun May 17 11:18:42 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  f5c8a9797b7d0efb79566c1ef3014bc08e7a92bc (commit)
       via  12a8c343865c8824578802fc8faeac16b9eff7d9 (commit)
      from  96013784f66155d2e6cf623b1da16be3baa139f6 (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=f5c8a9797b7d0efb79566c1ef3014bc08e7a92bc
commit f5c8a9797b7d0efb79566c1ef3014bc08e7a92bc
Merge: 9601378 12a8c34
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 11:18:42 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun May 17 11:18:42 2015 -0400

    Merge topic 'clean-up-cmMakefile' into next
    
    12a8c343 cmMakefile: Remove VarUsageStack.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=12a8c343865c8824578802fc8faeac16b9eff7d9
commit 12a8c343865c8824578802fc8faeac16b9eff7d9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 16:19:55 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sun May 17 17:18:20 2015 +0200

    cmMakefile: Remove VarUsageStack.
    
    Store usage information in the cmDefintions value instead.  We already
    pay for the memory as padding in the Def struct, so we might as well
    use it.

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 5b03bd4..2dab169 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -21,9 +21,10 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(
   const std::string& key, StackIter begin, StackIter end, bool raise)
 {
   assert(begin != end);
-  MapType::const_iterator i = begin->Map.find(key);
+  MapType::iterator i = begin->Map.find(key);
   if (i != begin->Map.end())
     {
+    i->second.Used = true;
     return i->second;
     }
   StackIter it = begin;
@@ -76,7 +77,7 @@ void cmDefinitions::Set(const std::string& key, const char* value)
 }
 
 //----------------------------------------------------------------------------
-std::vector<std::string> cmDefinitions::LocalKeys() const
+std::vector<std::string> cmDefinitions::UnusedKeys() const
 {
   std::vector<std::string> keys;
   keys.reserve(this->Map.size());
@@ -84,7 +85,7 @@ std::vector<std::string> cmDefinitions::LocalKeys() const
   for(MapType::const_iterator mi = this->Map.begin();
       mi != this->Map.end(); ++mi)
     {
-    if (mi->second.Exists)
+    if (!mi->second.Used)
       {
       keys.push_back(mi->first);
       }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index e998963..294f42f 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -42,8 +42,7 @@ public:
   /** Set (or unset if null) a value associated with a key.  */
   void Set(const std::string& key, const char* value);
 
-  /** Get the set of all local keys.  */
-  std::vector<std::string> LocalKeys() const;
+  std::vector<std::string> UnusedKeys() const;
 
   static std::vector<std::string> ClosureKeys(StackConstIter begin,
                                               StackConstIter end);
@@ -57,11 +56,16 @@ private:
   private:
     typedef std::string std_string;
   public:
-    Def(): std_string(), Exists(false) {}
-    Def(const char* v): std_string(v?v:""), Exists(v?true:false) {}
-    Def(const std_string& v): std_string(v), Exists(true) {}
-    Def(Def const& d): std_string(d), Exists(d.Exists) {}
+    Def(): std_string(), Exists(false), Used(false) {}
+    Def(const char* v)
+      : std_string(v ? v : ""),
+        Exists(v ? true : false),
+        Used(false)
+    {}
+    Def(const std_string& v): std_string(v), Exists(true), Used(false) {}
+    Def(Def const& d): std_string(d), Exists(d.Exists), Used(d.Used) {}
     bool Exists;
+    bool Used;
   };
   static Def NoDef;
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index dd78d07..1267418 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -38,7 +38,6 @@
 #include <cmsys/FStream.hxx>
 #include <cmsys/auto_ptr.hxx>
 
-#include <stack>
 #include <list>
 #include <ctype.h> // for isspace
 #include <assert.h>
@@ -47,7 +46,6 @@ class cmMakefile::Internals
 {
 public:
   std::list<cmDefinitions> VarStack;
-  std::stack<std::set<std::string> > VarUsageStack;
   bool IsSourceFileTryCompile;
 
   void PushDefinitions()
@@ -84,9 +82,9 @@ public:
     this->VarStack.back().Set(name, 0);
   }
 
-  std::vector<std::string> LocalKeys() const
+  std::vector<std::string> UnusedKeys() const
   {
-    return this->VarStack.back().LocalKeys();
+    return this->VarStack.back().UnusedKeys();
   }
 
   std::vector<std::string> ClosureKeys() const
@@ -142,7 +140,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
     StateSnapshot(localGenerator->GetStateSnapshot())
 {
   this->Internal->PushDefinitions();
-  this->Internal->VarUsageStack.push(std::set<std::string>());
   this->Internal->IsSourceFileTryCompile = false;
 
   this->GeneratingBuildSystem = false;
@@ -580,7 +577,6 @@ bool cmMakefile::ReadListFile(const char* listfile,
 
   if (res)
     {
-    // Check for unused variables
     this->CheckForUnusedVariables();
     }
 
@@ -1718,7 +1714,6 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
   if (this->VariableInitialized(name))
     {
     this->LogUnused("changing definition", name);
-    this->Internal->VarUsageStack.top().erase(name);
     }
   this->Internal->SetDefinition(name, value);
 
@@ -1792,7 +1787,6 @@ void cmMakefile::AddDefinition(const std::string& name, bool value)
   if (this->VariableInitialized(name))
     {
     this->LogUnused("changing definition", name);
-    this->Internal->VarUsageStack.top().erase(name);
     }
   this->Internal->SetDefinition(name, value ? "ON" : "OFF");
 #ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1811,9 +1805,9 @@ void cmMakefile::CheckForUnusedVariables() const
     {
     return;
     }
-  const std::vector<std::string>& locals = this->Internal->LocalKeys();
-  std::vector<std::string>::const_iterator it = locals.begin();
-  for (; it != locals.end(); ++it)
+  const std::vector<std::string>& unused = this->Internal->UnusedKeys();
+  std::vector<std::string>::const_iterator it = unused.begin();
+  for (; it != unused.end(); ++it)
     {
     this->LogUnused("out of scope", *it);
     }
@@ -1821,7 +1815,7 @@ void cmMakefile::CheckForUnusedVariables() const
 
 void cmMakefile::MarkVariableAsUsed(const std::string& var)
 {
-  this->Internal->VarUsageStack.top().insert(var);
+  this->Internal->GetDefinition(var);
 }
 
 bool cmMakefile::VariableInitialized(const std::string& var) const
@@ -1829,20 +1823,10 @@ bool cmMakefile::VariableInitialized(const std::string& var) const
   return this->Internal->IsInitialized(var);
 }
 
-bool cmMakefile::VariableUsed(const std::string& var) const
-{
-  if(this->Internal->VarUsageStack.top().find(var) !=
-      this->Internal->VarUsageStack.top().end())
-    {
-    return true;
-    }
-  return false;
-}
-
 void cmMakefile::LogUnused(const char* reason,
                                 const std::string& name) const
 {
-  if (this->WarnUnused && !this->VariableUsed(name))
+  if (this->WarnUnused)
     {
     std::string path;
     cmListFileBacktrace bt(this->GetLocalGenerator());
@@ -1883,7 +1867,6 @@ void cmMakefile::RemoveDefinition(const std::string& name)
   if (this->VariableInitialized(name))
     {
     this->LogUnused("unsetting", name);
-    this->Internal->VarUsageStack.top().erase(name);
     }
   this->Internal->RemoveDefinition(name);
 #ifdef CMAKE_BUILD_WITH_CMAKE
@@ -2352,7 +2335,6 @@ const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
 bool cmMakefile::IsDefinitionSet(const std::string& name) const
 {
   const char* def = this->Internal->GetDefinition(name);
-  this->Internal->VarUsageStack.top().insert(name);
   if(!def)
     {
     def = this->GetState()->GetInitializedCacheValue(name);
@@ -2373,10 +2355,6 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
 
 const char* cmMakefile::GetDefinition(const std::string& name) const
 {
-  if (this->WarnUnused)
-    {
-    this->Internal->VarUsageStack.top().insert(name);
-    }
   const char* def = this->Internal->GetDefinition(name);
   if(!def)
     {
@@ -4303,8 +4281,6 @@ std::string cmMakefile::FormatListFileStack() const
 void cmMakefile::PushScope()
 {
   this->Internal->PushDefinitions();
-  const std::set<std::string>& usage = this->Internal->VarUsageStack.top();
-  this->Internal->VarUsageStack.push(usage);
 
   this->PushLoopBlockBarrier();
 
@@ -4321,27 +4297,9 @@ void cmMakefile::PopScope()
 
   this->PopLoopBlockBarrier();
 
-  std::set<std::string> usage = this->Internal->VarUsageStack.top();
-  const std::vector<std::string>& locals = this->Internal->LocalKeys();
-  // Remove initialization and usage information for variables in the local
-  // scope.
-  std::vector<std::string>::const_iterator it = locals.begin();
-  for (; it != locals.end(); ++it)
-    {
-    if (!this->VariableUsed(*it))
-      {
-      this->LogUnused("out of scope", *it);
-      }
-    else
-      {
-      usage.erase(*it);
-      }
-    }
+  this->CheckForUnusedVariables();
 
   this->Internal->PopDefinitions();
-  this->Internal->VarUsageStack.pop();
-  // Push usage up to the parent scope.
-  this->Internal->VarUsageStack.top().insert(usage.begin(), usage.end());
 }
 
 void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index ae026d7..cc76a78 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -66,8 +66,6 @@ public:
   void MarkVariableAsUsed(const std::string& var);
   /* return true if a variable has been initialized */
   bool VariableInitialized(const std::string& ) const;
-  /* return true if a variable has been used */
-  bool VariableUsed(const std::string& ) const;
 
   /**
    * Construct an empty makefile.

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list