This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Correctly identify self-contained headers included rercursively
ClosedPublic

Authored by kbobyrev on Apr 21 2022, 6:30 AM.

Details

Summary

Right now when exiting the file Headers.cpp will identify the recursive
inclusion (with a new FileID) as non self-contained and will add it to the set
from which it will never be removed. As a result, we get incorrect results in
the IncludeStructure and Include Cleaner. This patch is a fix.

Diff Detail

Event Timeline

kbobyrev created this revision.Apr 21 2022, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2022, 6:30 AM
kbobyrev requested review of this revision.Apr 21 2022, 6:30 AM
kbobyrev updated this revision to Diff 424176.Apr 21 2022, 6:30 AM

Remove unused include.

sammccall accepted this revision.Apr 21 2022, 6:49 AM
sammccall added inline comments.
clang-tools-extra/clangd/Headers.cpp
109–116

nit: reverse the if condition to avoid double-negative.

110

second sentence just echoes the code: say why, not what

isSelfContainedHeader only returns true once the full header-guard structure has been seen, i.e. when exiting the *outer* copy of the file. So last result wins.

This revision is now accepted and ready to land.Apr 21 2022, 6:49 AM
kbobyrev updated this revision to Diff 424192.Apr 21 2022, 7:05 AM
kbobyrev marked 2 inline comments as done.

Resolve the comments.