diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-11-18 12:34:54 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-11-18 13:01:07 +0100 |
commit | 197576c40986085cbd5250283e1e80a2679c9cf0 (patch) | |
tree | b7e8a80342b674d96a2b4581cfbe1b031beca997 /clang/lib/Lex/HeaderSearch.cpp | |
parent | 7b6790850968031fe1c098ed6dcc196ddc547ea5 (diff) | |
download | llvm-197576c40986085cbd5250283e1e80a2679c9cf0.zip llvm-197576c40986085cbd5250283e1e80a2679c9cf0.tar.gz llvm-197576c40986085cbd5250283e1e80a2679c9cf0.tar.bz2 |
[clang][lex] Refactor check for the first file include
This patch refactors the code that checks whether a file has just been included for the first time.
The `HeaderSearch::FirstTimeLexingFile` function is removed and the information is threaded to the original call site from `HeaderSearch::ShouldEnterIncludeFile`. This will make it possible to avoid tracking the number of includes in a follow up patch.
Depends on D114092.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D114093
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 150e7ed..a0b6011 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1310,9 +1310,12 @@ void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE, bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File, bool isImport, - bool ModulesEnabled, Module *M) { + bool ModulesEnabled, Module *M, + bool &IsFirstIncludeOfFile) { ++NumIncluded; // Count # of attempted #includes. + IsFirstIncludeOfFile = false; + // Get information about this file. HeaderFileInfo &FileInfo = getFileInfo(File); @@ -1387,6 +1390,8 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP, // Increment the number of times this file has been included. ++FileInfo.NumIncludes; + IsFirstIncludeOfFile = FileInfo.NumIncludes == 1; + return true; } |