[Cmake-commits] CMake branch, next, updated. v3.2.2-2880-g606330f
Stephen Kelly
steveire at gmail.com
Sun May 17 11:08:23 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 606330f6d0ca88721d68bd4947993e17efcd064e (commit)
via 65738b09d9e4e736fd63d84b57984370d8a97e5e (commit)
via b79bc1a0f8405ad8bd21e1eae916e96a67960cfe (commit)
via a3f3c5a3f1ae7fdce07a54167c0f6c58dd56d84a (commit)
via 9ecddf1370e1228767379dc2941112ffa2713c66 (commit)
via e22a58540fb5039b9dad09668de6a307269d763a (commit)
via 818574d128ea4a93c13457c9e7b2461f7980289e (commit)
from 2cf25b949bd3fd8a59aa1cbfc75ad171318d059d (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=606330f6d0ca88721d68bd4947993e17efcd064e
commit 606330f6d0ca88721d68bd4947993e17efcd064e
Merge: 2cf25b9 65738b0
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 11:08:21 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun May 17 11:08:21 2015 -0400
Merge topic 'clean-up-cmMakefile' into next
65738b09 cmMakefile: Remove VarUsageStack.
b79bc1a0 cmMakefile: Remove VarInitStack.
a3f3c5a3 cmMakefile: Use more suitable method name to log var usage.
9ecddf13 cmMakefile: Move internal method to private scope.
e22a5854 cmMakefile: Mark definitions explicitly erased, even at top level.
818574d1 cmMakefile: Raise variable in scope explicitly when needed.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65738b09d9e4e736fd63d84b57984370d8a97e5e
commit 65738b09d9e4e736fd63d84b57984370d8a97e5e
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:07:48 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..c995404 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -47,7 +47,6 @@ class cmMakefile::Internals
{
public:
std::list<cmDefinitions> VarStack;
- std::stack<std::set<std::string> > VarUsageStack;
bool IsSourceFileTryCompile;
void PushDefinitions()
@@ -84,9 +83,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 +141,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 +578,6 @@ bool cmMakefile::ReadListFile(const char* listfile,
if (res)
{
- // Check for unused variables
this->CheckForUnusedVariables();
}
@@ -1718,7 +1715,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 +1788,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 +1806,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 +1816,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 +1824,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 +1868,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 +2336,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 +2356,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 +4282,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 +4298,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.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b79bc1a0f8405ad8bd21e1eae916e96a67960cfe
commit b79bc1a0f8405ad8bd21e1eae916e96a67960cfe
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 13:37:41 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun May 17 17:07:47 2015 +0200
cmMakefile: Remove VarInitStack.
In cmMakefile::PushScope, a copy of the closure of keys initialized
in the parent scope is made. In PopScope, essentially the same copy
is inserted back into the parent. That means a lot of duplication
of strings and a lot of string comparisons. None of it is needed,
because the cmDefinitions keys already provide a canonical
representation of what is initialized.
The removal of the separate container also makes the variable handling
code more easy to reason about in general.
Before this patch, configuring llvm uses 200 KiB for the VarInitStack.
Overall peak memory consumption goes from 35.5 MiB to 35.1 MiB.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 97a16ea..5b03bd4 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -54,6 +54,20 @@ void cmDefinitions::Raise(const std::string& key,
cmDefinitions::GetInternal(key, begin, end, true);
}
+bool cmDefinitions::HasKey(const std::string& key,
+ StackConstIter begin, StackConstIter end)
+{
+ for (StackConstIter it = begin; it != end; ++it)
+ {
+ MapType::const_iterator i = it->Map.find(key);
+ if (i != it->Map.end())
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
//----------------------------------------------------------------------------
void cmDefinitions::Set(const std::string& key, const char* value)
{
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4d9051b..e998963 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -36,6 +36,9 @@ public:
static void Raise(const std::string& key, StackIter begin, StackIter end);
+ static bool HasKey(const std::string& key,
+ StackConstIter begin, StackConstIter end);
+
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9bccea6..dd78d07 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -47,7 +47,6 @@ class cmMakefile::Internals
{
public:
std::list<cmDefinitions> VarStack;
- std::stack<std::set<std::string> > VarInitStack;
std::stack<std::set<std::string> > VarUsageStack;
bool IsSourceFileTryCompile;
@@ -69,6 +68,12 @@ public:
this->VarStack.rend());
}
+ bool IsInitialized(std::string const& name)
+ {
+ return cmDefinitions::HasKey(name, this->VarStack.rbegin(),
+ this->VarStack.rend());
+ }
+
void SetDefinition(std::string const& name, std::string const& value)
{
this->VarStack.back().Set(name, value.c_str());
@@ -137,7 +142,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
StateSnapshot(localGenerator->GetStateSnapshot())
{
this->Internal->PushDefinitions();
- this->Internal->VarInitStack.push(std::set<std::string>());
this->Internal->VarUsageStack.push(std::set<std::string>());
this->Internal->IsSourceFileTryCompile = false;
@@ -1711,13 +1715,12 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
return;
}
- this->Internal->SetDefinition(name, value);
if (this->VariableInitialized(name))
{
this->LogUnused("changing definition", name);
this->Internal->VarUsageStack.top().erase(name);
}
- this->Internal->VarInitStack.top().insert(name);
+ this->Internal->SetDefinition(name, value);
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
@@ -1786,13 +1789,12 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
void cmMakefile::AddDefinition(const std::string& name, bool value)
{
- this->Internal->SetDefinition(name, value ? "ON" : "OFF");
if (this->VariableInitialized(name))
{
this->LogUnused("changing definition", name);
this->Internal->VarUsageStack.top().erase(name);
}
- this->Internal->VarInitStack.top().insert(name);
+ this->Internal->SetDefinition(name, value ? "ON" : "OFF");
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
@@ -1824,12 +1826,7 @@ void cmMakefile::MarkVariableAsUsed(const std::string& var)
bool cmMakefile::VariableInitialized(const std::string& var) const
{
- if(this->Internal->VarInitStack.top().find(var) !=
- this->Internal->VarInitStack.top().end())
- {
- return true;
- }
- return false;
+ return this->Internal->IsInitialized(var);
}
bool cmMakefile::VariableUsed(const std::string& var) const
@@ -1883,13 +1880,12 @@ void cmMakefile::LogUnused(const char* reason,
void cmMakefile::RemoveDefinition(const std::string& name)
{
- this->Internal->RemoveDefinition(name);
if (this->VariableInitialized(name))
{
this->LogUnused("unsetting", name);
this->Internal->VarUsageStack.top().erase(name);
}
- this->Internal->VarInitStack.top().insert(name);
+ this->Internal->RemoveDefinition(name);
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
@@ -4307,9 +4303,7 @@ std::string cmMakefile::FormatListFileStack() const
void cmMakefile::PushScope()
{
this->Internal->PushDefinitions();
- const std::set<std::string>& init = this->Internal->VarInitStack.top();
const std::set<std::string>& usage = this->Internal->VarUsageStack.top();
- this->Internal->VarInitStack.push(init);
this->Internal->VarUsageStack.push(usage);
this->PushLoopBlockBarrier();
@@ -4327,7 +4321,6 @@ void cmMakefile::PopScope()
this->PopLoopBlockBarrier();
- std::set<std::string> init = this->Internal->VarInitStack.top();
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
@@ -4335,7 +4328,6 @@ void cmMakefile::PopScope()
std::vector<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it)
{
- init.erase(*it);
if (!this->VariableUsed(*it))
{
this->LogUnused("out of scope", *it);
@@ -4347,10 +4339,8 @@ void cmMakefile::PopScope()
}
this->Internal->PopDefinitions();
- this->Internal->VarInitStack.pop();
this->Internal->VarUsageStack.pop();
- // Push initialization and usage up to the parent scope.
- this->Internal->VarInitStack.top().insert(init.begin(), init.end());
+ // Push usage up to the parent scope.
this->Internal->VarUsageStack.top().insert(usage.begin(), usage.end());
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3f3c5a3f1ae7fdce07a54167c0f6c58dd56d84a
commit a3f3c5a3f1ae7fdce07a54167c0f6c58dd56d84a
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 16:28:39 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun May 17 17:07:46 2015 +0200
cmMakefile: Use more suitable method name to log var usage.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 89ee7ad..9bccea6 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1714,7 +1714,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
this->Internal->SetDefinition(name, value);
if (this->VariableInitialized(name))
{
- this->CheckForUnused("changing definition", name);
+ this->LogUnused("changing definition", name);
this->Internal->VarUsageStack.top().erase(name);
}
this->Internal->VarInitStack.top().insert(name);
@@ -1789,7 +1789,7 @@ void cmMakefile::AddDefinition(const std::string& name, bool value)
this->Internal->SetDefinition(name, value ? "ON" : "OFF");
if (this->VariableInitialized(name))
{
- this->CheckForUnused("changing definition", name);
+ this->LogUnused("changing definition", name);
this->Internal->VarUsageStack.top().erase(name);
}
this->Internal->VarInitStack.top().insert(name);
@@ -1813,7 +1813,7 @@ void cmMakefile::CheckForUnusedVariables() const
std::vector<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it)
{
- this->CheckForUnused("out of scope", *it);
+ this->LogUnused("out of scope", *it);
}
}
@@ -1842,7 +1842,7 @@ bool cmMakefile::VariableUsed(const std::string& var) const
return false;
}
-void cmMakefile::CheckForUnused(const char* reason,
+void cmMakefile::LogUnused(const char* reason,
const std::string& name) const
{
if (this->WarnUnused && !this->VariableUsed(name))
@@ -1886,7 +1886,7 @@ void cmMakefile::RemoveDefinition(const std::string& name)
this->Internal->RemoveDefinition(name);
if (this->VariableInitialized(name))
{
- this->CheckForUnused("unsetting", name);
+ this->LogUnused("unsetting", name);
this->Internal->VarUsageStack.top().erase(name);
}
this->Internal->VarInitStack.top().insert(name);
@@ -4338,7 +4338,7 @@ void cmMakefile::PopScope()
init.erase(*it);
if (!this->VariableUsed(*it))
{
- this->CheckForUnused("out of scope", *it);
+ this->LogUnused("out of scope", *it);
}
else
{
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 7eee963..ae026d7 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -839,7 +839,7 @@ protected:
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
// Check for a an unused variable
- void CheckForUnused(const char* reason, const std::string& name) const;
+ void LogUnused(const char* reason, const std::string& name) const;
std::string ProjectName; // project name
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9ecddf1370e1228767379dc2941112ffa2713c66
commit 9ecddf1370e1228767379dc2941112ffa2713c66
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 16:27:47 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun May 17 17:07:46 2015 +0200
cmMakefile: Move internal method to private scope.
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 5d6419a..7eee963 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -62,8 +62,6 @@ class cmMakefile
class Internals;
cmsys::auto_ptr<Internals> Internal;
public:
- /* Check for unused variables in this scope */
- void CheckForUnusedVariables() const;
/* Mark a variable as used */
void MarkVariableAsUsed(const std::string& var);
/* return true if a variable has been initialized */
@@ -1050,6 +1048,8 @@ private:
bool HaveCxxStandardAvailable(cmTarget const* target,
const std::string& feature) const;
+ void CheckForUnusedVariables() const;
+
mutable bool SuppressWatches;
};
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e22a58540fb5039b9dad09668de6a307269d763a
commit e22a58540fb5039b9dad09668de6a307269d763a
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 15:20:38 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun May 17 17:07:45 2015 +0200
cmMakefile: Mark definitions explicitly erased, even at top level.
Presumably the intention here is to attempt to optimize memory by not
storing what is not needed. However, all keys need to be tracked
anyway to implement initialization tracking, and this special case
gets in the way of simplifying the implementation of that.
This doesn't change any observable effects because values set
to 0 are considered not to exist by the cmDefinitions API.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index d7b6279..97a16ea 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -61,11 +61,6 @@ void cmDefinitions::Set(const std::string& key, const char* value)
this->Map[key] = def;
}
-void cmDefinitions::Erase(const std::string& key)
-{
- this->Map.erase(key);
-}
-
//----------------------------------------------------------------------------
std::vector<std::string> cmDefinitions::LocalKeys() const
{
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index c1e2d95..4d9051b 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -39,8 +39,6 @@ public:
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
- void Erase(const std::string& key);
-
/** Get the set of all local keys. */
std::vector<std::string> LocalKeys() const;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ccec8ca..89ee7ad 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -76,15 +76,7 @@ public:
void RemoveDefinition(std::string const& name)
{
- if (this->VarStack.size() > 1)
- {
- // In lower scopes we store keys, defined or not.
- this->VarStack.back().Set(name, 0);
- }
- else
- {
- this->VarStack.back().Erase(name);
- }
+ this->VarStack.back().Set(name, 0);
}
std::vector<std::string> LocalKeys() const
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=818574d128ea4a93c13457c9e7b2461f7980289e
commit 818574d128ea4a93c13457c9e7b2461f7980289e
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun May 17 13:21:02 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sun May 17 17:07:45 2015 +0200
cmMakefile: Raise variable in scope explicitly when needed.
The Get method implicitly pulls a copy of all variables into a local scope. This
is not necessary.
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index e2c6876..d7b6279 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -18,7 +18,7 @@ cmDefinitions::Def cmDefinitions::NoDef;
//----------------------------------------------------------------------------
cmDefinitions::Def const& cmDefinitions::GetInternal(
- const std::string& key, StackIter begin, StackIter end)
+ const std::string& key, StackIter begin, StackIter end, bool raise)
{
assert(begin != end);
MapType::const_iterator i = begin->Map.find(key);
@@ -32,7 +32,11 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(
{
return cmDefinitions::NoDef;
}
- Def const& def = cmDefinitions::GetInternal(key, it, end);
+ Def const& def = cmDefinitions::GetInternal(key, it, end, raise);
+ if (!raise)
+ {
+ return def;
+ }
return begin->Map.insert(MapType::value_type(key, def)).first->second;
}
@@ -40,10 +44,16 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(
const char* cmDefinitions::Get(const std::string& key,
StackIter begin, StackIter end)
{
- Def const& def = cmDefinitions::GetInternal(key, begin, end);
+ Def const& def = cmDefinitions::GetInternal(key, begin, end, false);
return def.Exists? def.c_str() : 0;
}
+void cmDefinitions::Raise(const std::string& key,
+ StackIter begin, StackIter end)
+{
+ cmDefinitions::GetInternal(key, begin, end, true);
+}
+
//----------------------------------------------------------------------------
void cmDefinitions::Set(const std::string& key, const char* value)
{
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 80643a9..c1e2d95 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -31,11 +31,11 @@ class cmDefinitions
typedef std::list<cmDefinitions>::reverse_iterator StackIter;
typedef std::list<cmDefinitions>::const_reverse_iterator StackConstIter;
public:
- /** Get the value associated with a key; null if none.
- Store the result locally if it came from a parent. */
static const char* Get(const std::string& key,
StackIter begin, StackIter end);
+ static void Raise(const std::string& key, StackIter begin, StackIter end);
+
/** Set (or unset if null) a value associated with a key. */
void Set(const std::string& key, const char* value);
@@ -73,7 +73,7 @@ private:
MapType Map;
static Def const& GetInternal(const std::string& key,
- StackIter begin, StackIter end);
+ StackIter begin, StackIter end, bool raise);
};
#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f1f4223..ccec8ca 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -130,7 +130,7 @@ public:
return true;
}
// First localize the definition in the current scope.
- this->GetDefinition(var);
+ cmDefinitions::Raise(var, this->VarStack.rbegin(), this->VarStack.rend());
// Now update the definition in the parent scope.
it->Set(var, varDef);
-----------------------------------------------------------------------
Summary of changes:
Source/cmDefinitions.cxx | 42 +++++++++++++-----
Source/cmDefinitions.h | 27 +++++++-----
Source/cmMakefile.cxx | 109 +++++++++++-----------------------------------
Source/cmMakefile.h | 8 ++--
4 files changed, 75 insertions(+), 111 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list