diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-06 16:59:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-06 16:59:53 +0000 |
commit | 46cd2186bddc3e046140cb2d56932ee7faf7e3ae (patch) | |
tree | e633e03a03c45dba3caeaecd731f74040cbd3453 /lib/AST/DeclBase.cpp | |
parent | b4e85ed51905fc94378d7b4ff62b06e0d08042b7 (diff) |
Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bits
into the two unused lower bits of the NextDeclInContext link, dropping
the number of bits in Decl down to 32, and saving 8 bytes per
declaration on x86-64.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 4dc5bb7e85..3fc507ebdb 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -853,7 +853,7 @@ DeclContext *DeclContext::getNextContext() { std::pair<Decl *, Decl *> DeclContext::BuildDeclChain(const SmallVectorImpl<Decl*> &Decls, bool FieldsAlreadyLoaded) { - // Build up a chain of declarations via the Decl::NextDeclInContext field. + // Build up a chain of declarations via the Decl::NextInContextAndBits field. Decl *FirstNewDecl = 0; Decl *PrevDecl = 0; for (unsigned I = 0, N = Decls.size(); I != N; ++I) { @@ -862,7 +862,7 @@ DeclContext::BuildDeclChain(const SmallVectorImpl<Decl*> &Decls, Decl *D = Decls[I]; if (PrevDecl) - PrevDecl->NextDeclInContext = D; + PrevDecl->NextInContextAndBits.setPointer(D); else FirstNewDecl = D; @@ -908,7 +908,7 @@ DeclContext::LoadLexicalDeclsFromExternalStorage() const { Decl *ExternalFirst, *ExternalLast; llvm::tie(ExternalFirst, ExternalLast) = BuildDeclChain(Decls, FieldsAlreadyLoaded); - ExternalLast->NextDeclInContext = FirstDecl; + ExternalLast->NextInContextAndBits.setPointer(FirstDecl); FirstDecl = ExternalFirst; if (!LastDecl) LastDecl = ExternalLast; @@ -983,7 +983,7 @@ bool DeclContext::decls_empty() const { void DeclContext::removeDecl(Decl *D) { assert(D->getLexicalDeclContext() == this && "decl being removed from non-lexical context"); - assert((D->NextDeclInContext || D == LastDecl) && + assert((D->NextInContextAndBits.getPointer() || D == LastDecl) && "decl is not in decls list"); // Remove D from the decl chain. This is O(n) but hopefully rare. @@ -991,12 +991,12 @@ void DeclContext::removeDecl(Decl *D) { if (D == LastDecl) FirstDecl = LastDecl = 0; else - FirstDecl = D->NextDeclInContext; + FirstDecl = D->NextInContextAndBits.getPointer(); } else { - for (Decl *I = FirstDecl; true; I = I->NextDeclInContext) { + for (Decl *I = FirstDecl; true; I = I->NextInContextAndBits.getPointer()) { assert(I && "decl not found in linked list"); - if (I->NextDeclInContext == D) { - I->NextDeclInContext = D->NextDeclInContext; + if (I->NextInContextAndBits.getPointer() == D) { + I->NextInContextAndBits.setPointer(D->NextInContextAndBits.getPointer()); if (D == LastDecl) LastDecl = I; break; } @@ -1004,7 +1004,7 @@ void DeclContext::removeDecl(Decl *D) { } // Mark that D is no longer in the decl chain. - D->NextDeclInContext = 0; + D->NextInContextAndBits.setPointer(0); // Remove D from the lookup table if necessary. if (isa<NamedDecl>(D)) { @@ -1030,7 +1030,7 @@ void DeclContext::addHiddenDecl(Decl *D) { "Decl already inserted into a DeclContext"); if (FirstDecl) { - LastDecl->NextDeclInContext = D; + LastDecl->NextInContextAndBits.setPointer(D); LastDecl = D; } else { FirstDecl = LastDecl = D; |