[cfe-commits] [Request for approval] Redundant NNS and missing template keyword)
Abramo Bagnara
abramo.bagnara at gmail.com
Tue Aug 10 01:16:13 PDT 2010
Douglas Gregor wrote:
> On Jul 27, 2010, at 12:01 PM, Abramo Bagnara wrote:
>
>> Please find attached a couple of patches that are meant to fix the
>> problems shown by the following examples.
[...]
>> The first problem is due to the fact that the NNS is encoded *both* in
>> the ElaboratedType and in the underlying (dependent)
>> TemplateSpecializationType: this should be corrected in redundant-nns.patch
>
> In this patch, we have:
>
> Index: lib/Sema/SemaTemplate.cpp
> ===================================================================
> --- lib/Sema/SemaTemplate.cpp (revision 109367)
> +++ lib/Sema/SemaTemplate.cpp (working copy)
> @@ -5258,8 +5260,6 @@
>
> TypeSourceInfo *InnerTSI = 0;
> QualType T = GetTypeFromParser(Ty, &InnerTSI);
> - NestedNameSpecifier *NNS
> - = static_cast<NestedNameSpecifier *>(SS.getScopeRep());
>
> assert(isa<TemplateSpecializationType>(T) &&
> "Expected a template specialization type");
> @@ -5276,7 +5276,7 @@
> else
> Builder.push<TemplateSpecializationTypeLoc>(T).initialize(TemplateLoc);
>
> - T = Context.getElaboratedType(ETK_Typename, NNS, T);
> + T = Context.getElaboratedType(ETK_Typename, /*NNS=*/0, T);
> ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T);
> TL.setKeywordLoc(TypenameLoc);
> TL.setQualifierRange(SS.getRange());
>
> I think we only want to drop NNS when T is a TemplateSpecializationTypeLoc. Otherwise, we'll end up eliminating some syntactic sugar in the non-template-specialization case.
Here T is known to definitely be a TemplateSpecializationType.
see the assert a few lines above:
assert(isa<TemplateSpecializationType>(T) &&
"Expected a template specialization type");
Anyway, we managed to improve this patch: we found another occurrence of
the same problem in SemaType.cpp.
OK to commit?
Cheers,
Abramo.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: redundant-nns-2.patch
Type: text/x-patch
Size: 2929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100810/ac168e95/attachment.bin>
More information about the cfe-commits
mailing list