aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-05 23:49:36 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-05 23:49:36 +0000
commit5d1f496f86305b4738d465031a517b5be49f9ebd (patch)
tree11f4fedbe974f9eb5dff8eeedc785baf2ba7e921 /lib/AST/DeclBase.cpp
parent71207fc0470e1eee40a2951cd5cc3ff47725b755 (diff)
Always allocate an extra 8 bytes for a deserialized declaration, since
some code in Clang expects 8-byte alignment of declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index f4e5d43ee6..4dc5bb7e85 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -44,14 +44,11 @@ static bool StatSwitch = false;
void *Decl::AllocateDeserializedDecl(const ASTContext &Context,
unsigned ID,
unsigned Size) {
- // Allocate an extra pointer's worth of storage, which ensures that
- // (1) We have enough storage to stash the global declaration ID, and
- // (2) We maintain pointer alignment.
- //
- // Note that this wastes 4 bytes on x86-64, which we'll undoubtedly end up
- // finding a use for later.
- void *Start = Context.Allocate(Size + sizeof(void*));
- void *Result = (char*)Start + sizeof(void*);
+ // Allocate an extra 8 bytes worth of storage, which ensures that the
+ // resulting pointer will still be 8-byte aligned. At present, we're only
+ // using the latter 4 bytes of this storage.
+ void *Start = Context.Allocate(Size + 8);
+ void *Result = (char*)Start + 8;
// Store the global declaration ID
unsigned *IDPtr = (unsigned*)Result - 1;