This is an archive of the discontinued LLVM Phabricator instance.

Perform wildcard expansion in Process::GetArgumentVector on Windows (PR17098)
ClosedPublic

Authored by hans on Jul 15 2014, 4:09 PM.

Details

Summary

On Windows, wildcard expansion isn't performed by the shell, but left to the program itself. The common way to do this is to link with setargv.obj, which performs the expansion on argc/argv before main is entered. However, we don't use argv in Clang on Windows, but instead call GetCommandLineW so we can handle unicode arguments. This means we have to do wildcard expansion ourselves.

Here is a stab at making GetArgumentVector perform wildcard expansion. I'm very open for ideas on how to test this, and also if this is the right place for the code to live.

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 11476.Jul 15 2014, 4:09 PM
hans retitled this revision from to Perform wildcard expansion in Process::GetArgumentVector on Windows (PR17098).
hans updated this object.
hans edited the test plan for this revision. (Show Details)
hans added reviewers: rnk, majnemer.
hans added subscribers: Unknown Object (MLST), hansw.
majnemer edited edge metadata.Jul 15 2014, 4:29 PM

The code looks fine but it needs tests.

lib/Support/Windows/Process.inc
224–225 ↗(On Diff #11476)

Can we use FindFirstFile?

hans added inline comments.Jul 15 2014, 4:39 PM
lib/Support/Windows/Process.inc
224–225 ↗(On Diff #11476)

Yes, it seems I'm not using any of the Ex capabilities.

238 ↗(On Diff #11476)

As per your offline comment, I'll see if I can just reuse Dir and avoid this copying.

hans updated this revision to Diff 11478.Jul 15 2014, 4:39 PM
hans edited edge metadata.

Addressing David's comments.

hans added a comment.Jul 15 2014, 4:57 PM

The code looks fine but it needs tests.

We don't have anything exercising this code in LLVM, but I can test it from Clang with the lit test below. What do you think?

Clang does wildcard expansion on Windows. On other OSs, it's done by the shell.
REQUIRES: system-windows

RUN: %clang -c -### %S/Inputs/wildcard*.c 2>&1 | FileCheck %s
CHECK: wildcard1.c
// CHECK: wildcard2.c

majnemer accepted this revision.Jul 15 2014, 5:59 PM
majnemer edited edge metadata.
This revision is now accepted and ready to land.Jul 15 2014, 5:59 PM
hans closed this revision.Jul 15 2014, 6:00 PM
hans updated this revision to Diff 11481.

Closed by commit rL213114 (authored by @hans).