From 5bf825b7642ded88574a16e08596e1babb7272ca Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 8 Oct 2016 01:38:43 +0000 Subject: [PATCH] Use StringRef in Command::printArg() instead of raw pointer (NFC) llvm-svn: 283645 --- clang/include/clang/Driver/Job.h | 2 +- clang/lib/Driver/Job.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Driver/Job.h b/clang/include/clang/Driver/Job.h index 3366fc4..35758d8 100644 --- a/clang/include/clang/Driver/Job.h +++ b/clang/include/clang/Driver/Job.h @@ -116,7 +116,7 @@ public: const llvm::opt::ArgStringList &getArguments() const { return Arguments; } /// Print a command argument, and optionally quote it. - static void printArg(llvm::raw_ostream &OS, const char *Arg, bool Quote); + static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote); }; /// Like Command, but with a fallback which is executed in case diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp index 8d5e302..97aaf3e 100644 --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -80,8 +80,8 @@ static int skipArgs(const char *Flag, bool HaveCrashVFS) { return 0; } -void Command::printArg(raw_ostream &OS, const char *Arg, bool Quote) { - const bool Escape = std::strpbrk(Arg, "\"\\$"); +void Command::printArg(raw_ostream &OS, StringRef Arg, bool Quote) { + const bool Escape = Arg.find_first_of("\"\\$") != StringRef::npos; if (!Quote && !Escape) { OS << Arg; @@ -90,7 +90,7 @@ void Command::printArg(raw_ostream &OS, const char *Arg, bool Quote) { // Quote and escape. This isn't really complete, but good enough. OS << '"'; - while (const char c = *Arg++) { + for (const char c : Arg) { if (c == '"' || c == '\\' || c == '$') OS << '\\'; OS << c; -- 2.7.4