================ @@ -276,6 +280,27 @@ class PragmaIncludes::RecordPragma : public PPCallbacks, public CommentHandler { KeepStack.pop_back(); // Pop immediately for single-line keep pragma. } + // Consider marking H as the "associated header" of the main file. + // + // Our heuristic: + // - it must be the first #include in the main file + // - it must have the same name stem as the main file (foo.h and foo.cpp) + // (IWYU pragma: associated is also supported, just not by this function). + // + // We consider the associated header as if it had a keep pragma. + // (Unlike IWYU, we don't treat #includes inside the associated header as if + // they were written in the main file.) + void checkForDeducedAssociated(std::optional<Header> H) { + namespace path = llvm::sys::path; + if (!InMainFile || SeenAssociatedCandidate) + return; + SeenAssociatedCandidate = true; ---------------- kadircet wrote:
i think this is still worth a comment, `Make sure we don't consider anything but the first include of the main file` ? https://github.com/llvm/llvm-project/pull/67228 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits