forked from OSchip/llvm-project
-Introduce PCHReader::ReadTemplateArgumentLoc()
-Introduce PCHWriter::AddTemplateArgumentLocInfo() -Modify PCHWriter::AddTemplateArgumentLoc() to also write TemplateArgumentLoc's TemplateArgument and move the existing calls of AddTemplateArgumentLoc() to AddTemplateArgumentLocInfo(). llvm-svn: 106533
This commit is contained in:
parent
cb6f346873
commit
ae85e2414c
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue