initializeImpl(*this, Loc);
}
+ /// \brief Initializes this by copying its information from another
+ /// TypeLoc of the same type.
+ void initializeFullCopy(TypeLoc Other) const {
+ initializeFullCopyImpl(*this, Other);
+ }
+
friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
}
private:
static void initializeImpl(TypeLoc TL, SourceLocation Loc);
+ static void initializeFullCopyImpl(TypeLoc TL, TypeLoc Other);
static TypeLoc getNextTypeLocImpl(TypeLoc TL);
static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
};
ASTTemplateArgsPtr TemplateArgs,
SourceLocation RAngleLoc);
- TypeResult ActOnTagTemplateIdType(TypeResult Type,
- TagUseKind TUK,
- TypeSpecifierType TagSpec,
- SourceLocation TagLoc);
+ TypeResult ActOnTagTemplateIdType(CXXScopeSpec &SS,
+ TypeResult Type,
+ TagUseKind TUK,
+ TypeSpecifierType TagSpec,
+ SourceLocation TagLoc);
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
LookupResult &R,
}
}
+/// \brief Initializes a type location by copying all its data from
+/// another type location of the same type.
+void TypeLoc::initializeFullCopyImpl(TypeLoc TL, TypeLoc Other) {
+ assert(TL.getType() == Other.getType() && "Must copy from same type");
+ memcpy(TL.getOpaqueData(), Other.getOpaqueData(), TL.getFullDataSize());
+}
+
SourceLocation TypeLoc::getBeginLoc() const {
TypeLoc Cur = *this;
while (true) {
TemplateArgsPtr,
TemplateId->RAngleLoc);
- TypeResult = Actions.ActOnTagTemplateIdType(TypeResult, TUK,
+ TypeResult = Actions.ActOnTagTemplateIdType(SS, TypeResult, TUK,
TagType, StartLoc);
} else {
// This is an explicit specialization or a class template
return CreateParsedType(Result, DI);
}
-TypeResult Sema::ActOnTagTemplateIdType(TypeResult TypeResult,
+TypeResult Sema::ActOnTagTemplateIdType(CXXScopeSpec &SS,
+ TypeResult TypeResult,
TagUseKind TUK,
TypeSpecifierType TagSpec,
SourceLocation TagLoc) {
if (TypeResult.isInvalid())
return ::TypeResult();
- // FIXME: preserve source info, ideally without copying the DI.
TypeSourceInfo *DI;
QualType Type = GetTypeFromParser(TypeResult.get(), &DI);
= TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
QualType ElabType = Context.getElaboratedType(Keyword, /*NNS=*/0, Type);
- return ParsedType::make(ElabType);
+ TypeSourceInfo *ElabDI = Context.CreateTypeSourceInfo(ElabType);
+ ElaboratedTypeLoc TL = cast<ElaboratedTypeLoc>(ElabDI->getTypeLoc());
+ TL.setKeywordLoc(TagLoc);
+ TL.setQualifierRange(SS.getRange());
+ TL.getNamedTypeLoc().initializeFullCopy(DI->getTypeLoc());
+ return CreateParsedType(ElabType, ElabDI);
}
ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,