summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-09-18 15:17:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-09-18 15:18:00 (GMT)
commita8f628c0a456f74680bfdad0050f2614dbe50853 (patch)
treef072a8939837a3d6f954993fdbb9b54e43cdf1f0 /Source/cmMakefile.cxx
parent7adf3aabd55dd80784727a229a37c394740db628 (diff)
parentf4ff60a803170311f49511a60a381eef8b78c5dd (diff)
downloadCMake-a8f628c0a456f74680bfdad0050f2614dbe50853.zip
CMake-a8f628c0a456f74680bfdad0050f2614dbe50853.tar.gz
CMake-a8f628c0a456f74680bfdad0050f2614dbe50853.tar.bz2
Merge topic 'getsafedef-stdstring'
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2350
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx24
1 files changed, 17 insertions, 7 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index fdcf0a8..ec5ce92 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2401,7 +2401,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
return def != nullptr;
}
-const char* cmMakefile::GetDefinition(const std::string& name) const
+const std::string* cmMakefile::GetDef(const std::string& name) const
{
const std::string* def = this->StateSnapshot.GetDefinition(name);
if (!def) {
@@ -2427,16 +2427,26 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
}
}
#endif
- return (def ? def->c_str() : nullptr);
+ return def;
}
-const char* cmMakefile::GetSafeDefinition(const std::string& def) const
+const char* cmMakefile::GetDefinition(const std::string& name) const
{
- const char* ret = this->GetDefinition(def);
- if (!ret) {
- return "";
+ const std::string* def = GetDef(name);
+ if (!def) {
+ return nullptr;
}
- return ret;
+ return def->c_str();
+}
+
+const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const
+{
+ static std::string const empty;
+ const std::string* def = GetDef(name);
+ if (!def) {
+ return empty;
+ }
+ return *def;
}
std::vector<std::string> cmMakefile::GetDefinitions() const