[PATCH] D129524: [Lex/HeaderSearch] Only lookup `HeaderFileInfo` for a `FileEntry` from `ExternalSource` once

Argyrios Kyrtzidis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 11 16:53:41 PDT 2022


akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without marking the `HeaderFileInfo` as resolved the `FileEntries` of files that were not found in `ExternalSource`
are looked up in `ExternalSource` over and over again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129524

Files:
  clang/lib/Lex/HeaderSearch.cpp


Index: clang/lib/Lex/HeaderSearch.cpp
===================================================================
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1284,9 +1284,9 @@
   HeaderFileInfo *HFI = &FileInfo[FE->getUID()];
   // FIXME: Use a generation count to check whether this is really up to date.
   if (ExternalSource && !HFI->Resolved) {
+    HFI->Resolved = true;
     auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
     if (ExternalHFI.IsValid) {
-      HFI->Resolved = true;
       if (ExternalHFI.External)
         mergeHeaderFileInfo(*HFI, ExternalHFI);
     }
@@ -1316,9 +1316,9 @@
     if (!WantExternal && (!HFI->IsValid || HFI->External))
       return nullptr;
     if (!HFI->Resolved) {
+      HFI->Resolved = true;
       auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
       if (ExternalHFI.IsValid) {
-        HFI->Resolved = true;
         if (ExternalHFI.External)
           mergeHeaderFileInfo(*HFI, ExternalHFI);
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129524.443790.patch
Type: text/x-patch
Size: 997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220711/69cbd0ab/attachment-0001.bin>


More information about the cfe-commits mailing list