فهرست منبع

cmStateDirectory: use const std::string& for return values

Vitaly Stakhovsky 7 سال پیش
والد
کامیت
ada121e573
6فایلهای تغییر یافته به همراه23 افزوده شده و 21 حذف شده
  1. 2 2
      Source/cmLocalGenerator.cxx
  2. 2 2
      Source/cmMakefile.cxx
  3. 2 2
      Source/cmOutputConverter.cxx
  4. 9 9
      Source/cmStateDirectory.cxx
  5. 4 4
      Source/cmStateDirectory.h
  6. 4 2
      Source/cmTarget.cxx

+ 2 - 2
Source/cmLocalGenerator.cxx

@@ -2524,12 +2524,12 @@ std::string const& cmLocalGenerator::GetBinaryDirectory() const
 
 const char* cmLocalGenerator::GetCurrentBinaryDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str();
 }
 
 const char* cmLocalGenerator::GetCurrentSourceDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentSource();
+  return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str();
 }
 
 std::string cmLocalGenerator::GetTargetDirectory(

+ 2 - 2
Source/cmMakefile.cxx

@@ -1637,12 +1637,12 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
 
 const char* cmMakefile::GetCurrentSourceDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentSource();
+  return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str();
 }
 
 const char* cmMakefile::GetCurrentBinaryDirectory() const
 {
-  return this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str();
 }
 
 std::vector<cmTarget*> cmMakefile::GetImportedTargets() const

+ 2 - 2
Source/cmOutputConverter.cxx

@@ -83,9 +83,9 @@ bool cmOutputConverter::ContainedInDirectory(std::string const& local_path,
                                              std::string const& remote_path,
                                              cmStateDirectory const& directory)
 {
-  const std::string relativePathTopBinary =
+  const std::string& relativePathTopBinary =
     directory.GetRelativePathTopBinary();
-  const std::string relativePathTopSource =
+  const std::string& relativePathTopSource =
     directory.GetRelativePathTopSource();
 
   const bool bothInBinary =

+ 9 - 9
Source/cmStateDirectory.cxx

@@ -84,9 +84,9 @@ void cmStateDirectory::ComputeRelativePathTopBinary()
   }
 }
 
-const char* cmStateDirectory::GetCurrentSource() const
+std::string const& cmStateDirectory::GetCurrentSource() const
 {
-  return this->DirectoryState->Location.c_str();
+  return this->DirectoryState->Location;
 }
 
 void cmStateDirectory::SetCurrentSource(std::string const& dir)
@@ -101,9 +101,9 @@ void cmStateDirectory::SetCurrentSource(std::string const& dir)
   this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc);
 }
 
-const char* cmStateDirectory::GetCurrentBinary() const
+std::string const& cmStateDirectory::GetCurrentBinary() const
 {
-  return this->DirectoryState->OutputLocation.c_str();
+  return this->DirectoryState->OutputLocation;
 }
 
 void cmStateDirectory::SetCurrentBinary(std::string const& dir)
@@ -118,14 +118,14 @@ void cmStateDirectory::SetCurrentBinary(std::string const& dir)
   this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc);
 }
 
-const char* cmStateDirectory::GetRelativePathTopSource() const
+std::string const& cmStateDirectory::GetRelativePathTopSource() const
 {
-  return this->DirectoryState->RelativePathTopSource.c_str();
+  return this->DirectoryState->RelativePathTopSource;
 }
 
-const char* cmStateDirectory::GetRelativePathTopBinary() const
+std::string const& cmStateDirectory::GetRelativePathTopBinary() const
 {
-  return this->DirectoryState->RelativePathTopBinary.c_str();
+  return this->DirectoryState->RelativePathTopBinary;
 }
 
 void cmStateDirectory::SetRelativePathTopSource(const char* dir)
@@ -474,7 +474,7 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
   if (prop == "PARENT_DIRECTORY") {
     cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
     if (parent.IsValid()) {
-      return parent.GetDirectory().GetCurrentSource();
+      return parent.GetDirectory().GetCurrentSource().c_str();
     }
     return "";
   }

+ 4 - 4
Source/cmStateDirectory.h

@@ -22,13 +22,13 @@ class cmStateDirectory
     cmStateSnapshot const& snapshot);
 
 public:
-  const char* GetCurrentSource() const;
+  std::string const& GetCurrentSource() const;
   void SetCurrentSource(std::string const& dir);
-  const char* GetCurrentBinary() const;
+  std::string const& GetCurrentBinary() const;
   void SetCurrentBinary(std::string const& dir);
 
-  const char* GetRelativePathTopSource() const;
-  const char* GetRelativePathTopBinary() const;
+  std::string const& GetRelativePathTopSource() const;
+  std::string const& GetRelativePathTopBinary() const;
   void SetRelativePathTopSource(const char* dir);
   void SetRelativePathTopBinary(const char* dir);
 

+ 4 - 2
Source/cmTarget.cxx

@@ -1415,13 +1415,15 @@ const char* cmTarget::GetProperty(const std::string& prop) const
       return this->GetMakefile()
         ->GetStateSnapshot()
         .GetDirectory()
-        .GetCurrentBinary();
+        .GetCurrentBinary()
+        .c_str();
     }
     if (prop == propSOURCE_DIR) {
       return this->GetMakefile()
         ->GetStateSnapshot()
         .GetDirectory()
-        .GetCurrentSource();
+        .GetCurrentSource()
+        .c_str();
     }
   }