diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-11-24 17:14:34 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-11-24 17:14:34 +0000 |
commit | 46408eedfff5aa33662cedb6716a20616f3bad31 (patch) | |
tree | 3ece8c5de5ce4d520ba30ba02a6773c2c4334c80 /include/clang/AST/Redeclarable.h | |
parent | d3d5301c44138b92bf01286183f5bf310cdd37cf (diff) | |
download | clang-46408eedfff5aa33662cedb6716a20616f3bad31.tar.gz |
Make sure redeclaration chains are properly linked, even through invalid decls. This fixes PR5415.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/Redeclarable.h')
-rw-r--r-- | include/clang/AST/Redeclarable.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/clang/AST/Redeclarable.h b/include/clang/AST/Redeclarable.h index 867932332d..35af8c766e 100644 --- a/include/clang/AST/Redeclarable.h +++ b/include/clang/AST/Redeclarable.h @@ -92,6 +92,11 @@ public: } /// \brief Returns the most recent (re)declaration of this declaration. + decl_type *getMostRecentDeclaration() { + return getFirstDeclaration()->RedeclLink.getNext(); + } + + /// \brief Returns the most recent (re)declaration of this declaration. const decl_type *getMostRecentDeclaration() const { return getFirstDeclaration()->RedeclLink.getNext(); } @@ -102,8 +107,11 @@ public: decl_type *First; if (PrevDecl) { - // Point to previous. - RedeclLink = PreviousDeclLink(PrevDecl); + // Point to previous. Make sure that this is actually the most recent + // redeclaration, or we can build invalid chains. If the most recent + // redeclaration is invalid, it won't be PrevDecl, but we want it anyway. + RedeclLink = PreviousDeclLink(cast<decl_type>( + PrevDecl->getMostRecentDeclaration())); First = PrevDecl->getFirstDeclaration(); assert(First->RedeclLink.NextIsLatest() && "Expected first"); } else { |