This is an archive of the discontinued LLVM Phabricator instance.

[include-cleaner] FindHeaders respects IWYU export pragma for standard headers.
ClosedPublic

Authored by hokein on Jan 13 2023, 2:43 AM.

Diff Detail

Event Timeline

hokein created this revision.Jan 13 2023, 2:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2023, 2:43 AM
hokein requested review of this revision.Jan 13 2023, 2:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2023, 2:43 AM
kadircet added inline comments.Jan 13 2023, 4:22 AM
clang-tools-extra/include-cleaner/lib/Record.cpp
206

just saying StandardHeader here isn't really useful. what about changing signautre here to take a include_cleaner::Header instead, named IncludedHeader and switch over kind to add it to ExportBy map? I don't think there's any value in storing Exporters for <vector> both as a physical entry and a stdlib entry.

clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
122

nit: tooling::stdlib::Header::named("<string>")

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
437

drop the comment Line 1

hokein updated this revision to Diff 488995.Jan 13 2023, 7:13 AM
hokein marked 2 inline comments as done.

address comments

clang-tools-extra/include-cleaner/lib/Record.cpp
206

Ah, nice idea! thanks.

clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
122

We need this tooling::stdlib::Symbol here, include_cleaner::findHeaders accepts a SymbolLocation, SymbolLocation is construct from a tooling::stdlib::Symbol.

kadircet accepted this revision.Jan 13 2023, 7:51 AM

thanks!

clang-tools-extra/include-cleaner/lib/Record.cpp
192–200

nit: I'd make this an optional instead (as the code in checkForExport looks weird now, we do nullptr check on one branch but not the other) and change the flow to:

std::optional<Header> IncludedHeader;
if(IsAngled) {
  if(stdlibheader) ...
}

if(!IncludedHeader && File) {
 ...
}
214–227

nit:

switch(IncludedHeader.kind()) {
case Verbatim:
  assert(false && "...");
  break;
case others:
...
}

to be consistent with rest of the places (and more explicit about handling of verbatim)

clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
122

oops you're right

This revision is now accepted and ready to land.Jan 13 2023, 7:51 AM
hokein updated this revision to Diff 489448.Jan 16 2023, 1:03 AM
hokein marked 2 inline comments as done.

address comments.

This revision was landed with ongoing or failed builds.Jan 16 2023, 1:09 AM
This revision was automatically updated to reflect the committed changes.