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 | 33f352ca62f608b71497b1a89015a2149cf16b0f (patch) | |
tree | 2a49ed471c3b4cd9c98d4347c9c2abc829acdb06 /clang/lib/Sema | |
parent | 521eb7c11e2d9800a9f00ddbf3b1a225b1e407ac (diff) | |
download | bcm5719-llvm-33f352ca62f608b71497b1a89015a2149cf16b0f.tar.gz bcm5719-llvm-33f352ca62f608b71497b1a89015a2149cf16b0f.zip |
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.
llvm-svn: 128208
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/IdentifierResolver.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/clang/lib/Sema/IdentifierResolver.cpp b/clang/lib/Sema/IdentifierResolver.cpp index d520a6edabf..95420a316ad 100644 --- a/clang/lib/Sema/IdentifierResolver.cpp +++ b/clang/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); |