From: Chandler Carruth Date: Fri, 1 Apr 2011 02:03:23 +0000 (+0000) Subject: Fix an error in TreeTransform where we failed to copy the TemplateName's X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a35d5d7700b519d713039afd31477e95e2da7aa7;p=clang Fix an error in TreeTransform where we failed to copy the TemplateName's location into a TemplateSpecializationTypeLoc. These were found using a hand-written program to inspect every source location in TemplateSpecializationTypeLocs and Valgrind. I don't know of any way to test them in Clang's existing test suite sadly. Example code that triggers the ElaboratedType case: template struct X1 { template struct X1_1 { int x; }; }; template struct X2 { typename X1::template X1_1 B; }; X2 x2; The other fix was simply spotted by inspection. I audited all constructions of [Dependent]TemplateSpecializationTypeLocs in TreeTransform.h, and the rest set the TemplateNameLoc properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128702 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index bd28991e4b..74e918bf86 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -4521,6 +4521,7 @@ TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, // Copy information relevant to the template specialization. TemplateSpecializationTypeLoc NamedTL = TLB.push(NamedT); + NamedTL.setTemplateNameLoc(TL.getNameLoc()); NamedTL.setLAngleLoc(TL.getLAngleLoc()); NamedTL.setRAngleLoc(TL.getRAngleLoc()); for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I) @@ -4535,14 +4536,15 @@ TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, = TLB.push(Result); SpecTL.setKeywordLoc(TL.getKeywordLoc()); SpecTL.setQualifierLoc(QualifierLoc); + SpecTL.setNameLoc(TL.getNameLoc()); SpecTL.setLAngleLoc(TL.getLAngleLoc()); SpecTL.setRAngleLoc(TL.getRAngleLoc()); - SpecTL.setNameLoc(TL.getNameLoc()); for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I) SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); } else { TemplateSpecializationTypeLoc SpecTL = TLB.push(Result); + SpecTL.setTemplateNameLoc(TL.getNameLoc()); SpecTL.setLAngleLoc(TL.getLAngleLoc()); SpecTL.setRAngleLoc(TL.getRAngleLoc()); for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)