]> granicus.if.org Git - clang/commitdiff
Use StringRef in Command::printArg() instead of raw pointer (NFC)
authorMehdi Amini <mehdi.amini@apple.com>
Sat, 8 Oct 2016 01:38:43 +0000 (01:38 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Sat, 8 Oct 2016 01:38:43 +0000 (01:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283645 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Job.h
lib/Driver/Job.cpp

index 3366fc48d7110ecbb15f60bda3355bc1d2b10c68..35758d8340ad968c5321d221c230c0494bc90910 100644 (file)
@@ -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
index 8d5e302ae6ff15de1015c477cac684043e207cca..97aaf3e703e32063a3888df8d107741bfaab4e90 100644 (file)
@@ -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;