diff options
author | Reid Kleckner <rnk@google.com> | 2020-02-26 16:29:37 -0800 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2020-02-27 10:18:06 -0800 |
commit | bc8836651fba3304d92e1025ff6a918f25e9e209 (patch) | |
tree | bcd1b9745ac65de4df60f0c569792c54a50ae415 /clang/lib/Basic/Module.cpp | |
parent | 04da3dfecc199a7fdd262b06eeb399fc8ce0d1f6 (diff) | |
download | llvm-bc8836651fba3304d92e1025ff6a918f25e9e209.zip llvm-bc8836651fba3304d92e1025ff6a918f25e9e209.tar.gz llvm-bc8836651fba3304d92e1025ff6a918f25e9e209.tar.bz2 |
Forward declare FileEntry and DirectoryEntry in Module.h
FileManager.h is an expensive header (~350ms for me in isolation), so
try to do without it.
Notably, we need to avoid checking the alignment of FileEntry, which
happens for DenseMap<FileEntry*> and PointerUnion<FileEntry*>. I
adjusted the code to avoid PointerUnion, and moved the DenseMap
insertion to the .cpp file.
Globally, this only saved about ~17 includes of the related headers
because SourceManager.h still includes FileManager.h, and it is more
popular than Module.h.
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 92835c9..7fb6dee 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, InferSubmodules(false), InferExplicitSubmodules(false), InferExportWildcard(false), ConfigMacrosExhaustive(false), NoUndeclaredIncludes(false), ModuleMapIsPrivate(false), - NameVisibility(Hidden) { + HasUmbrellaDir(false), NameVisibility(Hidden) { if (Parent) { if (!Parent->isAvailable()) IsAvailable = false; @@ -239,7 +239,12 @@ Module::DirectoryName Module::getUmbrellaDir() const { if (Header U = getUmbrellaHeader()) return {"", U.Entry->getDir()}; - return {UmbrellaAsWritten, Umbrella.dyn_cast<const DirectoryEntry *>()}; + return {UmbrellaAsWritten, static_cast<const DirectoryEntry *>(Umbrella)}; +} + +void Module::addTopHeader(const FileEntry *File) { + assert(File); + TopHeaders.insert(File); } ArrayRef<const FileEntry *> Module::getTopHeaders(FileManager &FileMgr) { |