[PATCH] D113676: WIP: [clang][lex] Fix search path usage remark with modules
Alex Hoppen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 17 04:35:08 PST 2021
ahoppen added inline comments.
================
Comment at: clang/lib/Lex/HeaderSearch.cpp:95
+ if (HS.CurrentSearchPathIdx != ~0U)
+ HS.ModuleToSearchDirIdx[M] = HS.CurrentSearchPathIdx;
+ }
----------------
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;
```
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