[PATCH] D75951: Keep a list of already-included pragma-once files for mods.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 14 16:20:29 PDT 2020
rsmith added inline comments.
================
Comment at: clang/include/clang/Lex/Preprocessor.h:749-750
+ /// The set of the included headers' UID for the submodule.
+ std::set<unsigned> IncludedFiles;
+
----------------
A `std::set` is a very heavy object to be copying each time a module is entered / left. I think this is also putting the cost in the wrong place: ideally we want an approach whose cost scales only with the number of `#include` / `#import` directives that name a header that should only be included once, not the number of modules entered / left after such a directive is seen, so we should be tracking the state on the `HeaderFileInfo` instead of here.
So, how about this: on each `HeaderFileInfo`, track the set of module IDs in which the header file has been included in a way that suppresses further inclusion. Then when we come to consider a `#include`, check to see if any of those module IDs is visible in the includer and suppress the inclusion if so.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75951/new/
https://reviews.llvm.org/D75951
More information about the cfe-commits
mailing list