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

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.

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

Differential Revision: https://reviews.llvm.org/D131241

GitOrigin-RevId: 786b503f66b1a35f79312203fcb533ad27511982
5 files changed