[cfe-commits] r141018 - in /cfe/trunk/lib: AST/DeclTemplate.cpp Sema/SemaTemplate.cpp Sema/SemaTemplateInstantiate.cpp
Abramo Bagnara
abramo.bagnara at gmail.com
Mon Oct 3 13:34:04 PDT 2011
Author: abramo
Date: Mon Oct 3 15:34:03 2011
New Revision: 141018
URL: http://llvm.org/viewvc/llvm-project?rev=141018&view=rev
Log:
Fixed source range for template implicit instantiations.
Modified:
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=141018&r1=141017&r2=141018&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Mon Oct 3 15:34:03 2011
@@ -656,15 +656,27 @@
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();
+ }
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=141018&r1=141017&r2=141018&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Oct 3 15:34:03 2011
@@ -2007,7 +2007,7 @@
Decl = ClassTemplateSpecializationDecl::Create(Context,
ClassTemplate->getTemplatedDecl()->getTagKind(),
ClassTemplate->getDeclContext(),
- ClassTemplate->getLocation(),
+ ClassTemplate->getTemplatedDecl()->getLocStart(),
ClassTemplate->getLocation(),
ClassTemplate,
Converted.data(),
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=141018&r1=141017&r2=141018&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Oct 3 15:34:03 2011
@@ -1818,6 +1818,9 @@
if (!FieldsWithMemberInitializers.empty())
ActOnFinishDelayedMemberInitializers(Instantiation);
+ if (TSK == TSK_ImplicitInstantiation)
+ Instantiation->setRBraceLoc(Pattern->getRBraceLoc());
+
if (Instantiation->isInvalidDecl())
Invalid = true;
else {
More information about the cfe-commits
mailing list