This is an archive of the discontinued LLVM Phabricator instance.

[include-cleaner] Implement IWYU begin_keep/end_keep pragma support.
AbandonedPublic

Authored by VitaNuo on Nov 28 2022, 2:20 AM.

Details

Reviewers
hokein
Summary

Keep the includes contained between IWYU begin_keep and end_keep pragmas.

Diff Detail

Event Timeline

VitaNuo created this revision.Nov 28 2022, 2:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 2:20 AM
Herald added a subscriber: kadircet. · View Herald Transcript
VitaNuo requested review of this revision.Nov 28 2022, 2:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 2:20 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
VitaNuo updated this revision to Diff 478166.Nov 28 2022, 2:23 AM

Remove unnecessary code.

hokein added inline comments.Nov 28 2022, 4:20 AM
clang-tools-extra/include-cleaner/lib/Record.cpp
299

using a simple variable is not enough to handle the nested case like

// IWYU pragma: begin_keep
#include "keep1.h" 
// IWYU pragma: begin_keep
#include "keep2.h" 
#include "keep3.h"
// IWYU pragma: end_keep
#include "keep4.h"
// IWYU pragma: end_keep

now keep4.h is marked as unkeeped. I think we need to maintain a stack for Keep here (we already have a similar pattern for export)

VitaNuo added inline comments.Nov 28 2022, 4:23 AM
clang-tools-extra/include-cleaner/lib/Record.cpp
299

Ok, I had no idea this was valid usage :(

VitaNuo abandoned this revision.Nov 28 2022, 5:40 AM