From 44f8c37e378f716e8cbb600e3800f437cf58f9e5 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 22 Jun 2010 09:54:59 +0000 Subject: [PATCH] -Introduce PCHReader::ReadTemplateArgumentLoc() -Introduce PCHWriter::AddTemplateArgumentLocInfo() -Modify PCHWriter::AddTemplateArgumentLoc() to also write TemplateArgumentLoc's TemplateArgument and move the existing calls of AddTemplateArgumentLoc() to AddTemplateArgumentLocInfo(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106533 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Frontend/PCHReader.h | 4 ++++ include/clang/Frontend/PCHWriter.h | 6 ++++++ lib/Frontend/PCHReader.cpp | 7 +++++++ lib/Frontend/PCHWriter.cpp | 24 +++++++++++++++++------- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h index 8139066c4b..0a002687b9 100644 --- a/include/clang/Frontend/PCHReader.h +++ b/include/clang/Frontend/PCHReader.h @@ -569,6 +569,10 @@ public: GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx); + /// \brief Reads a TemplateArgumentLoc. + TemplateArgumentLoc ReadTemplateArgumentLoc(const RecordData &Record, + unsigned &Idx); + /// \brief Reads a declarator info from the given record. TypeSourceInfo *GetTypeSourceInfo(const RecordData &Record, unsigned &Idx); diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h index 7e589f3321..264734d34e 100644 --- a/include/clang/Frontend/PCHWriter.h +++ b/include/clang/Frontend/PCHWriter.h @@ -17,6 +17,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclarationName.h" +#include "clang/AST/TemplateBase.h" #include "clang/Frontend/PCHBitCodes.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -299,6 +300,11 @@ public: /// \brief Emits a reference to a declarator info. void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record); + /// \brief Emits a template argument location info. + void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, + const TemplateArgumentLocInfo &Arg, + RecordData &Record); + /// \brief Emits a template argument location. void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg, RecordData &Record); diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index c8663bc702..b83445bc50 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -2509,6 +2509,13 @@ PCHReader::GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, return TemplateArgumentLocInfo(); } +TemplateArgumentLoc +PCHReader::ReadTemplateArgumentLoc(const RecordData &Record, unsigned &Index) { + TemplateArgument Arg = ReadTemplateArgument(Record, Index); + return TemplateArgumentLoc(Arg, GetTemplateArgumentLocInfo(Arg.getKind(), + Record, Index)); +} + Decl *PCHReader::GetExternalDecl(uint32_t ID) { return GetDecl(ID); } diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index a0bd9ec2a7..1fb90851b5 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -428,7 +428,8 @@ void TypeLocWriter::VisitTemplateSpecializationTypeLoc( Writer.AddSourceLocation(TL.getLAngleLoc(), Record); Writer.AddSourceLocation(TL.getRAngleLoc(), Record); for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) - Writer.AddTemplateArgumentLoc(TL.getArgLoc(i), Record); + Writer.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(), + TL.getArgLoc(i).getLocInfo(), Record); } void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { Writer.AddSourceLocation(TL.getKeywordLoc(), Record); @@ -450,7 +451,8 @@ void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc( Writer.AddSourceLocation(TL.getLAngleLoc(), Record); Writer.AddSourceLocation(TL.getRAngleLoc(), Record); for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) - Writer.AddTemplateArgumentLoc(TL.getArgLoc(I), Record); + Writer.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(), + TL.getArgLoc(I).getLocInfo(), Record); } void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); @@ -2284,14 +2286,15 @@ void PCHWriter::AddCXXTemporary(const CXXTemporary *Temp, RecordData &Record) { AddDeclRef(Temp->getDestructor(), Record); } -void PCHWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg, - RecordData &Record) { - switch (Arg.getArgument().getKind()) { +void PCHWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, + const TemplateArgumentLocInfo &Arg, + RecordData &Record) { + switch (Kind) { case TemplateArgument::Expression: - AddStmt(Arg.getLocInfo().getAsExpr()); + AddStmt(Arg.getAsExpr()); break; case TemplateArgument::Type: - AddTypeSourceInfo(Arg.getLocInfo().getAsTypeSourceInfo(), Record); + AddTypeSourceInfo(Arg.getAsTypeSourceInfo(), Record); break; case TemplateArgument::Template: Record.push_back( @@ -2307,6 +2310,13 @@ void PCHWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg, } } +void PCHWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg, + RecordData &Record) { + AddTemplateArgument(Arg.getArgument(), Record); + AddTemplateArgumentLocInfo(Arg.getArgument().getKind(), Arg.getLocInfo(), + Record); +} + void PCHWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record) { if (TInfo == 0) { AddTypeRef(QualType(), Record); -- 2.40.0