This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Treat preamble patch as main file for include-cleaner analysis
ClosedPublic

Authored by kadircet on Apr 12 2023, 9:42 AM.

Details

Summary

Since we redefine all macros in preamble-patch, and it's parsed after
consuming the preamble macros, we can get false missing-include diagnostics
while a fresh preamble is being rebuilt.

This patch makes sure preamble-patch is treated same as main file for
include-cleaner purposes.

Diff Detail

Event Timeline

kadircet created this revision.Apr 12 2023, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 9:42 AM
Herald added a subscriber: arphaman. · View Herald Transcript
kadircet requested review of this revision.Apr 12 2023, 9:42 AM
sammccall added inline comments.Apr 12 2023, 9:52 AM
clang-tools-extra/clangd/IncludeCleaner.cpp
380

Comparing strings here every time seems odd & slow.

Is it too fragile to add a function somewhere (Preamble.h?) to get the preamble patch file ID from a source manager? (By reconstructing the path and then looking it up)

That way it can be done outside this loop, and without encoding such details here

kadircet updated this revision to Diff 512898.Apr 12 2023, 10:44 AM
  • Expose helper to get preamble patch entry
kadircet marked an inline comment as done.Apr 12 2023, 10:44 AM
sammccall accepted this revision.Apr 12 2023, 11:27 AM
sammccall added inline comments.
clang-tools-extra/clangd/Preamble.h
144

up to you, but this could be tested I think (just make sure it points to something valid with the right name when you have a patch and not otherwise)

This revision is now accepted and ready to land.Apr 12 2023, 11:27 AM
This revision was landed with ongoing or failed builds.Apr 12 2023, 12:06 PM
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.