[cfe-commits] r152583 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/linker-opts.c

Nico Weber thakis at chromium.org
Mon Mar 19 08:07:16 PDT 2012


Hi Bill,

On Mon, Mar 12, 2012 at 3:10 PM, Bill Wendling <isanbard at gmail.com> wrote:
> Author: void
> Date: Mon Mar 12 17:10:06 2012
> New Revision: 152583
>
> URL: http://llvm.org/viewvc/llvm-project?rev=152583&view=rev
> Log:
> Address some of the concerns by Chandler.
>
> * s/AddDirectoryList/addDirectoryList/
> * Move the call to ::getenv into the function.
> * FileCheck-ize the testcase.
>
> Modified:
>    cfe/trunk/lib/Driver/Tools.cpp
>    cfe/trunk/test/Driver/linker-opts.c
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=152583&r1=152582&r2=152583&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 12 17:10:06 2012
> @@ -88,10 +88,11 @@
>   }
>  }
>
> -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 @@
>       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;

This broke a :-separated CPLUS_INCLUDE_PATH:

$ CPLUS_INCLUDE_PATH="/foo:/bar"
third_party/llvm-build/Release+Asserts/bin/clang -v -c test.cc
# ...
clang -cc1 -cxx-isystem /foo:/bar ...
# ...

I landed a fix in r153034 (I just reverted the two lines you changed
above, since they look unrelated to the change description, and
changing them made no tests fail).

Nico


>   }
>
>   if (Dirs.empty()) { // Trailing colon.
> @@ -162,7 +163,7 @@
>   }
>
>   // 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 @@
>   // 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()))
>
> Modified: cfe/trunk/test/Driver/linker-opts.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linker-opts.c?rev=152583&r1=152582&r2=152583&view=diff
> ==============================================================================
> --- cfe/trunk/test/Driver/linker-opts.c (original)
> +++ cfe/trunk/test/Driver/linker-opts.c Mon Mar 12 17:10:06 2012
> @@ -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"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list