[cmake-commits] king committed cmLocalVisualStudio6Generator.cxx 1.140 1.141 cmLocalVisualStudio6Generator.h 1.22 1.23 cmLocalVisualStudio7Generator.cxx 1.215 1.216 cmLocalVisualStudio7Generator.h 1.48 1.49 cmTarget.cxx 1.184 1.185 cmTarget.h 1.100 1.101

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jan 29 17:30:37 EST 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv6690/Source

Modified Files:
	cmLocalVisualStudio6Generator.cxx 
	cmLocalVisualStudio6Generator.h 
	cmLocalVisualStudio7Generator.cxx 
	cmLocalVisualStudio7Generator.h cmTarget.cxx cmTarget.h 
Log Message:
BUG: cmTarget instances should not be copied.  Removed pass-by-value arguments from cmLocalVisualStudio7Generator::WriteGroup and cmLocalVisualStudio6Generator::WriteGroup.  Updated cmTarget to make this easier to find.


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- cmLocalVisualStudio7Generator.cxx	29 Jan 2008 20:07:33 -0000	1.215
+++ cmLocalVisualStudio7Generator.cxx	29 Jan 2008 22:30:34 -0000	1.216
@@ -1179,7 +1179,7 @@
 }
 
 void cmLocalVisualStudio7Generator
-::WriteGroup(const cmSourceGroup *sg, cmTarget target, 
+::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
              std::ostream &fout, const char *libName, 
              std::vector<std::string> *configs)
 {

Index: cmLocalVisualStudio6Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmLocalVisualStudio6Generator.h	14 Jan 2008 14:20:57 -0000	1.22
+++ cmLocalVisualStudio6Generator.h	29 Jan 2008 22:30:34 -0000	1.23
@@ -91,7 +91,7 @@
   void AddUtilityCommandHack(cmTarget& target, int count,
                              std::vector<std::string>& depends,
                              const cmCustomCommand& origCommand);
-  void WriteGroup(const cmSourceGroup *sg, cmTarget target,
+  void WriteGroup(const cmSourceGroup *sg, cmTarget& target,
                   std::ostream &fout, const char *libName);
   std::string CreateTargetRules(cmTarget &target, 
                                 const char* configName, 

Index: cmLocalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cmLocalVisualStudio7Generator.h	22 Jan 2008 14:13:03 -0000	1.48
+++ cmLocalVisualStudio7Generator.h	29 Jan 2008 22:30:34 -0000	1.49
@@ -114,7 +114,7 @@
   void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
 
   void WriteGroup(const cmSourceGroup *sg, 
-                  cmTarget target, std::ostream &fout, 
+                  cmTarget& target, std::ostream &fout,
                   const char *libName, std::vector<std::string> *configs);
   virtual std::string GetTargetDirectory(cmTarget const&) const;
 

Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- cmLocalVisualStudio6Generator.cxx	29 Jan 2008 20:07:33 -0000	1.140
+++ cmLocalVisualStudio6Generator.cxx	29 Jan 2008 22:30:34 -0000	1.141
@@ -351,7 +351,7 @@
 }
 
 void cmLocalVisualStudio6Generator
-::WriteGroup(const cmSourceGroup *sg, cmTarget target, 
+::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
              std::ostream &fout, const char *libName)
 {
   const std::vector<const cmSourceFile *> &sourceFiles = 

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- cmTarget.h	29 Jan 2008 20:07:33 -0000	1.100
+++ cmTarget.h	29 Jan 2008 22:30:34 -0000	1.101
@@ -26,6 +26,15 @@
 class cmGlobalGenerator;
 class cmComputeLinkInformation;
 
+struct cmTargetLinkInformationMap:
+  public std::map<cmStdString, cmComputeLinkInformation*>
+{
+  typedef std::map<cmStdString, cmComputeLinkInformation*> derived;
+  cmTargetLinkInformationMap() {}
+  cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r);
+  ~cmTargetLinkInformationMap();
+};
+
 /** \class cmTarget
  * \brief Represent a library or executable target loaded from a makefile.
  *
@@ -36,7 +45,6 @@
 {
 public:
   cmTarget();
-  ~cmTarget();
   enum TargetType { EXECUTABLE, STATIC_LIBRARY,
                     SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET,
                     INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY};
@@ -466,7 +474,7 @@
   ImportInfo const* GetImportInfo(const char* config);
   void ComputeImportInfo(std::string const& desired_config, ImportInfo& info);
 
-  std::map<cmStdString, cmComputeLinkInformation*> LinkInformation;
+  cmTargetLinkInformationMap LinkInformation;
 
   // The cmMakefile instance that owns this target.  This should
   // always be set.

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- cmTarget.cxx	29 Jan 2008 20:07:33 -0000	1.184
+++ cmTarget.cxx	29 Jan 2008 22:30:34 -0000	1.185
@@ -25,6 +25,7 @@
 #include <set>
 #include <queue>
 #include <stdlib.h> // required for atof
+#include <assert.h>
 const char* cmTarget::TargetTypeNames[] = {
   "EXECUTABLE", "STATIC_LIBRARY",
   "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET",
@@ -42,17 +43,6 @@
 }
 
 //----------------------------------------------------------------------------
-cmTarget::~cmTarget()
-{
-  for(std::map<cmStdString, cmComputeLinkInformation*>::iterator
-        i = this->LinkInformation.begin();
-      i != this->LinkInformation.end(); ++i)
-    {
-    delete i->second;
-    }
-}
-
-//----------------------------------------------------------------------------
 void cmTarget::DefineProperties(cmake *cm)
 {
   cm->DefineProperty
@@ -3075,3 +3065,26 @@
     }
   return i->second;
 }
+
+//----------------------------------------------------------------------------
+cmTargetLinkInformationMap
+::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived()
+{
+  // Ideally cmTarget instances should never be copied.  However until
+  // we can make a sweep to remove that, this copy constructor avoids
+  // allowing the resources (LinkInformation) from getting copied.  In
+  // the worst case this will lead to extra cmComputeLinkInformation
+  // instances.  We also enforce in debug mode that the map be emptied
+  // when copied.
+  static_cast<void>(r);
+  assert(r.empty());
+}
+
+//----------------------------------------------------------------------------
+cmTargetLinkInformationMap::~cmTargetLinkInformationMap()
+{
+  for(derived::iterator i = this->begin(); i != this->end(); ++i)
+    {
+    delete i->second;
+    }
+}



More information about the Cmake-commits mailing list