[cfe-commits] r109755 - in /cfe/trunk: include/clang/AST/DeclTemplate.h lib/AST/DeclTemplate.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriterDecl.cpp
Peter Collingbourne
peter at pcc.me.uk
Thu Jul 29 09:12:01 PDT 2010
Author: pcc
Date: Thu Jul 29 11:12:01 2010
New Revision: 109755
URL: http://llvm.org/viewvc/llvm-project?rev=109755&view=rev
Log:
Store latest redeclaration for each redeclarable template declaration
This patch adds a Latest field to RedeclarableTemplateDecl's CommonBase
class which is used to store the latest redeclaration.
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=109755&r1=109754&r2=109755&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Jul 29 11:12:01 2010
@@ -492,10 +492,7 @@
RedeclarableTemplateDecl *getCanonicalDeclImpl();
- void setPreviousDeclarationImpl(RedeclarableTemplateDecl *Prev) {
- if (Prev)
- CommonOrPrev = Prev;
- }
+ void setPreviousDeclarationImpl(RedeclarableTemplateDecl *Prev);
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplateImpl() {
return getCommonPtr()->InstantiatedFromMember.getPointer();
@@ -517,6 +514,9 @@
/// was explicitly specialized.
llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
InstantiatedFromMember;
+
+ /// \brief The latest declaration of this template.
+ RedeclarableTemplateDecl *Latest;
};
/// \brief A pointer to the previous declaration (if this is a redeclaration)
@@ -602,6 +602,7 @@
}
friend class PCHDeclReader;
+ friend class PCHDeclWriter;
};
template <class decl_type>
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=109755&r1=109754&r2=109755&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Jul 29 11:12:01 2010
@@ -94,6 +94,7 @@
if (First->CommonOrPrev.isNull()) {
CommonBase *CommonPtr = First->newCommon();
First->CommonOrPrev = CommonPtr;
+ CommonPtr->Latest = First;
}
return First->CommonOrPrev.get<CommonBase*>();
}
@@ -106,6 +107,18 @@
return Tmpl;
}
+void RedeclarableTemplateDecl::setPreviousDeclarationImpl(
+ RedeclarableTemplateDecl *Prev) {
+ if (Prev) {
+ CommonBase *Common = Prev->getCommonPtr();
+ Prev = Common->Latest;
+ Common->Latest = this;
+ CommonOrPrev = Prev;
+ } else {
+ assert(CommonOrPrev.is<CommonBase*>() && "Cannot reset TemplateDecl Prev");
+ }
+}
+
//===----------------------------------------------------------------------===//
// FunctionTemplateDecl Implementation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=109755&r1=109754&r2=109755&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Thu Jul 29 11:12:01 2010
@@ -915,6 +915,11 @@
if (Record[Idx++])
D->setMemberSpecialization();
}
+
+ RedeclarableTemplateDecl *LatestDecl =
+ cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++]));
+ assert(LatestDecl->getKind() == D->getKind() && "Latest kind mismatch");
+ D->getCommonPtr()->Latest = LatestDecl;
}
}
Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=109755&r1=109754&r2=109755&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Thu Jul 29 11:12:01 2010
@@ -852,6 +852,8 @@
Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record);
if (D->getInstantiatedFromMemberTemplate())
Record.push_back(D->isMemberSpecialization());
+
+ Writer.AddDeclRef(D->getCommonPtr()->Latest, Record);
}
}
More information about the cfe-commits
mailing list