This is an archive of the discontinued LLVM Phabricator instance.

[Frontend] Don't output skipped includes from predefines
ClosedPublic

Authored by smeenai on Jun 16 2023, 3:37 PM.

Details

Summary

-H displays a tree of included header files, but that tree is supposed
to omit two categories of header files:

  1. Any header files pulled in via -include, which the code refers to as the "predefines".
  2. Any header files whose inclusion was skipped because they'd already been included (assuming header guards or #pragma once).

-fshow-skipped-includes was intended to make -H display the second
category of files. It wasn't checking for the first category, however,
so you could end up with only the middle of the -include hierarchy
displayed, e.g. the added test would previously output:

... /data/users/smeenai/llvm-project/clang/test/Frontend/Inputs/test2.h
. /data/users/smeenai/llvm-project/clang/test/Frontend/Inputs/test.h

This diff adds a check to prevent that and correctly omit headers from
-include even when -fshow-skipped-includes is passed. While I'm
here, add tests for the interaction between -fshow-skipped-includes
and -sys-header-deps as well.

Diff Detail

Event Timeline

smeenai created this revision.Jun 16 2023, 3:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 3:37 PM
smeenai requested review of this revision.Jun 16 2023, 3:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 3:37 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
smeenai edited the summary of this revision. (Show Details)Jun 16 2023, 3:52 PM
hans accepted this revision.Jun 19 2023, 1:22 AM

-H is supposed to skip outputting headers from -include command line
arguments, but -fshow-skipped-includes was outputting any skipped
includes encountered via -include.

I was thrown off by the "-H is supposed to skip ... but -fshow-skipped-includes was outputting ..."

I suppose the point is that we do want -fshow-skipped-includes to show skipped includes, but not the ones from -include or system headers (unless -sys-header-deps)?

lgtm if I got that right.

This revision is now accepted and ready to land.Jun 19 2023, 1:22 AM

-H is supposed to skip outputting headers from -include command line
arguments, but -fshow-skipped-includes was outputting any skipped
includes encountered via -include.

I was thrown off by the "-H is supposed to skip ... but -fshow-skipped-includes was outputting ..."

I suppose the point is that we do want -fshow-skipped-includes to show skipped includes, but not the ones from -include or system headers (unless -sys-header-deps)?

lgtm if I got that right.

Yup, my description was kinda terrible :D Lemme try to clarify it.

smeenai edited the summary of this revision. (Show Details)Jun 21 2023, 3:32 PM
This revision was automatically updated to reflect the committed changes.