This is an archive of the discontinued LLVM Phabricator instance.

clang-cl: Add a `/showIncludes:user` flag.
ClosedPublic

Authored by thakis on Feb 24 2020, 5:08 PM.

Details

Summary

This flag is like /showIncludes, but it only includes user headers and omits system headers (similar to MD and MMD). The motivation is that projects that already track system includes though other means can use this flag to get consistent behavior on Windows and non-Windows, and it saves tools that output /showIncludes output (e.g. ninja) some work.

implementation-wise, this makes HeaderIncludesCallback honor the existing IncludeSystemHeaders bit, and changes the three clients of HeaderIncludesCallback (/showIncludes, -H, CC_PRINT_HEADERS=1) to pass -sys-header-deps to set that bit -- except for /showIncludes:user, which doesn't pass it.

Diff Detail

Event Timeline

thakis created this revision.Feb 24 2020, 5:08 PM
hans added a comment.Feb 25 2020, 3:05 AM

Instead of replacing the old cc1 "--show-includes" with "--show-includes -sys-header-deps" -- which looks a little ugly maybe -- would it be simpler to just introduce a new cc1 flag instead, e.g. "--show-user-includes", and just expand /showIncludes:user to that?

This is what -MD passes (which is why the -sys flag already exists), and more orthogonal flags instead of fewer, tangled ones is what we usually go for at the cc1 layer. So I like it more as is.

thakis updated this revision to Diff 246417.Feb 25 2020, 4:59 AM

add one more test

hans added a comment.Feb 25 2020, 6:34 AM

This is what -MD passes (which is why the -sys flag already exists), and more orthogonal flags instead of fewer, tangled ones is what we usually go for at the cc1 layer. So I like it more as is.

Ah cool, I didn't realize that. Yes, this makes sense then.

hans accepted this revision.Feb 25 2020, 6:34 AM
This revision is now accepted and ready to land.Feb 25 2020, 6:34 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2020, 6:46 AM
hans added a comment.Feb 28 2020, 12:30 AM

Probably worth a mention in clang/docs/ReleaseNotes.rst, and maybe we should call it out in the user manual too, similarly to what we do for /Zc:dllexportInlines-