Don't return a reference to a local variable, and removed a redundant API.

llvm-svn: 180713
This commit is contained in:
Greg Clayton 2013-04-29 16:36:27 +00:00
parent d56a262200
commit a44c1e6b63
2 changed files with 5 additions and 26 deletions

View File

@ -380,17 +380,6 @@ public:
size_t
GetPath (char *path, size_t max_path_length) const;
//------------------------------------------------------------------
/// Extract the full path to the file.
///
/// Extract the directory and path into a std::string, which is returned.
///
/// @param[out] path
/// The directory + filename returned in this std::string reference.
//------------------------------------------------------------------
void
GetPath (std::string &path) const;
//------------------------------------------------------------------
/// Extract the full path to the file.
///
@ -400,8 +389,8 @@ public:
/// Returns a std::string with the directory and filename
/// concatenated.
//------------------------------------------------------------------
std::string&
GetPath (void) const;
std::string
GetPath () const;
//------------------------------------------------------------------
/// Extract the extension of the file.

View File

@ -702,12 +702,12 @@ FileSpec::GetPath(char *path, size_t path_max_len) const
return 0;
}
void
FileSpec::GetPath (std::string &path) const
std::string
FileSpec::GetPath (void) const
{
std::string path;
const char *dirname = m_directory.GetCString();
const char *filename = m_filename.GetCString();
path.clear();
if (dirname)
{
path.append (dirname);
@ -715,17 +715,7 @@ FileSpec::GetPath (std::string &path) const
path.append ("/");
}
if (filename)
{
path.append (filename);
}
}
std::string&
FileSpec::GetPath (void) const
{
std::string path;
GetPath (path);
return path;
}