diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-22 09:01:48 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-22 09:01:48 +0000 |
| commit | f798172419f4acf7c784373e97ed79ced98e1159 (patch) | |
| tree | f98bde80d6a5d5b3bc781fa128ad18a4b31cde82 /clang/lib/AST/DeclFriend.cpp | |
| parent | fe8ed4a5914afed12a7cff6e3f3ea65b39e2d909 (diff) | |
| download | bcm5719-llvm-f798172419f4acf7c784373e97ed79ced98e1159.tar.gz bcm5719-llvm-f798172419f4acf7c784373e97ed79ced98e1159.zip | |
Add class-specific operator new to Decl hierarchy. This guarantees that Decls
can't accidentally be allocated the wrong way (missing prefix data for decls
from AST files, for instance) and simplifies the CreateDeserialized functions a
little. An extra DeclContext* parameter to the not-from-AST-file operator new
allows us to ensure that we don't accidentally call the wrong one when
deserializing (when we don't have a DeclContext), allows some extra checks, and
prepares for some planned modules-related changes to Decl allocation.
No functionality change intended.
llvm-svn: 195426
Diffstat (limited to 'clang/lib/AST/DeclFriend.cpp')
| -rw-r--r-- | clang/lib/AST/DeclFriend.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/AST/DeclFriend.cpp b/clang/lib/AST/DeclFriend.cpp index 1c639d676dc..02374c78b8a 100644 --- a/clang/lib/AST/DeclFriend.cpp +++ b/clang/lib/AST/DeclFriend.cpp @@ -46,21 +46,17 @@ FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC, } #endif - std::size_t Size = sizeof(FriendDecl) - + FriendTypeTPLists.size() * sizeof(TemplateParameterList*); - void *Mem = C.Allocate(Size); - FriendDecl *FD = new (Mem) FriendDecl(DC, L, Friend, FriendL, - FriendTypeTPLists); + std::size_t Extra = FriendTypeTPLists.size() * sizeof(TemplateParameterList*); + FriendDecl *FD = new (C, DC, Extra) FriendDecl(DC, L, Friend, FriendL, + FriendTypeTPLists); cast<CXXRecordDecl>(DC)->pushFriendDecl(FD); return FD; } FriendDecl *FriendDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned FriendTypeNumTPLists) { - std::size_t Size = sizeof(FriendDecl) - + FriendTypeNumTPLists * sizeof(TemplateParameterList*); - void *Mem = AllocateDeserializedDecl(C, ID, Size); - return new (Mem) FriendDecl(EmptyShell(), FriendTypeNumTPLists); + std::size_t Extra = FriendTypeNumTPLists * sizeof(TemplateParameterList*); + return new (C, ID, Extra) FriendDecl(EmptyShell(), FriendTypeNumTPLists); } FriendDecl *CXXRecordDecl::getFirstFriend() const { |

