This is an archive of the discontinued LLVM Phabricator instance.

[clang-cl] Add support for CL and _CL_ environment variables
ClosedPublic

Authored by majnemer on Aug 10 2015, 1:15 AM.

Details

Summary

cl uses 'CL' and '_CL_' to prepend and append command line options to
the given argument vector. There is an additional quirk whereby '#' is
transformed into '='.

Diff Detail

Event Timeline

majnemer updated this revision to Diff 31640.Aug 10 2015, 1:15 AM
majnemer retitled this revision from to [clang-cl] Add support for CL and _CL_ environment variables.
majnemer updated this object.
majnemer added reviewers: hansw, rnk.
majnemer added a subscriber: cfe-commits.
rnk accepted this revision.Aug 10 2015, 8:22 AM
rnk edited edge metadata.

lgtm

tools/driver/driver.cpp
464–466

How about adjusting all the options in place and then inserting them all at once to avoid the N^2 complexity?

This revision is now accepted and ready to land.Aug 10 2015, 8:22 AM
hans accepted this revision.Aug 10 2015, 9:33 AM
hans added a reviewer: hans.
hans added a subscriber: hans.

Out of curiosity, did you run in to something that relies on this in the wild?

tools/driver/driver.cpp
452

Maybe don't take the parameter as a const char* if the constness needs to be dropped for the adjusting to take place? The const_cast could just be moved to where you make the call below.

rnk added inline comments.Aug 10 2015, 9:55 AM
tools/driver/driver.cpp
451

I'd also rather factor this out of driver main, since it's really not important to most readers.

452

I think TokenizeCommandLine builds you a list of const strings, unfortunately. We could avoid the cast if we hooked into the tokenization or StringSaver, but it didn't seem worth it.

This revision was automatically updated to reflect the committed changes.