diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-11-04 15:00:00 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-11-04 15:11:54 (GMT) |
commit | c7b50349de5e56d7584fa644832170d1e08ef62e (patch) | |
tree | 0fd42e52ae4cc439867b46b85664f0e1215690e4 /Source/cmSourceFile.cxx | |
parent | 622ac065d2abeb53de3548b7e4f3d9b5980dfa8d (diff) | |
download | CMake-c7b50349de5e56d7584fa644832170d1e08ef62e.zip CMake-c7b50349de5e56d7584fa644832170d1e08ef62e.tar.gz CMake-c7b50349de5e56d7584fa644832170d1e08ef62e.tar.bz2 |
cmSourceFile::GetPropertyForUser: return cmProp
also fix GetSafeProperty() return type
Diffstat (limited to 'Source/cmSourceFile.cxx')
-rw-r--r-- | Source/cmSourceFile.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 61f48e9..39074a5 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -310,7 +310,7 @@ void cmSourceFile::AppendProperty(const std::string& prop, } } -const char* cmSourceFile::GetPropertyForUser(const std::string& prop) +cmProp cmSourceFile::GetPropertyForUser(const std::string& prop) { // This method is a consequence of design history and backwards // compatibility. GetProperty is (and should be) a const method. @@ -334,13 +334,12 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop) // Similarly, LANGUAGE can be determined by the file extension // if it is requested by the user. if (prop == propLANGUAGE) { - // The c_str pointer is valid until `this->Language` is modified. - return this->GetOrDetermineLanguage().c_str(); + // The pointer is valid until `this->Language` is modified. + return &this->GetOrDetermineLanguage(); } // Perform the normal property lookup. - cmProp p = this->GetProperty(prop); - return p ? p->c_str() : nullptr; + return this->GetProperty(prop); } cmProp cmSourceFile::GetProperty(const std::string& prop) const @@ -398,13 +397,15 @@ cmProp cmSourceFile::GetProperty(const std::string& prop) const return retVal; } -const char* cmSourceFile::GetSafeProperty(const std::string& prop) const +const std::string& cmSourceFile::GetSafeProperty(const std::string& prop) const { cmProp ret = this->GetProperty(prop); - if (!ret) { - return ""; + if (ret) { + return *ret; } - return ret->c_str(); + + static std::string const s_empty; + return s_empty; } bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const |