This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Lex] Extend HeaderSearch::LookupFile to control OpenFile behavior.
ClosedPublic

Authored by junaire on Aug 4 2022, 11:25 PM.

Details

Summary

In the downstream projects (ROOT and Cling), we want to do header files
lookups but no OpenFile behavior as we only need to register the file
name.

This patch extends the original API call by adding some optional flags
so we can continue use it in the previous way with no breakage.
Signed-off-by: Jun Zhang <jun@junz.org>

Diff Detail

Event Timeline

junaire created this revision.Aug 4 2022, 11:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 11:25 PM
junaire requested review of this revision.Aug 4 2022, 11:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 11:25 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Maybe we can add a little more context. In the case of static compilation the file system is pretty much read-only and taking a snapshot of it usually is sufficient. In the interactive C++ case the compilation is longer and people can create and include files, etc. In that case we often do not want to open files or cache failures unless is absolutely necessary. We might be able to write a test for this in clang/unittests/Lex/HeaderSearchTest.cpp. However, this patch improves consistency in the interfaces by forwarding the already provided flags to the callees and if we cannot write a reasonable test we should be able to accept it without.

jansvoboda11 accepted this revision.Aug 5 2022, 12:35 PM

LGTM. It'd be nice to have some tests for this, but since it's just forwarding arguments to FileManager I'm also fine with this as is.

This revision is now accepted and ready to land.Aug 5 2022, 12:35 PM