[cfe-commits] r140409 - in /cfe/trunk: docs/tools/clang.pod include/clang/Driver/Options.td lib/Driver/Driver.cpp

Chandler Carruth chandlerc at google.com
Fri Sep 30 14:21:06 PDT 2011


In addition to Doug's concerns which I share (chdir seems *really* heavy
handed inside the driver...) I have some more basic technical problems here.

On Fri, Sep 23, 2011 at 1:33 PM, Daniel Dunbar <daniel at zuster.org> wrote:

> +  // Honor --working-directory. Eventually we want to handle this
> completely
> +  // internally to support good use as a library, but for now we just
> change our
> +  // working directory.
> +  if (const Arg *A = Args->getLastArg(options::OPT__working_directory)) {
> +    ::chdir(A->getValue(*Args));
>

Why aren't you checking this for errors??

As a result of this not being checked, the test (which isn't in this commit?
please put test cases in the same commit when possible, it makes it harder
to review patches) doesn't actually test anything:

% cat tools/clang/test/Driver/Output/working-directory.c.script
touch .../build/tools/clang/test/Driver/Output/working-directory.c.tmp.h &&
echo '#include
".../build/tools/clang/test/Driver/Output/working-directory.c.tmp.h"' >
.../build/tools/clang/test/Driver/Output/working-directory.c.tmp.c &&
.../build/bin/./clang  --working-directory
.../build/tools/clang/test/Driver/Output/working-directory.c.tmp
-fsyntax-only
.../build/tools/clang/test/Driver/Output/working-directory.c.tmp.c

(paths munged for readability, but '...' is an absolute path)

'working-directory.c.tmp' is a non-existent file, its not a directory at
all.

Also, the include uses an absolute path, and the clang commandline does too,
this test would pass with Clang run from *any* working directory... I think
you want to have a source file in the Input subdirectory, and run the
compile with a relative path to that file, and a working directory inside
the Input subdirectory.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110930/c0b285a8/attachment.html>


More information about the cfe-commits mailing list