================
@@ -1550,19 +1557,57 @@ class Preprocessor {
/// Mark the file as included.
/// Returns true if this is the first time the file was included.
bool markIncluded(FileEntryRef File) {
+ bool AlreadyIncluded = alreadyIncluded(File);
HeaderInfo.getFileInfo(File).IsLocallyIncluded = true;
- return IncludedFiles.insert(File).second;
+ CurSubmoduleState->VisibleIncludedFiles.insert(File);
+
+ Module *M = BuildingSubmoduleStack.empty()
+ ? getCurrentModule()
+ : BuildingSubmoduleStack.back().M;
+ if (M) {
+ M->Includes.insert(File);
+ IncludingModules[&File.getFileEntry()].insert(M);
+ } else
+ Includes.insert(File);
+
+ return !AlreadyIncluded;
}
/// Return true if this header has already been included.
bool alreadyIncluded(FileEntryRef File) const {
HeaderInfo.getFileInfo(File);
- return IncludedFiles.count(File);
- }
-
- /// Get the set of included files.
- IncludedFilesSet &getIncludedFiles() { return IncludedFiles; }
- const IncludedFilesSet &getIncludedFiles() const { return IncludedFiles; }
+ if (CurSubmoduleState->VisibleIncludedFiles.contains(File))
+ return true;
+ auto It = IncludingModules.find(&File.getFileEntry());
+ if (It != IncludingModules.end())
----------------
jansvoboda11 wrote:
I'd personally prefer early
```c++
if (It == IncludingModules.end())
return false;
```
to reduce nesting of the loop below.
https://github.com/llvm/llvm-project/pull/170215
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits