From 44a8115797cc3f804d653928d71b126b39e29210 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:40:58 +0200 Subject: [PATCH 01/26] cmPolicies: Replace UNDEFINED bitset with WARN bitset. Might as well use the existing concept. --- Source/cmPolicies.cxx | 13 +++++-------- Source/cmPolicies.h | 3 +-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index f8d61db8d..3498adc80 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -343,11 +343,6 @@ cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id) return e.str(); } -cmPolicies::PolicyMap::PolicyMap() -{ - this->UNDEFINED.set(); -} - cmPolicies::PolicyStatus cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const { @@ -375,8 +370,8 @@ cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status) { - this->UNDEFINED.reset(id); this->OLD[id] = (status == cmPolicies::OLD); + this->WARN[id] = (status == cmPolicies::WARN); this->NEW[id] = (status == cmPolicies::NEW); this->REQUIRED_ALWAYS[id] = (status == cmPolicies::REQUIRED_ALWAYS); this->REQUIRED_IF_USED[id] = (status == cmPolicies::REQUIRED_IF_USED); @@ -384,10 +379,12 @@ void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id, bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const { - return !this->UNDEFINED[id]; + return this->OLD[id] || this->WARN[id] || this->NEW[id] + || this->REQUIRED_ALWAYS[id] || this->REQUIRED_IF_USED[id]; } bool cmPolicies::PolicyMap::IsEmpty() const { - return !this->UNDEFINED.none(); + return this->OLD.none() && this->WARN.none() && this->NEW.none() + && this->REQUIRED_ALWAYS.none() && this->REQUIRED_IF_USED.none(); } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 00d857a63..8c72dfe4a 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -281,15 +281,14 @@ public: /** Represent a set of policy values. */ struct PolicyMap { - PolicyMap(); PolicyStatus Get(PolicyID id) const; void Set(PolicyID id, PolicyStatus status); bool IsDefined(PolicyID id) const; bool IsEmpty() const; private: - std::bitset UNDEFINED; std::bitset OLD; + std::bitset WARN; std::bitset NEW; std::bitset REQUIRED_IF_USED; std::bitset REQUIRED_ALWAYS; From 93cc2eef38eab76831916bfee9d6fe16fbaaf4c1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:41:05 +0200 Subject: [PATCH 02/26] cmPolicies: Store all statuses in a single bitset. Currently there are an optimal number of policies (64) such that there are no wasted bits. When another policy is added, the cmPolicyMap will grow from 40 bytes to 80, and occupy 45. By storing all in a single bitset, we stay under the cache line size of 64 bytes until there are 512 policies in a range. --- Source/cmPolicies.cxx | 30 +++++++++++++++++------------- Source/cmPolicies.h | 7 ++----- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 3498adc80..5026893ba 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -348,19 +348,19 @@ cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const { PolicyStatus status = cmPolicies::WARN; - if (this->OLD[id]) + if (this->Status[(POLICY_STATUS_COUNT * id) + OLD]) { status = cmPolicies::OLD; } - else if (this->NEW[id]) + else if (this->Status[(POLICY_STATUS_COUNT * id) + NEW]) { status = cmPolicies::NEW; } - else if (this->REQUIRED_ALWAYS[id]) + else if (this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS]) { status = cmPolicies::REQUIRED_ALWAYS; } - else if (this->REQUIRED_IF_USED[id]) + else if (this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED]) { status = cmPolicies::REQUIRED_IF_USED; } @@ -370,21 +370,25 @@ cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status) { - this->OLD[id] = (status == cmPolicies::OLD); - this->WARN[id] = (status == cmPolicies::WARN); - this->NEW[id] = (status == cmPolicies::NEW); - this->REQUIRED_ALWAYS[id] = (status == cmPolicies::REQUIRED_ALWAYS); - this->REQUIRED_IF_USED[id] = (status == cmPolicies::REQUIRED_IF_USED); + this->Status[(POLICY_STATUS_COUNT * id) + OLD] = (status == OLD); + this->Status[(POLICY_STATUS_COUNT * id) + WARN] = (status == WARN); + this->Status[(POLICY_STATUS_COUNT * id) + NEW] = (status == NEW); + this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS] = + (status == REQUIRED_ALWAYS); + this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED] = + (status == REQUIRED_IF_USED); } bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const { - return this->OLD[id] || this->WARN[id] || this->NEW[id] - || this->REQUIRED_ALWAYS[id] || this->REQUIRED_IF_USED[id]; + return this->Status[(POLICY_STATUS_COUNT * id) + OLD] + || this->Status[(POLICY_STATUS_COUNT * id) + WARN] + || this->Status[(POLICY_STATUS_COUNT * id) + NEW] + || this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_ALWAYS] + || this->Status[(POLICY_STATUS_COUNT * id) + REQUIRED_IF_USED]; } bool cmPolicies::PolicyMap::IsEmpty() const { - return this->OLD.none() && this->WARN.none() && this->NEW.none() - && this->REQUIRED_ALWAYS.none() && this->REQUIRED_IF_USED.none(); + return this->Status.none(); } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 8c72dfe4a..8a3c27d9f 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -244,6 +244,7 @@ public: REQUIRED_IF_USED, REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW. }; +#define POLICY_STATUS_COUNT 5 /// Policy identifiers enum PolicyID @@ -287,11 +288,7 @@ public: bool IsEmpty() const; private: - std::bitset OLD; - std::bitset WARN; - std::bitset NEW; - std::bitset REQUIRED_IF_USED; - std::bitset REQUIRED_ALWAYS; + std::bitset Status; }; }; From 1c48edf8fc8cec71c780cbb1c587f10df0ab7185 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:46:26 +0200 Subject: [PATCH 03/26] cmProperty: Remove needless Name member. Size goes from 72 to 40 bytes with GNU libstdc++-5.1. --- Source/cmProperty.cxx | 7 ++----- Source/cmProperty.h | 6 ++---- Source/cmPropertyMap.cxx | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx index 40976db15..ef57068ad 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -12,17 +12,14 @@ #include "cmProperty.h" #include "cmSystemTools.h" -void cmProperty::Set(const std::string& name, const char *value) +void cmProperty::Set(const char *value) { - this->Name = name; this->Value = value; this->ValueHasBeenSet = true; } -void cmProperty::Append(const std::string& name, const char *value, - bool asString) +void cmProperty::Append(const char *value, bool asString) { - this->Name = name; if(!this->Value.empty() && *value && !asString) { this->Value += ";"; diff --git a/Source/cmProperty.h b/Source/cmProperty.h index 659c4c324..e026372db 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -21,11 +21,10 @@ public: TEST, VARIABLE, CACHED_VARIABLE, INSTALL }; // set this property - void Set(const std::string& name, const char *value); + void Set(const char *value); // append to this property - void Append(const std::string& name, const char *value, - bool asString = false); + void Append(const char *value, bool asString = false); // get the value const char *GetValue() const; @@ -34,7 +33,6 @@ public: cmProperty() { this->ValueHasBeenSet = false; } protected: - std::string Name; std::string Value; bool ValueHasBeenSet; }; diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 070f6f1ed..03124dca5 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -40,7 +40,7 @@ void cmPropertyMap::SetProperty(const std::string& name, const char *value, (void)scope; cmProperty *prop = this->GetOrCreateProperty(name); - prop->Set(name,value); + prop->Set(value); } void cmPropertyMap::AppendProperty(const std::string& name, const char* value, @@ -54,7 +54,7 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value, (void)scope; cmProperty *prop = this->GetOrCreateProperty(name); - prop->Append(name,value,asString); + prop->Append(value,asString); } const char *cmPropertyMap From 9058e27a431b01319b18cc4099780fa017ada113 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:46:38 +0200 Subject: [PATCH 04/26] Constify property definition API. --- Source/cmGetPropertyCommand.cxx | 6 ++---- Source/cmPropertyDefinitionMap.cxx | 8 ++++---- Source/cmPropertyDefinitionMap.h | 4 ++-- Source/cmState.cxx | 28 +++++++++++++++++++++------- Source/cmState.h | 10 ++++++---- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 250bd3551..36b6c6435 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -142,8 +142,7 @@ bool cmGetPropertyCommand { // Lookup brief documentation. std::string output; - if(cmPropertyDefinition* def = - this->Makefile->GetState()-> + if(cmPropertyDefinition const* def = this->Makefile->GetState()-> GetPropertyDefinition(this->PropertyName, scope)) { output = def->GetShortDescription(); @@ -158,8 +157,7 @@ bool cmGetPropertyCommand { // Lookup full documentation. std::string output; - if(cmPropertyDefinition* def = - this->Makefile->GetState()-> + if(cmPropertyDefinition const* def = this->Makefile->GetState()-> GetPropertyDefinition(this->PropertyName, scope)) { output = def->GetFullDescription(); diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index 3875318f4..776fad1dc 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -29,9 +29,9 @@ void cmPropertyDefinitionMap } } -bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) +bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const { - cmPropertyDefinitionMap::iterator it = this->find(name); + cmPropertyDefinitionMap::const_iterator it = this->find(name); if (it == this->end()) { return false; @@ -40,9 +40,9 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) return true; } -bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) +bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) const { - cmPropertyDefinitionMap::iterator it = this->find(name); + cmPropertyDefinitionMap::const_iterator it = this->find(name); if (it == this->end()) { return false; diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index 00c7328c6..f95c721a8 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -27,10 +27,10 @@ public: bool chain); // has a named property been defined - bool IsPropertyDefined(const std::string& name); + bool IsPropertyDefined(const std::string& name) const; // is a named property set to chain - bool IsPropertyChained(const std::string& name); + bool IsPropertyChained(const std::string& name) const; }; #endif diff --git a/Source/cmState.cxx b/Source/cmState.cxx index c6fb2998e..15a463804 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -256,27 +256,41 @@ void cmState::DefineProperty(const std::string& name, chained); } -cmPropertyDefinition *cmState +cmPropertyDefinition const* cmState ::GetPropertyDefinition(const std::string& name, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope) const { if (this->IsPropertyDefined(name,scope)) { - return &(this->PropertyDefinitions[scope][name]); + cmPropertyDefinitionMap const& defs = + this->PropertyDefinitions.find(scope)->second; + return &defs.find(name)->second; } return 0; } bool cmState::IsPropertyDefined(const std::string& name, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope) const { - return this->PropertyDefinitions[scope].IsPropertyDefined(name); + std::map::const_iterator it + = this->PropertyDefinitions.find(scope); + if (it == this->PropertyDefinitions.end()) + { + return false; + } + return it->second.IsPropertyDefined(name); } bool cmState::IsPropertyChained(const std::string& name, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope) const { - return this->PropertyDefinitions[scope].IsPropertyChained(name); + std::map::const_iterator it + = this->PropertyDefinitions.find(scope); + if (it == this->PropertyDefinitions.end()) + { + return false; + } + return it->second.IsPropertyChained(name); } void cmState::SetLanguageEnabled(std::string const& l) diff --git a/Source/cmState.h b/Source/cmState.h index 60b024f33..b06f77c9a 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -102,12 +102,14 @@ public: bool chain = false); // get property definition - cmPropertyDefinition *GetPropertyDefinition - (const std::string& name, cmProperty::ScopeType scope); + cmPropertyDefinition const* GetPropertyDefinition + (const std::string& name, cmProperty::ScopeType scope) const; // Is a property defined? - bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope); - bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope); + bool IsPropertyDefined(const std::string& name, + cmProperty::ScopeType scope) const; + bool IsPropertyChained(const std::string& name, + cmProperty::ScopeType scope) const; void SetLanguageEnabled(std::string const& l); bool GetLanguageEnabled(std::string const& l) const; From 7c0aa672fe4f1b5c4a15a89d90cd80009a1399d0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:41:15 +0200 Subject: [PATCH 05/26] cmPropertyMap: Remove scope parameter from API where not used. --- Source/cmCPluginAPI.cxx | 5 ++--- Source/cmCacheManager.cxx | 4 ++-- Source/cmMakefile.cxx | 4 ++-- Source/cmPropertyMap.cxx | 7 ++----- Source/cmPropertyMap.h | 5 ++--- Source/cmSourceFile.cxx | 5 ++--- Source/cmState.cxx | 5 ++--- Source/cmTarget.cxx | 18 ++++++------------ Source/cmTest.cxx | 4 ++-- 9 files changed, 22 insertions(+), 35 deletions(-) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index c55ea3597..bd8c10cc5 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -662,7 +662,7 @@ void CCONV cmSourceFileSetProperty(void *arg,const char *prop, else if(prop) { if(!value) { value = "NOTFOUND"; } - sf->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); + sf->Properties.SetProperty(prop, value); } } @@ -801,8 +801,7 @@ void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir, // Implement the old SetName method code here. if(headerFileOnly) { - sf->Properties.SetProperty("HEADER_FILE_ONLY", "1", - cmProperty::SOURCE_FILE); + sf->Properties.SetProperty("HEADER_FILE_ONLY", "1"); } sf->SourceName = name; std::string fname = sf->SourceName; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 108208ef1..6af14f29f 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -763,7 +763,7 @@ void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, } else { - this->Properties.SetProperty(prop, value, cmProperty::CACHE); + this->Properties.SetProperty(prop, value); } } @@ -789,7 +789,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop, } else { - this->Properties.AppendProperty(prop, value, cmProperty::CACHE, asString); + this->Properties.AppendProperty(prop, value, asString); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3ac77e9ea..9c0d4b10c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4089,7 +4089,7 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value) } } - this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY); + this->Properties.SetProperty(prop, value); } void cmMakefile::AppendProperty(const std::string& prop, @@ -4129,7 +4129,7 @@ void cmMakefile::AppendProperty(const std::string& prop, return; } - this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); + this->Properties.AppendProperty(prop, value, asString); } const char *cmMakefile::GetProperty(const std::string& prop) const diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 03124dca5..d1402c832 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -29,29 +29,26 @@ cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name) return prop; } -void cmPropertyMap::SetProperty(const std::string& name, const char *value, - cmProperty::ScopeType scope) +void cmPropertyMap::SetProperty(const std::string& name, const char *value) { if(!value) { this->erase(name); return; } - (void)scope; cmProperty *prop = this->GetOrCreateProperty(name); prop->Set(value); } void cmPropertyMap::AppendProperty(const std::string& name, const char* value, - cmProperty::ScopeType scope, bool asString) + bool asString) { // Skip if nothing to append. if(!value || !*value) { return; } - (void)scope; cmProperty *prop = this->GetOrCreateProperty(name); prop->Append(value,asString); diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 02d4235da..722732b56 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -21,11 +21,10 @@ class cmPropertyMap : public std::map public: cmProperty *GetOrCreateProperty(const std::string& name); - void SetProperty(const std::string& name, const char *value, - cmProperty::ScopeType scope); + void SetProperty(const std::string& name, const char *value); void AppendProperty(const std::string& name, const char* value, - cmProperty::ScopeType scope, bool asString=false); + bool asString=false); const char *GetPropertyValue(const std::string& name, cmProperty::ScopeType scope, diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 724ab3941..df511d832 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -299,7 +299,7 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) //---------------------------------------------------------------------------- void cmSourceFile::SetProperty(const std::string& prop, const char* value) { - this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); + this->Properties.SetProperty(prop, value); if (this->IsUiFile) { @@ -315,8 +315,7 @@ void cmSourceFile::SetProperty(const std::string& prop, const char* value) void cmSourceFile::AppendProperty(const std::string& prop, const char* value, bool asString) { - this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE, - asString); + this->Properties.AppendProperty(prop, value, asString); } //---------------------------------------------------------------------------- diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 15a463804..7bfeda19a 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -438,14 +438,13 @@ void cmState::RemoveUserDefinedCommands() void cmState::SetGlobalProperty(const std::string& prop, const char* value) { - this->GlobalProperties.SetProperty(prop, value, cmProperty::GLOBAL); + this->GlobalProperties.SetProperty(prop, value); } void cmState::AppendGlobalProperty(const std::string& prop, const char* value, bool asString) { - this->GlobalProperties.AppendProperty(prop, value, - cmProperty::GLOBAL, asString); + this->GlobalProperties.AppendProperty(prop, value, asString); } const char *cmState::GetGlobalProperty(const std::string& prop) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 443696658..873163246 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1772,7 +1772,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else { - this->Properties.SetProperty(prop, value, cmProperty::TARGET); + this->Properties.SetProperty(prop, value); this->MaybeInvalidatePropertyCache(prop); } } @@ -1857,7 +1857,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else { - this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); + this->Properties.AppendProperty(prop, value, asString); this->MaybeInvalidatePropertyCache(prop); } } @@ -2938,8 +2938,7 @@ const char *cmTarget::GetProperty(const std::string& prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->Properties.SetProperty(propLOCATION, this->GetLocationForBuild(), - cmProperty::TARGET); + this->Properties.SetProperty(propLOCATION, this->GetLocationForBuild()); } // Support "LOCATION_". @@ -2950,9 +2949,7 @@ const char *cmTarget::GetProperty(const std::string& prop, return 0; } const char* configName = prop.c_str() + 9; - this->Properties.SetProperty(prop, - this->GetLocation(configName), - cmProperty::TARGET); + this->Properties.SetProperty(prop, this->GetLocation(configName)); } // Support "_LOCATION". else if(cmHasLiteralSuffix(prop, "_LOCATION")) @@ -2964,9 +2961,7 @@ const char *cmTarget::GetProperty(const std::string& prop, { return 0; } - this->Properties.SetProperty(prop, - this->GetLocation(configName), - cmProperty::TARGET); + this->Properties.SetProperty(prop, this->GetLocation(configName)); } } } @@ -3168,8 +3163,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } } } - this->Properties.SetProperty("SOURCES", ss.str().c_str(), - cmProperty::TARGET); + this->Properties.SetProperty("SOURCES", ss.str().c_str()); } } diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index ff5d4119e..c60685967 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -69,12 +69,12 @@ bool cmTest::GetPropertyAsBool(const std::string& prop) const //---------------------------------------------------------------------------- void cmTest::SetProperty(const std::string& prop, const char* value) { - this->Properties.SetProperty(prop, value, cmProperty::TEST); + this->Properties.SetProperty(prop, value); } //---------------------------------------------------------------------------- void cmTest::AppendProperty(const std::string& prop, const char* value, bool asString) { - this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString); + this->Properties.AppendProperty(prop, value, asString); } From 3ac4b90bfdcca97f1f63056c97afee38cf66ea12 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:41:20 +0200 Subject: [PATCH 06/26] cmPropertyMap: Require a non-empty name parameter. The cmGetPropertyCommand already checks for this. --- Source/cmGetCMakePropertyCommand.cxx | 8 +++++--- Source/cmGetDirectoryPropertyCommand.cxx | 6 +++++- Source/cmGetSourceFilePropertyCommand.cxx | 6 +++++- Source/cmGetTargetPropertyCommand.cxx | 6 +++++- Source/cmGetTestPropertyCommand.cxx | 6 +++++- Source/cmPropertyMap.cxx | 7 +++---- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 76803c103..6717035b7 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -52,9 +52,11 @@ bool cmGetCMakePropertyCommand } else { - const char *prop = - this->Makefile->GetState() - ->GetGlobalProperty(args[1]); + const char *prop = 0; + if (!args[1].empty()) + { + prop = this->Makefile->GetState()->GetGlobalProperty(args[1]); + } if (prop) { output = prop; diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index 4fe33189e..228e53cd2 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -84,7 +84,11 @@ bool cmGetDirectoryPropertyCommand return true; } - const char *prop = dir->GetProperty(*i); + const char *prop = 0; + if (!i->empty()) + { + prop = dir->GetProperty(*i); + } if (prop) { this->Makefile->AddDefinition(variable, prop); diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 7667a8592..46daa349a 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -38,7 +38,11 @@ bool cmGetSourceFilePropertyCommand this->Makefile->AddDefinition(var, sf->GetLanguage().c_str()); return true; } - const char *prop = sf->GetPropertyForUser(args[2]); + const char *prop = 0; + if (!args[2].empty()) + { + prop = sf->GetPropertyForUser(args[2]); + } if (prop) { this->Makefile->AddDefinition(var, prop); diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 315e85188..ca40bd077 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -40,7 +40,11 @@ bool cmGetTargetPropertyCommand else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) { cmTarget& target = *tgt; - const char* prop_cstr = target.GetProperty(args[2], this->Makefile); + const char* prop_cstr = 0; + if (!args[2].empty()) + { + prop_cstr = target.GetProperty(args[2], this->Makefile); + } if(prop_cstr) { prop = prop_cstr; diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index b3df4c3bc..bf34589f4 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -29,7 +29,11 @@ bool cmGetTestPropertyCommand cmTest *test = this->Makefile->GetTest(testName); if (test) { - const char *prop = test->GetProperty(args[1]); + const char *prop = 0; + if (!args[1].empty()) + { + prop = test->GetProperty(args[1]); + } if (prop) { this->Makefile->AddDefinition(var, prop); diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index d1402c832..de2cd0582 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -14,6 +14,8 @@ #include "cmake.h" #include "cmState.h" +#include + cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name) { cmPropertyMap::iterator it = this->find(name); @@ -60,10 +62,7 @@ const char *cmPropertyMap bool &chain) const { chain = false; - if (name.empty()) - { - return 0; - } + assert(!name.empty()); cmPropertyMap::const_iterator it = this->find(name); if (it == this->end()) From 5181fae264444ad7736614ceb1e78c51def2b97c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:41:30 +0200 Subject: [PATCH 07/26] cmPropertyMap: Remove chaining logic. The chaining logic doesn't belong to the container, and the CMakeInstance pointer doesn't need to be in cmPropertyMap. Size goes from 56 to 48 bytes with GNU libstdc++-5.1. --- Source/cmCPluginAPI.cxx | 10 ++-------- Source/cmCacheManager.cxx | 7 +------ Source/cmGlobalGenerator.cxx | 1 - Source/cmMakefile.cxx | 16 +++++++--------- Source/cmMakefile.h | 3 +-- Source/cmPropertyMap.cxx | 11 +---------- Source/cmPropertyMap.h | 13 +------------ Source/cmSetTestsPropertiesCommand.cxx | 6 ++++-- Source/cmSourceFile.cxx | 14 ++++++++------ Source/cmState.cxx | 4 +--- Source/cmTarget.cxx | 16 ++++++++-------- Source/cmTest.cxx | 14 ++++++++------ 12 files changed, 42 insertions(+), 73 deletions(-) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index bd8c10cc5..0d24ed5ed 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -526,11 +526,9 @@ void * CCONV cmCreateSourceFile(void) return (void*)new cmCPluginAPISourceFile; } -void * CCONV cmCreateNewSourceFile(void *arg) +void * CCONV cmCreateNewSourceFile(void *) { - cmMakefile *mf = static_cast(arg); cmCPluginAPISourceFile *sf = new cmCPluginAPISourceFile; - sf->Properties.SetCMakeInstance(mf->GetCMakeInstance()); return (void*)sf; } @@ -630,11 +628,7 @@ const char * CCONV cmSourceFileGetProperty(void *arg,const char *prop) { return sf->FullPath.c_str(); } - bool chain = false; - // Ignore chain because old code will not expect it and it is a - // pain to implement here anyway. - return sf->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE, - chain); + return sf->Properties.GetPropertyValue(prop); } } diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 6af14f29f..54209c5ce 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -161,7 +161,6 @@ bool cmCacheManager::LoadCache(const std::string& path, // Format is key:type=value std::string helpString; CacheEntry e; - e.Properties.SetCMakeInstance(this->CMakeInstance); cmSystemTools::GetLineFromStream(fin, buffer); realbuffer = buffer.c_str(); while(*realbuffer != '0' && @@ -323,7 +322,6 @@ bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey, { // Create an entry and store the property. CacheEntry& ne = this->Cache[key]; - ne.Properties.SetCMakeInstance(this->CMakeInstance); ne.Type = cmState::UNINITIALIZED; ne.SetProperty(*p, e.Value.c_str()); } @@ -645,7 +643,6 @@ void cmCacheManager::AddCacheEntry(const std::string& key, cmState::CacheEntryType type) { CacheEntry& e = this->Cache[key]; - e.Properties.SetCMakeInstance(this->CMakeInstance); if ( value ) { e.Value = value; @@ -744,9 +741,7 @@ cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const { return this->Value.c_str(); } - bool c = false; - return - this->Properties.GetPropertyValue(prop, cmProperty::CACHE, c); + return this->Properties.GetPropertyValue(prop); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 481de1946..bd949bb42 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2438,7 +2438,6 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( { // Package cmTarget target; - target.GetProperties().SetCMakeInstance(this->CMakeInstance); target.SetType(cmTarget::GLOBAL_TARGET, name); target.SetProperty("EXCLUDE_FROM_ALL","TRUE"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9c0d4b10c..bc308f179 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -213,8 +213,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$"); #endif - this->Properties.SetCMakeInstance(this->GetCMakeInstance()); - { const char* dir = this->GetCMakeInstance()->GetHomeDirectory(); this->AddDefinition("CMAKE_SOURCE_DIR", dir); @@ -4134,11 +4132,13 @@ void cmMakefile::AppendProperty(const std::string& prop, const char *cmMakefile::GetProperty(const std::string& prop) const { - return this->GetProperty(prop, cmProperty::DIRECTORY); + const bool chain = this->GetState()-> + IsPropertyChained(prop, cmProperty::DIRECTORY); + return this->GetProperty(prop, chain); } const char *cmMakefile::GetProperty(const std::string& prop, - cmProperty::ScopeType scope) const + bool chain) const { // watch for specific properties static std::string output; @@ -4242,15 +4242,13 @@ const char *cmMakefile::GetProperty(const std::string& prop, return output.c_str(); } - bool chain = false; - const char *retVal = - this->Properties.GetPropertyValue(prop, scope, chain); - if (chain) + const char *retVal = this->Properties.GetPropertyValue(prop); + if (!retVal && chain) { if(this->LocalGenerator->GetParent()) { return this->LocalGenerator->GetParent()->GetMakefile()-> - GetProperty(prop, scope); + GetProperty(prop, chain); } return this->GetState()->GetGlobalProperty(prop); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index def0c23e9..751863105 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -717,8 +717,7 @@ public: void AppendProperty(const std::string& prop, const char *value, bool asString=false); const char *GetProperty(const std::string& prop) const; - const char *GetProperty(const std::string& prop, - cmProperty::ScopeType scope) const; + const char *GetProperty(const std::string& prop, bool chain) const; bool GetPropertyAsBool(const std::string& prop) const; const char* GetFeature(const std::string& feature, diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index de2cd0582..ef09dbcf0 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -57,22 +57,13 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value, } const char *cmPropertyMap -::GetPropertyValue(const std::string& name, - cmProperty::ScopeType scope, - bool &chain) const +::GetPropertyValue(const std::string& name) const { - chain = false; assert(!name.empty()); cmPropertyMap::const_iterator it = this->find(name); if (it == this->end()) { - // should we chain up? - if (this->CMakeInstance) - { - chain = this->CMakeInstance->GetState()-> - IsPropertyChained(name,scope); - } return 0; } return it->second.GetValue(); diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 722732b56..a9062dbbd 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -14,8 +14,6 @@ #include "cmProperty.h" -class cmake; - class cmPropertyMap : public std::map { public: @@ -26,16 +24,7 @@ public: void AppendProperty(const std::string& name, const char* value, bool asString=false); - const char *GetPropertyValue(const std::string& name, - cmProperty::ScopeType scope, - bool &chain) const; - - void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; } - - cmPropertyMap() { this->CMakeInstance = 0;} - -private: - cmake *CMakeInstance; + const char *GetPropertyValue(const std::string& name) const; }; #endif diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index e9cfaccea..53dc5a8a6 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -85,8 +85,10 @@ bool cmSetTestsPropertiesCommand unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - test->SetProperty(propertyPairs[k], - propertyPairs[k+1].c_str()); + if (!propertyPairs[k].empty()) + { + test->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str()); + } } } else diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index df511d832..86f0a7a87 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -22,7 +22,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name): Location(mf, name) { this->CustomCommand = 0; - this->Properties.SetCMakeInstance(mf->GetCMakeInstance()); this->FindFullPathFailed = false; this->IsUiFile = (".ui" == cmSystemTools::GetFilenameLastExtension(this->Location.GetName())); @@ -361,13 +360,16 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const } } - bool chain = false; - const char *retVal = - this->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE, chain); - if (chain) + const char *retVal = this->Properties.GetPropertyValue(prop); + if (!retVal) { cmMakefile const* mf = this->Location.GetMakefile(); - return mf->GetProperty(prop,cmProperty::SOURCE_FILE); + const bool chain = mf->GetState()-> + IsPropertyChained(prop, cmProperty::SOURCE_FILE); + if (chain) + { + return mf->GetProperty(prop, chain); + } } return retVal; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 7bfeda19a..25b49663a 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -482,9 +482,7 @@ const char *cmState::GetGlobalProperty(const std::string& prop) return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; } #undef STRING_LIST_ELEMENT - bool dummy = false; - return this->GlobalProperties.GetPropertyValue(prop, cmProperty::GLOBAL, - dummy); + return this->GlobalProperties.GetPropertyValue(prop); } bool cmState::GetGlobalPropertyAsBool(const std::string& prop) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 873163246..d1399ef13 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -286,9 +286,6 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Set our makefile. this->Makefile = mf; - // set the cmake instance of the properties - this->Properties.SetCMakeInstance(mf->GetCMakeInstance()); - // Check whether this is a DLL platform. this->DLLPlatform = (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") || @@ -3167,12 +3164,15 @@ const char *cmTarget::GetProperty(const std::string& prop, } } - bool chain = false; - const char *retVal = - this->Properties.GetPropertyValue(prop, cmProperty::TARGET, chain); - if (chain) + const char *retVal = this->Properties.GetPropertyValue(prop); + if (!retVal) { - return this->Makefile->GetProperty(prop, cmProperty::TARGET); + const bool chain = this->GetMakefile()->GetState()-> + IsPropertyChained(prop, cmProperty::TARGET); + if (chain) + { + return this->Makefile->GetProperty(prop, chain); + } } return retVal; } diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index c60685967..6fcd0dc95 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -21,7 +21,6 @@ cmTest::cmTest(cmMakefile* mf) { this->Makefile = mf; this->OldStyle = true; - this->Properties.SetCMakeInstance(mf->GetCMakeInstance()); } //---------------------------------------------------------------------------- @@ -50,12 +49,15 @@ void cmTest::SetCommand(std::vector const& command) //---------------------------------------------------------------------------- const char *cmTest::GetProperty(const std::string& prop) const { - bool chain = false; - const char *retVal = - this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain); - if (chain) + const char *retVal = this->Properties.GetPropertyValue(prop); + if (!retVal) { - return this->Makefile->GetProperty(prop,cmProperty::TEST); + const bool chain = this->Makefile->GetState()-> + IsPropertyChained(prop, cmProperty::TEST); + if (chain) + { + return this->Makefile->GetProperty(prop, chain); + } } return retVal; } From 6f148e4a48f3f879998e67d9bb30de07f5cf5608 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:42:09 +0200 Subject: [PATCH 08/26] cmTarget: Use method abstraction for policy status. --- Source/cmTarget.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1399ef13..5e866efbf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5925,8 +5925,8 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(thisTarget->PolicyStatusCMP0022 != cmPolicies::OLD && - thisTarget->PolicyStatusCMP0022 != cmPolicies::WARN) + if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD && + thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; @@ -5952,7 +5952,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( } if(explicitLibraries && - thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN && + thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the @@ -5996,8 +5996,8 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( iface.Libraries, iface.HadHeadSensitiveCondition); } - else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN - || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD) + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back @@ -6008,7 +6008,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); - if(thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN && + if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN && !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the @@ -6100,8 +6100,8 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, } } } - else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN - || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD) + else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN + || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmTarget::LinkImplementationLibraries const* @@ -6421,7 +6421,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const if(lib != item) { cmake* cm = this->Makefile->GetCMakeInstance(); - switch(this->PolicyStatusCMP0004) + switch(this->GetPolicyStatusCMP0004()) { case cmPolicies::WARN: { From 647488570bfe7ce210bfd0675df0eb5147e36ab6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 2 May 2015 14:50:02 +0200 Subject: [PATCH 09/26] cmTarget: Replace PolicyStatus members with PolicyMap. sizeof(cmTarget) goes from 856 to 840 with GNU libstdc++ 5.1. --- Source/cmTarget.cxx | 17 ++--------------- Source/cmTarget.h | 11 ++--------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5e866efbf..daf52822a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -239,13 +239,6 @@ cmTargetInternals::~cmTargetInternals() //---------------------------------------------------------------------------- cmTarget::cmTarget() { -#define INITIALIZE_TARGET_POLICY_MEMBER(POLICY) \ - this->PolicyStatus ## POLICY = cmPolicies::WARN; - - CM_FOR_EACH_TARGET_POLICY(INITIALIZE_TARGET_POLICY_MEMBER) - -#undef INITIALIZE_TARGET_POLICY_MEMBER - this->Makefile = 0; #if defined(_WIN32) && !defined(__CYGWIN__) this->LinkLibrariesForVS6Analyzed = false; @@ -440,20 +433,14 @@ void cmTarget::SetMakefile(cmMakefile* mf) } // Record current policies for later use. -#define CAPTURE_TARGET_POLICY(POLICY) \ - this->PolicyStatus ## POLICY = \ - this->Makefile->GetPolicyStatus(cmPolicies::POLICY); - - CM_FOR_EACH_TARGET_POLICY(CAPTURE_TARGET_POLICY) - -#undef CAPTURE_TARGET_POLICY + this->Makefile->RecordPolicies(this->PolicyMap); if (this->TargetTypeValue == INTERFACE_LIBRARY) { // This policy is checked in a few conditions. The properties relevant // to the policy are always ignored for INTERFACE_LIBRARY targets, // so ensure that the conditions don't lead to nonsense. - this->PolicyStatusCMP0022 = cmPolicies::NEW; + this->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW); } if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0cbb57519..cade7ab9d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -144,7 +144,7 @@ public: #define DECLARE_TARGET_POLICY(POLICY) \ cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \ - { return this->PolicyStatus ## POLICY; } + { return this->PolicyMap.Get(cmPolicies::POLICY); } CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) @@ -828,14 +828,7 @@ private: // The cmMakefile instance that owns this target. This should // always be set. cmMakefile* Makefile; - - // Policy status recorded when target was created. -#define TARGET_POLICY_MEMBER(POLICY) \ - cmPolicies::PolicyStatus PolicyStatus ## POLICY; - - CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER) - -#undef TARGET_POLICY_MEMBER + cmPolicies::PolicyMap PolicyMap; // Internal representation details. friend class cmTargetInternals; From 41fef23b9b8bfa795e2d61e27b12f055ef9bbc39 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:44:47 +0200 Subject: [PATCH 10/26] cmTarget: Re-arrange data layout. Size with GNU libstdc++-5.1 goes from 840 bytes to 808 bytes. --- Source/cmTarget.h | 62 +++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index cade7ab9d..ddc8d3572 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -642,12 +642,6 @@ public: private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; - // The set of include directories that are marked as system include - // directories. - std::set SystemIncludeDirectories; - - std::vector > TLLCommands; - #if defined(_WIN32) && !defined(__CYGWIN__) /** * A list of direct dependencies. Use in conjunction with DependencyMap. @@ -742,40 +736,48 @@ private: void GetSourceFiles(std::vector &files, const std::string& config) const; private: - std::string Name; - std::vector PreBuildCommands; - std::vector PreLinkCommands; - std::vector PostBuildCommands; - TargetType TargetTypeValue; - LinkLibraryVectorType PrevLinkedLibraries; -#if defined(_WIN32) && !defined(__CYGWIN__) - LinkLibraryVectorType LinkLibrariesForVS6; - bool LinkLibrariesForVS6Analyzed; -#endif - std::vector LinkDirectories; + mutable cmPropertyMap Properties; + std::set SystemIncludeDirectories; std::set LinkDirectoriesEmmitted; - bool HaveInstallRule; + std::set Utilities; + mutable std::set LinkImplicitNullProperties; + std::map UtilityBacktraces; + mutable std::map DebugCompatiblePropertiesDone; + mutable std::map MaxLanguageStandards; + cmPolicies::PolicyMap PolicyMap; + std::string Name; std::string InstallPath; std::string RuntimeInstallPath; mutable std::string ExportMacro; - std::set Utilities; - std::map UtilityBacktraces; - bool RecordDependencies; - mutable cmPropertyMap Properties; + std::vector LinkDirectories; + std::vector PreBuildCommands; + std::vector PreLinkCommands; + std::vector PostBuildCommands; + std::vector > TLLCommands; + LinkLibraryVectorType PrevLinkedLibraries; LinkLibraryVectorType OriginalLinkLibraries; +#if defined(_WIN32) && !defined(__CYGWIN__) + LinkLibraryVectorType LinkLibrariesForVS6; +#endif + cmMakefile* Makefile; + cmTargetInternalPointer Internal; + TargetType TargetTypeValue; + bool HaveInstallRule; + bool RecordDependencies; bool DLLPlatform; bool IsAndroid; bool IsApple; bool IsImportedTarget; + bool BuildInterfaceIncludesAppended; mutable bool DebugIncludesDone; - mutable std::map DebugCompatiblePropertiesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool DebugCompileFeaturesDone; - mutable std::set LinkImplicitNullProperties; - mutable std::map MaxLanguageStandards; - bool BuildInterfaceIncludesAppended; + mutable bool LinkImplementationLanguageIsContextDependent; +#if defined(_WIN32) && !defined(__CYGWIN__) + bool LinkLibrariesForVS6Analyzed; +#endif // Cache target output paths for each configuration. struct OutputInfo; @@ -825,16 +827,10 @@ private: void ProcessSourceExpression(std::string const& expr); - // The cmMakefile instance that owns this target. This should - // always be set. - cmMakefile* Makefile; - cmPolicies::PolicyMap PolicyMap; - // Internal representation details. friend class cmTargetInternals; friend class cmGeneratorTarget; friend class cmTargetTraceDependencies; - cmTargetInternalPointer Internal; void ComputeVersionedName(std::string& vName, std::string const& prefix, @@ -842,8 +838,6 @@ private: std::string const& suffix, std::string const& name, const char* version) const; - - mutable bool LinkImplementationLanguageIsContextDependent; }; #ifdef CMAKE_BUILD_WITH_CMAKE From c26696eb404888cec525bf3ee2e538ae8532156f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:45:50 +0200 Subject: [PATCH 11/26] cmSourceFile: Re-arrange data. Size goes from 304 to 296 bytes. --- Source/cmSourceFile.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index f8982600f..1433b54f0 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -107,8 +107,9 @@ private: std::string Extension; std::string Language; std::string FullPath; - bool FindFullPathFailed; std::string ObjectLibrary; + std::vector Depends; + bool FindFullPathFailed; bool IsUiFile; bool FindFullPath(std::string* error); @@ -116,7 +117,6 @@ private: void CheckExtension(); void CheckLanguage(std::string const& ext); - std::vector Depends; static const std::string propLANGUAGE; }; From e04217010345fd350d3ddd7897e47eb47eaec1d8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:45:56 +0200 Subject: [PATCH 12/26] cmMakefile: Re-arrange data layout. 2168 to 2152 bytes with GNU libstdc++-5.1. --- Source/cmMakefile.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 751863105..32223b42d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -372,8 +372,6 @@ public: }; friend class PolicyPushPop; - mutable std::set CMP0054ReportedIds; - /** * Determine if the given context, name pair has already been reported * in context of CMP0054. @@ -848,6 +846,8 @@ protected: // Check for a an unused variable void LogUnused(const char* reason, const std::string& name) const; + mutable std::set CMP0054ReportedIds; + std::string ProjectName; // project name // libraries, classes, and executables @@ -949,10 +949,6 @@ private: cmPropertyMap Properties; - // Unused variable flags - bool WarnUnused; - bool CheckSystemVars; - // stack of list files being read std::vector ListFileStack; @@ -994,8 +990,6 @@ private: cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id) const; - bool CheckCMP0000; - // Enforce rules about CMakeLists.txt files. void EnforceDirectoryLevelRules() const; @@ -1021,7 +1015,6 @@ private: long line, bool removeEmpty, bool replaceAt) const; - bool Configured; /** * Old version of GetSourceFileWithOutput(const std::string&) kept for * backward-compatibility. It implements a linear search and support @@ -1067,6 +1060,11 @@ private: void CheckForUnusedVariables() const; + // Unused variable flags + bool WarnUnused; + bool CheckSystemVars; + bool CheckCMP0000; + bool Configured; mutable bool SuppressWatches; }; From 3e087a408b4a5bad1eb079c61c982ce2dab0973a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:46:10 +0200 Subject: [PATCH 13/26] cmLocalUnixMakefileGenerator: Re-arrange data layout. Size goes from 536 to 528 bytes. --- Source/cmLocalUnixMakefileGenerator3.h | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index f2a138993..dcb301629 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -254,26 +254,10 @@ private: ImplicitDependTargetMap ImplicitDepends; - //========================================================================== - // Configuration settings. - int MakefileVariableSize; std::string ConfigurationName; - bool MakeCommandEscapeTargetTwice; - bool BorlandMakeCurlyHack; - //========================================================================== std::string HomeRelativeOutputPath; - /* Copy the setting of CMAKE_COLOR_MAKEFILE from the makefile at the - beginning of generation to avoid many duplicate lookups. */ - bool ColorMakefile; - - /* Copy the setting of CMAKE_SKIP_PREPROCESSED_SOURCE_RULES and - CMAKE_SKIP_ASSEMBLY_SOURCE_RULES at the beginning of generation to - avoid many duplicate lookups. */ - bool SkipPreprocessedSourceRules; - bool SkipAssemblySourceRules; - struct LocalObjectEntry { cmTarget* Target; @@ -302,6 +286,13 @@ private: /* does the work for each target */ std::map MakeVariableMap; std::map ShortMakeVariableMap; + + int MakefileVariableSize; + bool MakeCommandEscapeTargetTwice; + bool BorlandMakeCurlyHack; + bool ColorMakefile; + bool SkipPreprocessedSourceRules; + bool SkipAssemblySourceRules; }; #endif From 4cd13e80f00d4441112f400ff774d91a7fecfff8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 6 Jun 2015 09:59:24 +0200 Subject: [PATCH 14/26] cmComputeLinkInformation: Re-arrange data layout. Size goes from 1944 to 1920 bytes. --- Source/cmComputeLinkInformation.h | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 88471413c..ccf520b21 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -82,7 +82,6 @@ private: // Configuration information. std::string Config; std::string LinkLanguage; - bool LinkDependsNoShared; // Modes for dealing with dependent shared libraries. enum SharedDepMode @@ -93,8 +92,6 @@ private: SharedDepModeLink // List file on link line }; - // System info. - bool UseImportLibrary; const char* LoaderFlag; std::string LibLinkFlag; std::string LibLinkFileFlag; @@ -102,22 +99,18 @@ private: std::string RuntimeFlag; std::string RuntimeSep; std::string RuntimeAlways; - bool RuntimeUseChrpath; - bool NoSONameUsesPath; - bool LinkWithRuntimePath; std::string RPathLinkFlag; SharedDepMode SharedDependencyMode; + enum LinkType { LinkUnknown, LinkStatic, LinkShared }; + void SetCurrentLinkType(LinkType lt); + // Link type adjustment. void ComputeLinkTypeInfo(); - enum LinkType { LinkUnknown, LinkStatic, LinkShared }; LinkType StartLinkType; LinkType CurrentLinkType; std::string StaticLinkTypeFlag; std::string SharedLinkTypeFlag; - bool LinkTypeEnabled; - void SetCurrentLinkType(LinkType lt); - bool ArchivesMayBeShared; // Link item parsing. void ComputeItemParserInfo(); @@ -129,7 +122,6 @@ private: cmsys::RegularExpression ExtractSharedLibraryName; cmsys::RegularExpression ExtractAnyLibraryName; std::string SharedRegexString; - bool OpenBSD; void AddLinkPrefix(const char* p); void AddLinkExtension(const char* e, LinkType type); std::string CreateExtensionRegex(std::vector const& exts, @@ -173,20 +165,27 @@ private: std::set OldLinkDirMask; std::vector OldLinkDirItems; std::vector OldUserFlagItems; - bool OldLinkDirMode; - - // CMP0060 warnings. - bool CMP0060Warn; std::set CMP0060WarnItems; - + // Dependent library path computation. + cmOrderDirectories* OrderDependentRPath; // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; + + bool OldLinkDirMode; + bool OpenBSD; + bool LinkDependsNoShared; + bool UseImportLibrary; + bool RuntimeUseChrpath; + bool NoSONameUsesPath; + bool LinkWithRuntimePath; + bool LinkTypeEnabled; + bool ArchivesMayBeShared; + bool CMP0060Warn; + void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget const* target); void AddLibraryRuntimeInfo(std::string const& fullPath); - // Dependent library path computation. - cmOrderDirectories* OrderDependentRPath; }; #endif From db24e41b9d939fb8ad9106f7a8511670505a8ad0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 09:40:57 +0200 Subject: [PATCH 15/26] cmCommandArgumentParserHelper: Re-arrange data. Size goes from 232 to 216 bytes. --- Source/cmCommandArgumentParserHelper.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index d375ae624..387afc639 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -80,8 +80,6 @@ private: std::string::size_type InputBufferPos; std::string InputBuffer; std::vector OutputBuffer; - int CurrentLine; - int Verbose; void Print(const char* place, const char* str); void SafePrintMissing(const char* str, int line, int cnt); @@ -94,12 +92,14 @@ private: std::vector Variables; const cmMakefile* Makefile; std::string Result; + std::string ErrorString; const char* FileName; + long FileLine; + int CurrentLine; + int Verbose; bool WarnUninitialized; bool CheckSystemVars; - long FileLine; bool EscapeQuotes; - std::string ErrorString; bool NoEscapeMode; bool ReplaceAtSyntax; bool RemoveEmpty; From d9df7fa70c854207bb36b45ca0fdca6665bd4bd8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 09:43:11 +0200 Subject: [PATCH 16/26] cmComputeComponentGraph: Re-arrange data layout. Size goes from 224 to 216 bytes. --- Source/cmComputeComponentGraph.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index a2ce946c1..4dbac4a2e 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -67,17 +67,17 @@ private: int Root; int VisitIndex; }; - int TarjanWalkId; std::vector TarjanVisited; std::vector TarjanComponents; std::vector TarjanEntries; + std::vector Components; std::stack TarjanStack; + int TarjanWalkId; int TarjanIndex; void Tarjan(); void TarjanVisit(int i); // Connected components. - std::vector Components; }; #endif From 7f3e16239fd120eded5e23ee8a836d9e73119244 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 09:47:37 +0200 Subject: [PATCH 17/26] cmGlobalGenerator: Re-arrange data layout. Size goes from 1488 to 1480 bytes. --- Source/cmGlobalGenerator.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3b368c694..f02df90c1 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,10 +398,6 @@ protected: std::vector depends, const char* workingDir, bool uses_terminal); - bool NeedSymbolicMark; - bool UseLinkScript; - bool ForceUnixPaths; - bool ToolSupportsColor; std::string FindMakeProgramFile; std::string ConfiguredFilesPath; cmake *CMakeInstance; @@ -414,7 +410,6 @@ protected: // Set of named installation components requested by the project. std::set InstallComponents; - bool InstallTargetEnabled; // Sets of named target exports cmExportSetMap ExportSets; std::map BuildExportSets; @@ -448,7 +443,6 @@ private: cmState::Snapshot snapshot); cmMakefile* TryCompileOuterMakefile; - float FirstTimeProgress; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator std::map IgnoreExtensions; @@ -521,6 +515,14 @@ private: // Pool of file locks cmFileLockPool FileLockPool; #endif + +protected: + float FirstTimeProgress; + bool NeedSymbolicMark; + bool UseLinkScript; + bool ForceUnixPaths; + bool ToolSupportsColor; + bool InstallTargetEnabled; }; #endif From 92b8b1fc3d885091cfef210216b682a389eaf2fb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 09:54:55 +0200 Subject: [PATCH 18/26] cmGraphVizWriter: Re-arrange data layout. Size goes from 272 to 264 bytes. --- Source/cmGraphVizWriter.cxx | 2 +- Source/cmGraphVizWriter.h | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7f4c4c949..fa29b4f71 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -48,6 +48,7 @@ cmGraphVizWriter::cmGraphVizWriter(const std::vector& ,GraphName("GG") ,GraphHeader("node [\n fontsize = \"12\"\n];") ,GraphNodePrefix("node") +,LocalGenerators(localGenerators) ,GenerateForExecutables(true) ,GenerateForStaticLibs(true) ,GenerateForSharedLibs(true) @@ -55,7 +56,6 @@ cmGraphVizWriter::cmGraphVizWriter(const std::vector& ,GenerateForExternals(true) ,GeneratePerTarget(true) ,GenerateDependers(true) -,LocalGenerators(localGenerators) ,HaveTargetsAndLibs(false) { } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index a7acd0e54..64de68436 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -69,14 +69,6 @@ protected: std::string GraphHeader; std::string GraphNodePrefix; - bool GenerateForExecutables; - bool GenerateForStaticLibs; - bool GenerateForSharedLibs; - bool GenerateForModuleLibs; - bool GenerateForExternals; - bool GeneratePerTarget; - bool GenerateDependers; - std::vector TargetsToIgnoreRegex; const std::vector& LocalGenerators; @@ -85,6 +77,13 @@ protected: // maps from the actual target names to node names in dot: std::map TargetNamesNodes; + bool GenerateForExecutables; + bool GenerateForStaticLibs; + bool GenerateForSharedLibs; + bool GenerateForModuleLibs; + bool GenerateForExternals; + bool GeneratePerTarget; + bool GenerateDependers; bool HaveTargetsAndLibs; }; From 125c48660ce5f58e8fa9371cfb9c192f42b19401 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 09:57:33 +0200 Subject: [PATCH 19/26] cmInstallFilesGenerator: Re-arrange data layout. Size goes from 296 to 288 bytes. --- Source/cmInstallFilesGenerator.cxx | 6 ++++-- Source/cmInstallFilesGenerator.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 28c27c295..ff2c6e5b2 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -28,9 +28,11 @@ cmInstallFilesGenerator bool optional): cmInstallGenerator(dest, configurations, component, message), Makefile(mf), - Files(files), Programs(programs), + Files(files), FilePermissions(file_permissions), - Rename(rename), Optional(optional) + Rename(rename), + Programs(programs), + Optional(optional) { // We need per-config actions if any files have generator expressions. for(std::vector::const_iterator i = files.begin(); diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 0dbd71271..bf482d6f6 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -43,9 +43,9 @@ protected: cmMakefile* Makefile; std::vector Files; - bool Programs; std::string FilePermissions; std::string Rename; + bool Programs; bool Optional; }; From dd0417c7becb9d00bf60827d299b3d520bb138c5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 10:01:00 +0200 Subject: [PATCH 20/26] cmInstallTargetGenerator: Re-arrange data layout. Remove unused cmGeneratorTarget member. Size goes from 238 to 232 bytes. --- Source/cmInstallTargetGenerator.cxx | 4 +++- Source/cmInstallTargetGenerator.h | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 082a78c18..511578805 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -29,7 +29,9 @@ cmInstallTargetGenerator MessageLevel message, bool optional): cmInstallGenerator(dest, configurations, component, message), Target(&t), - ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) + FilePermissions(file_permissions), + ImportLibrary(implib), + Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 075c8a4bf..db69220a1 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -14,7 +14,6 @@ #include "cmInstallGenerator.h" #include "cmTarget.h" -#include "cmGeneratorTarget.h" /** \class cmInstallTargetGenerator * \brief Generate target installation rules. @@ -100,11 +99,10 @@ protected: const std::string& toDestDirPath); cmTarget* Target; - bool ImportLibrary; std::string FilePermissions; - bool Optional; NamelinkModeType NamelinkMode; - cmGeneratorTarget* GeneratorTarget; + bool ImportLibrary; + bool Optional; }; #endif From b1ff32afc67799d08130d457347290a41e426ed0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 10:06:19 +0200 Subject: [PATCH 21/26] cmOrderDirectories: Re-arrange data layout. Size goes from 680 to 672 bytes. --- Source/cmOrderDirectories.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 07c85dd07..cb5a51f41 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -44,8 +44,6 @@ private: cmTarget const* Target; std::string Purpose; - bool Computed; - std::vector OrderedDirectories; std::vector ConstraintEntries; @@ -68,8 +66,9 @@ private: void OrderDirectories(); void VisitDirectory(unsigned int i); void DiagnoseCycle(); - bool CycleDiagnosed; int WalkId; + bool CycleDiagnosed; + bool Computed; // Adjacency-list representation of runtime path ordering graph. // This maps from directory to those that must come *before* it. From 40844a1487ea576987ecec148f77bbeebea9433d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 10:09:47 +0200 Subject: [PATCH 22/26] cmProcessTools: Re-arrange data layout. Size goes from 72 to 64 bytes. --- Source/cmProcessTools.cxx | 2 +- Source/cmProcessTools.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index d2f7bf320..15d9ed065 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -44,7 +44,7 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, //---------------------------------------------------------------------------- cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR): - Separator(sep), IgnoreCR(ignoreCR), Log(0), Prefix(0), LineEnd('\0') + Log(0), Prefix(0), Separator(sep), LineEnd('\0'), IgnoreCR(ignoreCR) { } diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index 439726dd0..23833cabd 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -51,12 +51,12 @@ public: /** Configure logging of lines as they are extracted. */ void SetLog(std::ostream* log, const char* prefix); protected: - char Separator; - bool IgnoreCR; std::ostream* Log; const char* Prefix; - char LineEnd; std::string Line; + char Separator; + char LineEnd; + bool IgnoreCR; virtual bool ProcessChunk(const char* data, int length); /** Implement in a subclass to process one line of input. It From b661d6c631884e48b27353b0ee9f4f0eb6f5eea7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 10:11:42 +0200 Subject: [PATCH 23/26] cmQtAutoGenerators: Re-arrange data layout. Size goes from 920 to 912 bytes. --- Source/cmQtAutoGenerators.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index f74e3c5b6..4c0fcbcb4 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -105,7 +105,6 @@ private: std::string SkipMoc; std::string SkipUic; std::string Headers; - bool IncludeProjectDirsBefore; std::string Srcdir; std::string Builddir; std::string MocExecutable; @@ -131,6 +130,7 @@ private: std::map RccOptions; std::map > RccInputs; + bool IncludeProjectDirsBefore; bool Verbose; bool ColorOutput; bool RunMocFailed; @@ -138,7 +138,6 @@ private: bool RunRccFailed; bool GenerateAll; bool RelaxedMode; - }; #endif From 54cb76f299ebcdd07e59d3d0c61f1aa0ffe03a33 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 10:41:16 +0200 Subject: [PATCH 24/26] cmComputeLinkDepends: Re-arrange data layout. Size goes from 648 to 632 bytes. --- Source/cmComputeLinkDepends.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 09b9d7053..51a08c5c9 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -61,14 +61,7 @@ private: cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; - bool DebugMode; - - // Configuration information. - bool HasConfig; std::string Config; - cmTarget::LinkLibraryType LinkType; - - // Output information. EntryVector FinalLinkEntries; typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType; @@ -131,7 +124,7 @@ private: void OrderLinkEntires(); std::vector ComponentVisited; std::vector ComponentOrder; - int ComponentOrderId; + struct PendingComponent { // The real component id. Needed because the map is indexed by @@ -158,11 +151,14 @@ private: // Record of the original link line. std::vector OriginalEntries; - - // Compatibility help. - bool OldLinkDirMode; - void CheckWrongConfigItem(cmLinkItem const& item); std::set OldWrongConfigItems; + void CheckWrongConfigItem(cmLinkItem const& item); + + int ComponentOrderId; + cmTarget::LinkLibraryType LinkType; + bool HasConfig; + bool DebugMode; + bool OldLinkDirMode; }; #endif From 34e1d6db722b34bb6b4f7b8a7ea53a0bb61c5f58 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 10:44:59 +0200 Subject: [PATCH 25/26] cmCustomCommand: Re-arrange data layout. Size goes from 240 to 224 bytes. --- Source/cmCustomCommand.cxx | 12 +++++------- Source/cmCustomCommand.h | 10 +++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 4032b08e2..7418413c6 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -31,12 +31,12 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): Byproducts(r.Byproducts), Depends(r.Depends), CommandLines(r.CommandLines), - HaveComment(r.HaveComment), + Backtrace(r.Backtrace), Comment(r.Comment), WorkingDirectory(r.WorkingDirectory), + HaveComment(r.HaveComment), EscapeAllowMakeVars(r.EscapeAllowMakeVars), EscapeOldStyle(r.EscapeOldStyle), - Backtrace(r.Backtrace), UsesTerminal(r.UsesTerminal) { } @@ -77,15 +77,13 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf, Byproducts(byproducts), Depends(depends), CommandLines(commandLines), - HaveComment(comment?true:false), + Backtrace(), Comment(comment?comment:""), WorkingDirectory(workingDirectory?workingDirectory:""), + HaveComment(comment?true:false), EscapeAllowMakeVars(false), - EscapeOldStyle(true), - Backtrace() + EscapeOldStyle(true) { - this->EscapeOldStyle = true; - this->EscapeAllowMakeVars = false; if(mf) { this->Backtrace = mf->GetBacktrace(); diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 0bfaef23b..cc5501fca 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -93,13 +93,13 @@ private: std::vector Byproducts; std::vector Depends; cmCustomCommandLines CommandLines; - bool HaveComment; - std::string Comment; - std::string WorkingDirectory; - bool EscapeAllowMakeVars; - bool EscapeOldStyle; cmListFileBacktrace Backtrace; ImplicitDependsList ImplicitDepends; + std::string Comment; + std::string WorkingDirectory; + bool HaveComment; + bool EscapeAllowMakeVars; + bool EscapeOldStyle; bool UsesTerminal; }; From 8174e5cd9424a7f45174562f21eb80eb06a3f3d0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Jun 2015 11:09:32 +0200 Subject: [PATCH 26/26] cmCustomCommand: Remove special member functions. The compiler generated ones are fine. The existing implementations here are incorrect as they omit some members. --- Source/cmCustomCommand.cxx | 45 -------------------------------------- Source/cmCustomCommand.h | 4 ---- 2 files changed, 49 deletions(-) diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 7418413c6..7c37e3b96 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -25,46 +25,6 @@ cmCustomCommand::cmCustomCommand() this->UsesTerminal = false; } -//---------------------------------------------------------------------------- -cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): - Outputs(r.Outputs), - Byproducts(r.Byproducts), - Depends(r.Depends), - CommandLines(r.CommandLines), - Backtrace(r.Backtrace), - Comment(r.Comment), - WorkingDirectory(r.WorkingDirectory), - HaveComment(r.HaveComment), - EscapeAllowMakeVars(r.EscapeAllowMakeVars), - EscapeOldStyle(r.EscapeOldStyle), - UsesTerminal(r.UsesTerminal) -{ -} - -//---------------------------------------------------------------------------- -cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r) -{ - if(this == &r) - { - return *this; - } - - this->Outputs = r.Outputs; - this->Byproducts= r.Byproducts; - this->Depends = r.Depends; - this->CommandLines = r.CommandLines; - this->HaveComment = r.HaveComment; - this->Comment = r.Comment; - this->WorkingDirectory = r.WorkingDirectory; - this->EscapeAllowMakeVars = r.EscapeAllowMakeVars; - this->EscapeOldStyle = r.EscapeOldStyle; - this->ImplicitDepends = r.ImplicitDepends; - this->Backtrace = r.Backtrace; - this->UsesTerminal = r.UsesTerminal; - - return *this; -} - //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand(cmMakefile const* mf, const std::vector& outputs, @@ -90,11 +50,6 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf, } } -//---------------------------------------------------------------------------- -cmCustomCommand::~cmCustomCommand() -{ -} - //---------------------------------------------------------------------------- const std::vector& cmCustomCommand::GetOutputs() const { diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index cc5501fca..f9b38c3c4 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -26,8 +26,6 @@ class cmCustomCommand public: /** Default and copy constructors for STL containers. */ cmCustomCommand(); - cmCustomCommand(const cmCustomCommand& r); - cmCustomCommand& operator=(cmCustomCommand const& r); /** Main constructor specifies all information for the command. */ cmCustomCommand(cmMakefile const* mf, @@ -38,8 +36,6 @@ public: const char* comment, const char* workingDirectory); - ~cmCustomCommand(); - /** Get the output file produced by the command. */ const std::vector& GetOutputs() const;