Fixed source range for template implicit instantiations.

llvm-svn: 141018
This commit is contained in:
Abramo Bagnara 2011-10-03 20:34:03 +00:00
parent a279d9bd6a
commit fd3a455ac7
3 changed files with 25 additions and 10 deletions

View File

@ -656,15 +656,27 @@ ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
SourceRange
ClassTemplateSpecializationDecl::getSourceRange() const {
if (!ExplicitInfo)
return SourceRange();
SourceLocation Begin = getExternLoc();
if (Begin.isInvalid())
Begin = getTemplateKeywordLoc();
SourceLocation End = getRBraceLoc();
if (End.isInvalid())
End = getTypeAsWritten()->getTypeLoc().getEndLoc();
return SourceRange(Begin, End);
if (ExplicitInfo) {
SourceLocation Begin = getExternLoc();
if (Begin.isInvalid())
Begin = getTemplateKeywordLoc();
SourceLocation End = getRBraceLoc();
if (End.isInvalid())
End = getTypeAsWritten()->getTypeLoc().getEndLoc();
return SourceRange(Begin, End);
}
else {
// No explicit info available.
llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
inst_from = getInstantiatedFrom();
if (inst_from.isNull())
return getSpecializedTemplate()->getSourceRange();
if (ClassTemplateDecl *ctd = inst_from.dyn_cast<ClassTemplateDecl*>())
return ctd->getSourceRange();
return inst_from.get<ClassTemplatePartialSpecializationDecl*>()
->getSourceRange();
}
}
//===----------------------------------------------------------------------===//

View File

@ -2007,7 +2007,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
Decl = ClassTemplateSpecializationDecl::Create(Context,
ClassTemplate->getTemplatedDecl()->getTagKind(),
ClassTemplate->getDeclContext(),
ClassTemplate->getLocation(),
ClassTemplate->getTemplatedDecl()->getLocStart(),
ClassTemplate->getLocation(),
ClassTemplate,
Converted.data(),

View File

@ -1818,6 +1818,9 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
if (!FieldsWithMemberInitializers.empty())
ActOnFinishDelayedMemberInitializers(Instantiation);
if (TSK == TSK_ImplicitInstantiation)
Instantiation->setRBraceLoc(Pattern->getRBraceLoc());
if (Instantiation->isInvalidDecl())
Invalid = true;
else {