[cfe-commits] r128702 - /cfe/trunk/lib/Sema/TreeTransform.h
Douglas Gregor
dgregor at apple.com
Thu Apr 14 12:22:23 PDT 2011
On Mar 31, 2011, at 7:03 PM, Chandler Carruth wrote:
> Author: chandlerc
> Date: Thu Mar 31 21:03:23 2011
> New Revision: 128702
>
> URL: http://llvm.org/viewvc/llvm-project?rev=128702&view=rev
> Log:
> 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 <typename T> struct X1 {
> template <typename U> struct X1_1 {
> int x;
> };
> };
>
> template <typename T, typename U> struct X2 {
> typename X1<T>::template X1_1<U> B;
> };
>
> X2<char, int> 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.
Ugh. Thanks for tracking this down!
- Doug
> Modified:
> cfe/trunk/lib/Sema/TreeTransform.h
>
> Modified: cfe/trunk/lib/Sema/TreeTransform.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=128702&r1=128701&r2=128702&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
> +++ cfe/trunk/lib/Sema/TreeTransform.h Thu Mar 31 21:03:23 2011
> @@ -4521,6 +4521,7 @@
> // Copy information relevant to the template specialization.
> TemplateSpecializationTypeLoc NamedTL
> = TLB.push<TemplateSpecializationTypeLoc>(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 @@
> = TLB.push<DependentTemplateSpecializationTypeLoc>(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<TemplateSpecializationTypeLoc>(Result);
> + SpecTL.setTemplateNameLoc(TL.getNameLoc());
> SpecTL.setLAngleLoc(TL.getLAngleLoc());
> SpecTL.setRAngleLoc(TL.getRAngleLoc());
> for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list