diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/IdentifierResolver.cpp | 32 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 8 |
2 files changed, 17 insertions, 23 deletions
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index fcfc05380b..d520a6edab 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -168,36 +168,26 @@ void IdentifierResolver::AddDecl(NamedDecl *D) { IDI->AddDecl(D); } -void IdentifierResolver::InsertDecl(iterator Pos, NamedDecl *D) { - if (Pos == iterator()) { - // Simple case: insert at the beginning of the list (which is the - // end of the stored vector). - AddDecl(D); - return; - } - +void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) { DeclarationName Name = D->getDeclName(); void *Ptr = Name.getFETokenInfo<void>(); - if (isDeclPtr(Ptr)) { - // There's only one element, and we want to insert before it in the list. - // Just create the storage for these identifiers and insert them in the - // opposite order we normally would. - assert(isDeclPtr(Ptr) && "Not a single declaration!"); - Name.setFETokenInfo(NULL); - IdDeclInfo *IDI = &(*IdDeclInfos)[Name]; - NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr); - IDI->AddDecl(D); - IDI->AddDecl(PrevD); + if (Pos == iterator() || isDeclPtr(Ptr)) { + // Simple case: insert at the end of the list (which is the + // end of the stored vector). + AddDecl(D); return; } + if (IdentifierInfo *II = Name.getAsIdentifierInfo()) + II->setIsFromAST(false); + // General case: insert the declaration at the appropriate point in the // list, which already has at least two elements. IdDeclInfo *IDI = toIdDeclInfo(Ptr); - if (Pos.isIterator()) - IDI->InsertDecl(Pos.getIterator(), D); - else + if (Pos.isIterator()) { + IDI->InsertDecl(Pos.getIterator() + 1, D); + } else IDI->InsertDecl(IDI->decls_begin(), D); } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 19d96f2ec0..65a372850f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -500,11 +500,15 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // isn't strictly lexical, which breaks name lookup. Be careful to insert // the label at the appropriate place in the identifier chain. for (I = IdResolver.begin(D->getDeclName()); I != IEnd; ++I) { - if ((*I)->getLexicalDeclContext()->Encloses(CurContext)) + DeclContext *IDC = (*I)->getLexicalDeclContext(); + if (IDC == CurContext) { + if (!S->isDeclScope(*I)) + continue; + } else if (IDC->Encloses(CurContext)) break; } - IdResolver.InsertDecl(I, D); + IdResolver.InsertDeclAfter(I, D); } else { IdResolver.AddDecl(D); } |