Make the special lexing for dependency scanning a first-class feature of the Preprocessor and Lexer, instead of implementation detail of DependencyScanningFilesystem. This has the following benefits:
- Full access to the preprocessor state during dependency scanning. E.g. a component can see what includes were taken and where they were located in the actual sources.
- Improved performance for dependency scanning. Measurements for dependency scanning of clang sources shows reduction in wall time
- M1Pro: reduction of about -10.6%
- iMacPro: reduction of about -14%
- Opportunity to use dependency scanning lexing to speed-up skipping of excluded conditional blocks during normal preprocessing (as follow-up, not part of this patch).
Since, after this change, we don't minimize sources and pass them in place of the real sources, DependencyScanningFilesystem is not technically necessary, but it has valuable performance benefits for caching file stats along with the results of scanning the sources. So the setup of using the DependencyScanningFilesystem during a dependency scan remains.
You'll need to #include "clang/Basic/FileEntry.h". Build with modules fails otherwise.