This is an archive of the discontinued LLVM Phabricator instance.

enable -save-temps with -finclude-defult-header
ClosedPublic

Authored by guansong on Mar 8 2017, 9:05 AM.

Details

Summary

Currently the two flags can not work together.

To illustrate the issue, we can have an one line file a.cl contains only an empty function

cat a.cl

void test(){}

Then use

clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c a.cl

we will get redefinition errors for various things.

The reason is that the -finclude-default-header flag is not meant to be on cc1 command other than the preprocessor.

The fix is modeled after the code just below the change to filter the -finclude-default-header flag out when we are not in the preprocess phase.

Diff Detail

Repository
rL LLVM

Event Timeline

guansong created this revision.Mar 8 2017, 9:05 AM
guansong added a reviewer: yaxunl.
guansong updated this revision to Diff 91045.Mar 8 2017, 10:11 AM

add a test

guansong added a subscriber: cfe-commits.
Anastasia added inline comments.Mar 13 2017, 10:50 AM
lib/Driver/Tools.cpp
5288 ↗(On Diff #91045)

It would be nice to add a comment around here explaining this case.

5290 ↗(On Diff #91045)

Remove the commented code, please!

guansong updated this revision to Diff 91600.Mar 13 2017, 11:54 AM
Anastasia accepted this revision.Mar 14 2017, 7:08 AM

LGTM! Thanks!

lib/Driver/Tools.cpp
5290 ↗(On Diff #91045)

I think the comment could be lifted up before the if statement. :)

This revision is now accepted and ready to land.Mar 14 2017, 7:08 AM
guansong updated this revision to Diff 91718.Mar 14 2017, 7:21 AM

Thanks, update as suggested.

This revision was automatically updated to reflect the committed changes.