Page MenuHomePhabricator

clang-cl: Include /FI headers in /showIncludes output.
ClosedPublic

Authored by thakis on Mar 23 2016, 9:25 AM.

Details

Reviewers
hans
rsmith
Summary

-H in gcc mode doesn't print -include headers, but they are included in depfiles written by MMD and friends. Since /showIncludes is what's used instead of depfiles, printing /FI there seems important (and matches cl.exe).

There's more work to do for the interaction of /FI, /showIncludes, and PCH flags, but this is a strict improvement over what we have today.

Instead of giving HeaderIncludeGen more options, just switch on ShowAllHeaders in clang-cl mode and let clang::InitializePreprocessor() not put -include flags in the <command line> block. This changes the behavior of -E slightly, and it removes the <command line> flag from the output triggered by setting the obscure CC_PRINT_HEADERS=1 env var to true while running clang. Both of these seem ok to change.

Diff Detail

Event Timeline

thakis updated this revision to Diff 51430.Mar 23 2016, 9:25 AM
thakis retitled this revision from to clang-cl: Include /FI headers in /showIncludes output..
thakis updated this object.
thakis added a reviewer: hans.
thakis added a subscriber: cfe-commits.

On second thought, and after looking at -E output with -include and gch files, and at CC_PRINT_HEADERS behavior (it prints <command-line> but doesn't indent), I think I like the alternative implementation I'm mentioning better. Let me make that change.

thakis updated this object.
rsmith accepted this revision.Mar 23 2016, 10:53 AM
rsmith added a reviewer: rsmith.
rsmith added a subscriber: rsmith.
rsmith added inline comments.
lib/Frontend/HeaderIncludeGen.cpp
155–156

Missing "if" or similar in this comment?

157

I'm not a fan of using strcmp like this (implicitly converting the result to bool to mean "check strings are different"). I'd prefer you used

UserLoc.getFilename() != StringRef("<command line>")

(Of course, ideally we'd use something more principled than a check against the filename string... please add a FIXME for that.)

This revision is now accepted and ready to land.Mar 23 2016, 10:53 AM
thakis edited edge metadata.
thakis marked 2 inline comments as done.

Thanks! All done.

thakis closed this revision.Mar 23 2016, 11:06 AM

…and landed in r264174.