diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2022-11-18 10:45:08 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2022-11-18 11:11:17 +0800 |
commit | d5844685810980399397a4310b943532361790ef (patch) | |
tree | 67a15f179fa38812f53c6c6fb0fdb85c2f75d681 /clang/lib | |
parent | ae43420f39f5fea798141bb76b0b68c3d5e9dede (diff) | |
download | llvm-d5844685810980399397a4310b943532361790ef.zip llvm-d5844685810980399397a4310b943532361790ef.tar.gz llvm-d5844685810980399397a4310b943532361790ef.tar.bz2 |
[C++20] [Modules] Don't emit macro definitions with named module
It is meaningless to emit macro definitions for named modules. With some
small experiments, the size of the module for the named modules reduced
2%~4% after this patch.
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 95ed51a..e944d2e 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2318,11 +2318,14 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { // Construct the list of identifiers with macro directives that need to be // serialized. SmallVector<const IdentifierInfo *, 128> MacroIdentifiers; - for (auto &Id : PP.getIdentifierTable()) - if (Id.second->hadMacroDefinition() && - (!Id.second->isFromAST() || - Id.second->hasChangedSinceDeserialization())) - MacroIdentifiers.push_back(Id.second); + // It is meaningless to emit macros for named modules. It only wastes times + // and spaces. + if (!isWritingStdCXXNamedModules()) + for (auto &Id : PP.getIdentifierTable()) + if (Id.second->hadMacroDefinition() && + (!Id.second->isFromAST() || + Id.second->hasChangedSinceDeserialization())) + MacroIdentifiers.push_back(Id.second); // Sort the set of macro definitions that need to be serialized by the // name of the macro, to provide a stable ordering. llvm::sort(MacroIdentifiers, llvm::deref<std::less<>>()); |