diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-09 23:41:00 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-09 23:41:00 +0000 |
commit | 5239304ff761b8b03eefb772bd5d830a9b9f1aea (patch) | |
tree | 53033fe5ea5d74e5ba0656a854938755a05018ef /lib/AST/DeclSerialization.cpp | |
parent | 0f84a23cc542a76f97aee735cdf3ff948b149879 (diff) |
Introduce ScopedDecl::getLexicalDeclContext() which is different from ScopedDecl::getDeclContext() when there are nested-names.
e.g.:
namespace A {
void f(); // SemanticDC (getDeclContext) == LexicalDC (getLexicalDeclContext) == 'namespace A'
}
void A::f(); // SemanticDC == namespace 'A'
// LexicalDC == global namespace
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58948 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclSerialization.cpp')
-rw-r--r-- | lib/AST/DeclSerialization.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp index 34066a5039..04cb71983b 100644 --- a/lib/AST/DeclSerialization.cpp +++ b/lib/AST/DeclSerialization.cpp @@ -145,15 +145,31 @@ void ScopedDecl::EmitInRec(Serializer& S) const { NamedDecl::EmitInRec(S); S.EmitPtr(getNext()); // From ScopedDecl. S.EmitPtr(cast_or_null<Decl>(getDeclContext())); // From ScopedDecl. + S.EmitPtr(cast_or_null<Decl>(getLexicalDeclContext())); // From ScopedDecl. } void ScopedDecl::ReadInRec(Deserializer& D, ASTContext& C) { NamedDecl::ReadInRec(D, C); D.ReadPtr(Next); // From ScopedDecl. - - assert(DeclCtx == 0); // Allow back-patching. Observe that we register - D.ReadPtr(DeclCtx); // the variable of the *object* for back-patching. - // Its actual value will get filled in later. + + assert(DeclCtx == 0); + + const SerializedPtrID &SemaDCPtrID = D.ReadPtrID(); + const SerializedPtrID &LexicalDCPtrID = D.ReadPtrID(); + + if (SemaDCPtrID == LexicalDCPtrID) { + // Allow back-patching. Observe that we register the variable of the + // *object* for back-patching. Its actual value will get filled in later. + D.ReadUIntPtr(DeclCtx, SemaDCPtrID); + } + else { + MultipleDC *MDC = new MultipleDC(); + DeclCtx = reinterpret_cast<uintptr_t>(MDC) | 0x1; + // Allow back-patching. Observe that we register the variable of the + // *object* for back-patching. Its actual value will get filled in later. + D.ReadUIntPtr(reinterpret_cast<uintptr_t&>(MDC->SemanticDC), SemaDCPtrID); + D.ReadUIntPtr(reinterpret_cast<uintptr_t&>(MDC->LexicalDC), LexicalDCPtrID); + } } //===------------------------------------------------------------===// |