summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-10-05 01:32:41 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-10-05 01:32:41 +0000
commitec4fb5ba9736c1910b8a1631c46d653172e5a4df (patch)
treec479d07a6d2c2a68c4ee6f2a9fe6ed291cefcc2b /llvm/lib/Support
parent9ff9713f8a2fba396e4d40cb180b52a896e5bdd1 (diff)
downloadbcm5719-llvm-ec4fb5ba9736c1910b8a1631c46d653172e5a4df.tar.gz
bcm5719-llvm-ec4fb5ba9736c1910b8a1631c46d653172e5a4df.zip
Use StringRef in StringSaver API (NFC)
llvm-svn: 283290
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/CommandLine.cpp10
-rw-r--r--llvm/lib/Support/StringSaver.cpp4
2 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 21d4231215a..c5ca2149de3 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -726,7 +726,7 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
// End the token if this is whitespace.
if (isWhitespace(Src[I])) {
if (!Token.empty())
- NewArgv.push_back(Saver.save(StringRef(Token)));
+ NewArgv.push_back(Saver.save(StringRef(Token)).data());
Token.clear();
continue;
}
@@ -737,7 +737,7 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
// Append the last token after hitting EOF with no whitespace.
if (!Token.empty())
- NewArgv.push_back(Saver.save(StringRef(Token)));
+ NewArgv.push_back(Saver.save(StringRef(Token)).data());
// Mark the end of response files
if (MarkEOLs)
NewArgv.push_back(nullptr);
@@ -818,7 +818,7 @@ void cl::TokenizeWindowsCommandLine(StringRef Src, StringSaver &Saver,
if (State == UNQUOTED) {
// Whitespace means the end of the token.
if (isWhitespace(Src[I])) {
- NewArgv.push_back(Saver.save(StringRef(Token)));
+ NewArgv.push_back(Saver.save(StringRef(Token)).data());
Token.clear();
State = INIT;
// Mark the end of lines in response files
@@ -853,7 +853,7 @@ void cl::TokenizeWindowsCommandLine(StringRef Src, StringSaver &Saver,
}
// Append the last token after hitting EOF with no whitespace.
if (!Token.empty())
- NewArgv.push_back(Saver.save(StringRef(Token)));
+ NewArgv.push_back(Saver.save(StringRef(Token)).data());
// Mark the end of response files
if (MarkEOLs)
NewArgv.push_back(nullptr);
@@ -962,7 +962,7 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar,
SmallVector<const char *, 20> newArgv;
BumpPtrAllocator A;
StringSaver Saver(A);
- newArgv.push_back(Saver.save(progName));
+ newArgv.push_back(Saver.save(progName).data());
// Parse the value of the environment variable into a "command line"
// and hand it off to ParseCommandLineOptions().
diff --git a/llvm/lib/Support/StringSaver.cpp b/llvm/lib/Support/StringSaver.cpp
index bbc1fd27626..335fce3a7bb 100644
--- a/llvm/lib/Support/StringSaver.cpp
+++ b/llvm/lib/Support/StringSaver.cpp
@@ -11,9 +11,9 @@
using namespace llvm;
-const char *StringSaver::save(StringRef S) {
+StringRef StringSaver::save(StringRef S) {
char *P = Alloc.Allocate<char>(S.size() + 1);
memcpy(P, S.data(), S.size());
P[S.size()] = '\0';
- return P;
+ return StringRef(P, S.size());
}
OpenPOWER on IntegriCloud