diff options
author | Bruno Ricci <riccibrun@gmail.com> | 2018-08-16 10:48:16 +0000 |
---|---|---|
committer | Bruno Ricci <riccibrun@gmail.com> | 2018-08-16 10:48:16 +0000 |
commit | d6bd5983eed46607448dc1901f94691ba241d4ac (patch) | |
tree | b626492bf65c048e48d970d1f3dcc396111e14e1 /clang/lib/AST/ASTContext.cpp | |
parent | 08672ecef9122d4aa1e96cada56e4ed8c7019908 (diff) | |
download | bcm5719-llvm-d6bd5983eed46607448dc1901f94691ba241d4ac.tar.gz bcm5719-llvm-d6bd5983eed46607448dc1901f94691ba241d4ac.zip |
[AST] Store the OwnedTagDecl as a trailing object in ElaboratedType.
The TagDecl *OwnedTagDecl in ElaboratedType is quite commonly
null (at least when parsing all of Boost, it is non-null for only about 600
of the 66k ElaboratedType). Therefore we can save a pointer in the
common case by storing it as a trailing object, and storing a bit in the
bit-fields of Type indicating when the pointer is null.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D50715
llvm-svn: 339862
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 91e9f3ed873..0a40ee5de9d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4136,8 +4136,10 @@ QualType ASTContext::getElaboratedType(ElaboratedTypeKeyword Keyword, (void)CheckT; } - T = new (*this, TypeAlignment) - ElaboratedType(Keyword, NNS, NamedType, Canon, OwnedTagDecl); + void *Mem = Allocate(ElaboratedType::totalSizeToAlloc<TagDecl *>(!!OwnedTagDecl), + TypeAlignment); + T = new (Mem) ElaboratedType(Keyword, NNS, NamedType, Canon, OwnedTagDecl); + Types.push_back(T); ElaboratedTypes.InsertNode(T, InsertPos); return QualType(T, 0); |