diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-24 10:35:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-24 10:35:39 +0000 |
commit | fa7b8ced6f3318879b39f44b5ace8346e979826e (patch) | |
tree | 3c5cc15f150f3a2f667e3c2a55c64dd23657e09f /lib/Sema/IdentifierResolver.cpp | |
parent | c285372e69f42d95ca638d74abd1f46bd7b77a96 (diff) |
Fix the insertion of label declarations into the identifier chain in
the case where we only have a single identifier with that name in the
chain. Fixes PR9463 for real this time.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128208 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/IdentifierResolver.cpp')
-rw-r--r-- | lib/Sema/IdentifierResolver.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp index d520a6edab..95420a316a 100644 --- a/lib/Sema/IdentifierResolver.cpp +++ b/lib/Sema/IdentifierResolver.cpp @@ -172,13 +172,28 @@ void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) { DeclarationName Name = D->getDeclName(); void *Ptr = Name.getFETokenInfo<void>(); - if (Pos == iterator() || isDeclPtr(Ptr)) { - // Simple case: insert at the end of the list (which is the - // end of the stored vector). + if (!Ptr) { AddDecl(D); return; } + if (isDeclPtr(Ptr)) { + // We only have a single declaration: insert before or after it, + // as appropriate. + if (Pos == iterator()) { + // Add the new declaration before the existing declaration. + NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr); + RemoveDecl(PrevD); + AddDecl(D); + AddDecl(PrevD); + } else { + // Add new declaration after the existing declaration. + AddDecl(D); + } + + return; + } + if (IdentifierInfo *II = Name.getAsIdentifierInfo()) II->setIsFromAST(false); |