summaryrefslogtreecommitdiffstats
path: root/Source/cmParseArgumentsCommand.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-07-17 14:20:58 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-07-24 09:11:25 (GMT)
commite91bfe440c1419b445ef6746552dd03ba302e6cf (patch)
treed541b14cb020c209aef9f050f35dbe592dce20e1 /Source/cmParseArgumentsCommand.cxx
parentf2ba968ef2a1c46e117dcd8eec34a55775f3d5f4 (diff)
downloadCMake-e91bfe440c1419b445ef6746552dd03ba302e6cf.zip
CMake-e91bfe440c1419b445ef6746552dd03ba302e6cf.tar.gz
CMake-e91bfe440c1419b445ef6746552dd03ba302e6cf.tar.bz2
cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value argument instead of a `const char *`. Benefits are: - `std::string` can be passed to `cmMakefile::AddDefinition` directly without the `c_str()` plus string length recomputation fallback. - Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at compile time. In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid `std::string::c_str` calls and the `std::string` is passed directly. Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
Diffstat (limited to 'Source/cmParseArgumentsCommand.cxx')
-rw-r--r--Source/cmParseArgumentsCommand.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index 5213432..0f8aef7 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -75,7 +75,7 @@ static void PassParsedArguments(
for (auto const& iter : singleValArgs) {
if (!iter.second.empty()) {
- makefile.AddDefinition(prefix + iter.first, iter.second.c_str());
+ makefile.AddDefinition(prefix + iter.first, iter.second);
} else {
makefile.RemoveDefinition(prefix + iter.first);
}
@@ -84,7 +84,7 @@ static void PassParsedArguments(
for (auto const& iter : multiValArgs) {
if (!iter.second.empty()) {
makefile.AddDefinition(prefix + iter.first,
- JoinList(iter.second, parseFromArgV).c_str());
+ JoinList(iter.second, parseFromArgV));
} else {
makefile.RemoveDefinition(prefix + iter.first);
}
@@ -92,15 +92,14 @@ static void PassParsedArguments(
if (!unparsed.empty()) {
makefile.AddDefinition(prefix + "UNPARSED_ARGUMENTS",
- JoinList(unparsed, parseFromArgV).c_str());
+ JoinList(unparsed, parseFromArgV));
} else {
makefile.RemoveDefinition(prefix + "UNPARSED_ARGUMENTS");
}
if (!keywordsMissingValues.empty()) {
- makefile.AddDefinition(
- prefix + "KEYWORDS_MISSING_VALUES",
- cmJoin(cmMakeRange(keywordsMissingValues), ";").c_str());
+ makefile.AddDefinition(prefix + "KEYWORDS_MISSING_VALUES",
+ cmJoin(cmMakeRange(keywordsMissingValues), ";"));
} else {
makefile.RemoveDefinition(prefix + "KEYWORDS_MISSING_VALUES");
}