diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-04 21:44:00 +0000 | 
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-04 21:44:00 +0000 | 
| commit | cdb8b3f7ec3f3ab8e1b3db8da384f2444492e5b3 (patch) | |
| tree | 4208e890f691f8739b5e96e333707815d70a34fc /clang | |
| parent | 0bdaf64fd76e76df33beca1f5e66df8836012005 (diff) | |
| download | bcm5719-llvm-cdb8b3f7ec3f3ab8e1b3db8da384f2444492e5b3.tar.gz bcm5719-llvm-cdb8b3f7ec3f3ab8e1b3db8da384f2444492e5b3.zip  | |
Read/write specialization info of static data members for PCH.
llvm-svn: 107593
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/ASTContext.h | 3 | ||||
| -rw-r--r-- | clang/include/clang/AST/DeclTemplate.h | 5 | ||||
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Frontend/PCHReaderDecl.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Frontend/PCHWriterDecl.cpp | 13 | 
5 files changed, 28 insertions, 5 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 2b65f3155ea..0a6b6cd45e6 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -331,7 +331,8 @@ public:    /// \brief Note that the static data member \p Inst is an instantiation of    /// the static data member template \p Tmpl of a class template.    void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, -                                           TemplateSpecializationKind TSK); +                                           TemplateSpecializationKind TSK, +                        SourceLocation PointOfInstantiation = SourceLocation());    /// \brief If the given using decl is an instantiation of a    /// (possibly unresolved) using decl from a template instantiation, diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 84e755302af..9e6cf0c38fa 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -379,8 +379,9 @@ class MemberSpecializationInfo {  public:    explicit  -  MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK) -    : MemberAndTSK(IF, TSK - 1), PointOfInstantiation() { +  MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, +                           SourceLocation POI = SourceLocation()) +    : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {      assert(TSK != TSK_Undeclared &&              "Cannot encode undeclared template specializations for members");    } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 2d52bd08d55..f8f568cbb48 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -392,13 +392,14 @@ ASTContext::getInstantiatedFromStaticDataMember(const VarDecl *Var) {  void  ASTContext::setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, -                                                TemplateSpecializationKind TSK) { +                                                TemplateSpecializationKind TSK, +                                          SourceLocation PointOfInstantiation) {    assert(Inst->isStaticDataMember() && "Not a static data member");    assert(Tmpl->isStaticDataMember() && "Not a static data member");    assert(!InstantiatedFromStaticDataMember[Inst] &&           "Already noted what static data member was instantiated from");    InstantiatedFromStaticDataMember[Inst]  -    = new (*this) MemberSpecializationInfo(Tmpl, TSK); +    = new (*this) MemberSpecializationInfo(Tmpl, TSK, PointOfInstantiation);  }  NamedDecl * diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp index 9de002b0e6e..ab7485ce794 100644 --- a/clang/lib/Frontend/PCHReaderDecl.cpp +++ b/clang/lib/Frontend/PCHReaderDecl.cpp @@ -522,6 +522,13 @@ void PCHDeclReader::VisitVarDecl(VarDecl *VD) {                           cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));    if (Record[Idx++])      VD->setInit(Reader.ReadExpr()); + +  if (Record[Idx++]) { // HasMemberSpecializationInfo. +    VarDecl *Tmpl = cast<VarDecl>(Reader.GetDecl(Record[Idx++])); +    TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; +    SourceLocation POI = Reader.ReadSourceLocation(Record, Idx); +    Reader.getContext()->setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); +  }  }  void PCHDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { diff --git a/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp index 2383a75bd04..f5230233657 100644 --- a/clang/lib/Frontend/PCHWriterDecl.cpp +++ b/clang/lib/Frontend/PCHWriterDecl.cpp @@ -492,6 +492,16 @@ void PCHDeclWriter::VisitVarDecl(VarDecl *D) {    Record.push_back(D->getInit() ? 1 : 0);    if (D->getInit())      Writer.AddStmt(D->getInit()); + +  MemberSpecializationInfo *SpecInfo +    = D->isStaticDataMember() ? D->getMemberSpecializationInfo() : 0; +  Record.push_back(SpecInfo != 0); +  if (SpecInfo) { +    Writer.AddDeclRef(SpecInfo->getInstantiatedFrom(), Record); +    Record.push_back(SpecInfo->getTemplateSpecializationKind()); +    Writer.AddSourceLocation(SpecInfo->getPointOfInstantiation(), Record); +  } +    Code = pch::DECL_VAR;  } @@ -530,6 +540,8 @@ void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {    assert(!D->isDeclaredInCondition() && "PARM_VAR_DECL can't be in condition");    assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");    assert(D->getPreviousDeclaration() == 0 && "PARM_VAR_DECL can't be redecl"); +  assert(!D->isStaticDataMember() && +         "PARM_VAR_DECL can't be static data member");  }  void PCHDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { @@ -974,6 +986,7 @@ void PCHWriter::WriteDeclsBlockAbbrevs() {    Abv->Add(BitCodeAbbrevOp(0));                       // isNRVOVariable    Abv->Add(BitCodeAbbrevOp(0));                       // PrevDecl    Abv->Add(BitCodeAbbrevOp(0));                       // HasInit +  Abv->Add(BitCodeAbbrevOp(0));                   // HasMemberSpecializationInfo    // ParmVarDecl    Abv->Add(BitCodeAbbrevOp(0));                       // ObjCDeclQualifier    Abv->Add(BitCodeAbbrevOp(0));                       // HasInheritedDefaultArg  | 

