[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 25 01:11:43 PDT 2023
================
@@ -617,24 +617,27 @@ void ASTDeclReader::VisitDecl(Decl *D) {
Reader.getContext());
}
D->setLocation(ThisDeclLoc);
- D->InvalidDecl = Record.readInt();
- if (Record.readInt()) { // hasAttrs
+
+ uint64_t DeclBits = Record.readInt();
+ D->InvalidDecl = DeclBits & 0x1;
+ D->setImplicit(DeclBits & (1 << 2));
+ D->Used = (DeclBits >> 3) & 0x1;
+ IsDeclMarkedUsed |= D->Used;
+ D->setReferenced(DeclBits & (1 << 4));
+ D->setTopLevelDeclInObjCContainer(DeclBits & (1 << 5));
+ D->setAccess((AccessSpecifier)((DeclBits >> 6) & 0x3));
+ D->FromASTFile = true;
+ auto ModuleOwnership = (Decl::ModuleOwnershipKind)((DeclBits >> 8) & 0x7);
----------------
ChuanqiXu9 wrote:
Yes... and I feel the magic numbers for some types (e.g., `AccessSpecifier` and `ModuleOwnershipKind`) might not be so scaring. Since the devs can see `AccessSpecifier` and `ModuleOwnershipKind` here then they can get the size quickly. Also even if now we have to look at both ASTWriterDecl.cpp and ASTReaderDecl.cpp to change anything. I mean, it is already tightly bounded.
https://github.com/llvm/llvm-project/pull/69287
More information about the cfe-commits
mailing list