aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-09 17:30:44 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-09 17:30:44 +0000
commitc6c8e0ec96bb64f1b9f543d7c8317c6090f80a30 (patch)
tree39aea2b30aebc4a42f967293a8e28181ab8fc20e /lib/AST/DeclBase.cpp
parentc02d62f0b82c144f7db2a71c3b4565de8c6163e5 (diff)
Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the merged DeclContexts as well as the (now-primary) DeclContext. This supports the common case where two different modules put something into the same namespace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 0312cfbc4a..6a508dfcbe 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -45,14 +45,17 @@ void *Decl::AllocateDeserializedDecl(const ASTContext &Context,
unsigned ID,
unsigned Size) {
// 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.
+ // resulting pointer will still be 8-byte aligned.
void *Start = Context.Allocate(Size + 8);
void *Result = (char*)Start + 8;
- // Store the global declaration ID
- unsigned *IDPtr = (unsigned*)Result - 1;
- *IDPtr = ID;
+ unsigned *PrefixPtr = (unsigned *)Result - 2;
+
+ // Zero out the first 4 bytes; this is used to store the owning module ID.
+ PrefixPtr[0] = 0;
+
+ // Store the global declaration ID in the second 4 bytes.
+ PrefixPtr[1] = ID;
return Result;
}