From 9ad804ac7be18efb92040434808f89174586b13d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 23:06:05 +0100 Subject: [PATCH] cmGeneratorTarget: Constify cmSourceFile* in containers. Some of them will be used with other APIs which require value_type to be cmSourceFile const*. --- Source/cmGeneratorTarget.cxx | 27 +++++++++++------- Source/cmGeneratorTarget.h | 18 ++++++------ Source/cmGlobalNinjaGenerator.cxx | 6 ++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 ++-- Source/cmGlobalVisualStudioGenerator.cxx | 10 +++---- Source/cmGlobalXCodeGenerator.cxx | 6 ++-- Source/cmLocalUnixMakefileGenerator3.cxx | 6 ++-- Source/cmMakefileTargetGenerator.cxx | 16 +++++------ Source/cmNinjaTargetGenerator.cxx | 20 +++++++------- Source/cmOSXBundleGenerator.cxx | 7 +++-- Source/cmOSXBundleGenerator.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 32 +++++++++++----------- Source/cmVisualStudio10TargetGenerator.h | 3 +- 13 files changed, 84 insertions(+), 75 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bde60b834..8efd7bb52 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -97,7 +97,7 @@ struct DoAccept template<> struct DoAccept { - static void Do(std::vector& files, cmSourceFile* f) + static void Do(std::vector& files, cmSourceFile* f) { files.push_back(f); } @@ -120,7 +120,7 @@ struct DoAccept }; //---------------------------------------------------------------------------- -template > +template > struct TagVisitor { DataType& Data; @@ -306,7 +306,8 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetObjectSources(std::vector &data) const +cmGeneratorTarget +::GetObjectSources(std::vector &data) const { IMPLEMENT_VISIT(ObjectSources); if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY) @@ -342,34 +343,39 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetIDLSources(std::vector& data) const +void cmGeneratorTarget +::GetIDLSources(std::vector& data) const { IMPLEMENT_VISIT(IDLSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetHeaderSources(std::vector& data) const +cmGeneratorTarget +::GetHeaderSources(std::vector& data) const { IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetExtraSources(std::vector& data) const +void cmGeneratorTarget +::GetExtraSources(std::vector& data) const { IMPLEMENT_VISIT(ExtraSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetCustomCommands(std::vector& data) const +cmGeneratorTarget +::GetCustomCommands(std::vector& data) const { IMPLEMENT_VISIT(CustomCommands); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetExternalObjects(std::vector& data) const +cmGeneratorTarget +::GetExternalObjects(std::vector& data) const { IMPLEMENT_VISIT(ExternalObjects); } @@ -384,7 +390,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetResxSources(std::vector& srcs) const +void cmGeneratorTarget +::GetResxSources(std::vector& srcs) const { ResxData data; IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) @@ -570,7 +577,7 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const cmTarget* objLib = *ti; cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); - for(std::vector::const_iterator + for(std::vector::const_iterator si = ogt->ObjectSources.begin(); si != ogt->ObjectSources.end(); ++si) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1c4276cb1..139e736c8 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -32,19 +32,19 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector& files) const; - void GetObjectSources(std::vector &) const; + void GetObjectSources(std::vector &) const; const std::string& GetObjectName(cmSourceFile const* file); void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile const* sf); - void GetResxSources(std::vector&) const; - void GetIDLSources(std::vector&) const; - void GetExternalObjects(std::vector&) const; - void GetHeaderSources(std::vector&) const; - void GetExtraSources(std::vector&) const; - void GetCustomCommands(std::vector&) const; + void GetResxSources(std::vector&) const; + void GetIDLSources(std::vector&) const; + void GetExternalObjects(std::vector&) const; + void GetHeaderSources(std::vector&) const; + void GetExtraSources(std::vector&) const; + void GetCustomCommands(std::vector&) const; void GetExpectedResxHeaders(std::set&) const; cmTarget* Target; @@ -117,7 +117,7 @@ public: struct ResxData { mutable std::set ExpectedResxHeaders; - mutable std::vector ResxSources; + mutable std::vector ResxSources; }; private: friend class cmTargetTraceDependencies; @@ -127,7 +127,7 @@ private: std::map Objects; std::set ExplicitObjectName; - mutable std::vector ObjectSources; + mutable std::vector ObjectSources; std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 686414d3f..e9c31e9dd 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -634,14 +634,14 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. - for(std::vector::iterator + for(std::vector::iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f9ec0a9a6..6ce867806 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -108,14 +108,14 @@ void cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const { - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. - for(std::vector::iterator + for(std::vector::iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index f3cba5a68..bd57d0c1d 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -129,13 +129,13 @@ cmGlobalVisualStudioGenerator // Count the number of object files with each name. Note that // windows file names are not case sensitive. std::map counts; - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectNameLower = cmSystemTools::LowerCase( cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); objectNameLower += ".obj"; @@ -144,11 +144,11 @@ cmGlobalVisualStudioGenerator // For all source files producing duplicate names we need unique // object name computation. - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); objectName += ".obj"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6c12040c9..4904d511c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3944,13 +3944,13 @@ cmGlobalXCodeGenerator // to avoid exact duplicate file names. Note that Mac file names are not // typically case sensitive, hence the LowerCase. std::map counts; - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); objectName += ".o"; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a838ce3b5..79240e1c4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -185,7 +185,7 @@ GetLocalObjectFiles(std::map &localObjectFiles) { continue; } - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); // Compute full path to object file directory for this target. std::string dir_max; @@ -194,11 +194,11 @@ GetLocalObjectFiles(std::map &localObjectFiles) dir_max += this->GetTargetDirectory(*gt->Target); dir_max += "/"; // Compute the name of each object file. - for(std::vector::iterator + for(std::vector::iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; bool hasSourceExtension = true; std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 32e1c1ae1..6759d050e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -153,9 +153,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -176,27 +176,27 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3738ca75c..4319f3cb3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -480,36 +480,36 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); @@ -570,9 +570,9 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 835f892ba..6f16913d6 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -190,13 +190,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, //---------------------------------------------------------------------------- void cmOSXBundleGenerator:: -GenerateMacOSXContentStatements(std::vector const& sources, - MacOSXContentGeneratorType* generator) +GenerateMacOSXContentStatements( + std::vector const& sources, + MacOSXContentGeneratorType* generator) { if (this->MustSkip()) return; - for(std::vector::const_iterator + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { cmGeneratorTarget::SourceFileFlags tsFlags = diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 5acdd9f27..f945c15a8 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -49,7 +49,7 @@ public: }; void GenerateMacOSXContentStatements( - std::vector const& sources, + std::vector const& sources, MacOSXContentGeneratorType* generator); std::string InitMacOSXContentDirectory(const char* pkgloc); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cc1fdbce6..b8631ca18 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -377,12 +377,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector resxObjs; + std::vector resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("\n", 1); - for(std::vector::const_iterator oi = resxObjs.begin(); + for(std::vector::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -551,9 +551,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -746,12 +746,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector resxObjs; + std::vector resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("\n", 1); - for(std::vector::const_iterator oi = resxObjs.begin(); + for(std::vector::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -902,7 +902,7 @@ WriteGroupSources(const char* name, for(ToolSources::const_iterator s = sources.begin(); s != sources.end(); ++s) { - cmSourceFile* sf = s->SourceFile; + cmSourceFile const* sf = s->SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); @@ -985,9 +985,9 @@ void cmVisualStudio10TargetGenerator::WriteSource( } void cmVisualStudio10TargetGenerator::WriteSources( - const char* tool, std::vector const& sources) + const char* tool, std::vector const& sources) { - for(std::vector::const_iterator + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { this->WriteSource(tool, *si); @@ -1002,16 +1002,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("\n", 1); - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->WriteSources("ClInclude", headerSources); - std::vector idlSources; + std::vector idlSources; this->GeneratorTarget->GetIDLSources(idlSources); this->WriteSources("Midl", idlSources); - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { @@ -1050,7 +1050,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { @@ -1062,7 +1062,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { @@ -1072,7 +1072,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->WriteSources("None", extraSources); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 8faeb8ecb..d72c6fd6a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -57,7 +57,8 @@ private: void WriteProjectConfigurationValues(); void WriteSource(const char* tool, cmSourceFile const* sf, const char* end = 0); - void WriteSources(const char* tool, std::vector const&); + void WriteSources(const char* tool, + std::vector const&); void WriteAllSources(); void WriteDotNetReferences(); void WriteEmbeddedResourceGroup();