]> granicus.if.org Git - clang/commitdiff
Address some of the concerns by Chandler.
authorBill Wendling <isanbard@gmail.com>
Mon, 12 Mar 2012 22:10:06 +0000 (22:10 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 12 Mar 2012 22:10:06 +0000 (22:10 +0000)
* s/AddDirectoryList/addDirectoryList/
* Move the call to ::getenv into the function.
* FileCheck-ize the testcase.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152583 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/linker-opts.c

index 02b69b50573d83191d255c393f72d716987fd364..acd8b3a9451761e626a3fc71004b97607a7f748f 100644 (file)
@@ -88,10 +88,11 @@ static void QuoteTarget(StringRef Target,
   }
 }
 
-static void AddDirectoryList(const ArgList &Args,
+static void addDirectoryList(const ArgList &Args,
                              ArgStringList &CmdArgs,
                              const char *ArgName,
-                             const char *DirList) {
+                             const char *EnvVar) {
+  const char *DirList = ::getenv(EnvVar);
   if (!DirList)
     return; // Nothing to do.
 
@@ -106,9 +107,9 @@ static void AddDirectoryList(const ArgList &Args,
       CmdArgs.push_back(".");
     } else {
       CmdArgs.push_back(ArgName);
-      CmdArgs.push_back(Args.MakeArgString(Dirs.substr(0, Delim)));
+      CmdArgs.push_back(Args.MakeArgString(Dirs.split(Delim).first));
     }
-    Dirs = Dirs.substr(Delim + 1);
+    Dirs = Dirs.split(Delim).second;
   }
 
   if (Dirs.empty()) { // Trailing colon.
@@ -162,7 +163,7 @@ static void AddLinkerInputs(const ToolChain &TC,
   }
 
   // LIBRARY_PATH - included following the user specified library paths.
-  AddDirectoryList(Args, CmdArgs, "-L", ::getenv("LIBRARY_PATH"));
+  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
@@ -402,19 +403,15 @@ void Clang::AddPreprocessingOptions(Compilation &C,
   // frontend into the driver. It will allow deleting 4 otherwise unused flags.
   // CPATH - included following the user specified includes (but prior to
   // builtin and standard includes).
-  AddDirectoryList(Args, CmdArgs, "-I", ::getenv("CPATH"));
+  addDirectoryList(Args, CmdArgs, "-I", "CPATH");
   // C_INCLUDE_PATH - system includes enabled when compiling C.
-  AddDirectoryList(Args, CmdArgs, "-c-isystem",
-                   ::getenv("C_INCLUDE_PATH"));
+  addDirectoryList(Args, CmdArgs, "-c-isystem", "C_INCLUDE_PATH");
   // CPLUS_INCLUDE_PATH - system includes enabled when compiling C++.
-  AddDirectoryList(Args, CmdArgs, "-cxx-isystem",
-                   ::getenv("CPLUS_INCLUDE_PATH"));
+  addDirectoryList(Args, CmdArgs, "-cxx-isystem", "CPLUS_INCLUDE_PATH");
   // OBJC_INCLUDE_PATH - system includes enabled when compiling ObjC.
-  AddDirectoryList(Args, CmdArgs, "-objc-isystem",
-                   ::getenv("OBJC_INCLUDE_PATH"));
+  addDirectoryList(Args, CmdArgs, "-objc-isystem", "OBJC_INCLUDE_PATH");
   // OBJCPLUS_INCLUDE_PATH - system includes enabled when compiling ObjC++.
-  AddDirectoryList(Args, CmdArgs, "-objcxx-isystem",
-                   ::getenv("OBJCPLUS_INCLUDE_PATH"));
+  addDirectoryList(Args, CmdArgs, "-objcxx-isystem", "OBJCPLUS_INCLUDE_PATH");
 
   // Add C++ include arguments, if needed.
   if (types::isCXX(Inputs[0].getType()))
index a8d176cc1b2490ccaaf5c11dfb91703b75111103..253ca7bcf188ac0972ce8248b5ff3da00cc15033 100644 (file)
@@ -1,2 +1,2 @@
-// RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### -o foo 2> %t.log
-// RUN: grep '".*ld.*" .*"-L" "%T/test1"' %t.log
+// RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s
+// CHECK: "-L" "{{.*}}/test1"