[PATCH] D113676: [clang][lex] Fix search path usage remark with modules

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 6 08:22:55 PST 2022


jansvoboda11 marked an inline comment as done.
jansvoboda11 added inline comments.


================
Comment at: clang/lib/Lex/HeaderSearch.cpp:95
+      if (HS.CurrentSearchPathIdx != ~0U)
+        HS.ModuleToSearchDirIdx[M] = HS.CurrentSearchPathIdx;
+    }
----------------
ahoppen wrote:
> These indices will be out of date if the search paths are changed via `HeaderSearch::SetSearchPaths` or `HeaderSearch::AddSearchPath` after the first module map has been loaded. One could probably adjust the indices in `AddSearchPath` but maybe it’s easier to not use the index into `SearchDirs` as the key. An alternative suggestion would be to use `std::shared_ptr<DirectoryLookup>` instead, changing some of the data structures as follows:
> ```
> - std::vector<DirectoryLookup> SearchDirs
> + std::vector<std::shared_ptr<DirectoryLookup>> SearchDirs
> 
> - std::vector<bool> SearchDirsUsage;
> + std::map<std::shared_ptr<DirectoryLookup>, bool> SearchDirsUsage; 
> 
> - llvm::DenseMap<Module *, unsigned> ModuleToSearchDirIdx;
> + llvm::DenseMap<Module *, std::shared_ptr<DirectoryLookup>> ModuleToSearchDirIdx;
> 
> - llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
> + llvm::DenseMap<std::shared_ptr<DirectoryLookup>, unsigned> SearchDirToHSEntry; 
> ```
Fixed in D116750.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113676/new/

https://reviews.llvm.org/D113676



More information about the cfe-commits mailing list