From: Douglas Gregor Date: Wed, 2 Mar 2011 18:32:08 +0000 (+0000) Subject: Kill off one of the TreeTransform::TransformTypeInObjectScope() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b71d821d64af88749fc9860fd43a5164d8d819c8;p=clang Kill off one of the TreeTransform::TransformTypeInObjectScope() overloads (the one with the poor source-location information). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126851 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index f11f1ef052..31a4bec233 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -2309,20 +2309,15 @@ public: } private: - QualType TransformTypeInObjectScope(QualType T, - QualType ObjectType, - NamedDecl *FirstQualifierInScope, - NestedNameSpecifier *Prefix); - - TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *T, - QualType ObjectType, - NamedDecl *FirstQualifierInScope, - NestedNameSpecifier *Prefix); - TypeLoc TransformTypeInObjectScope(TypeLoc TL, QualType ObjectType, NamedDecl *FirstQualifierInScope, CXXScopeSpec &SS); + + TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo, + QualType ObjectType, + NamedDecl *FirstQualifierInScope, + CXXScopeSpec &SS); }; template @@ -2540,13 +2535,20 @@ TreeTransform::TransformNestedNameSpecifier(NestedNameSpecifier *NNS, case NestedNameSpecifier::TypeSpecWithTemplate: case NestedNameSpecifier::TypeSpec: { TemporaryBase Rebase(*this, Range.getBegin(), DeclarationName()); - QualType T = TransformTypeInObjectScope(QualType(NNS->getAsType(), 0), - ObjectType, - FirstQualifierInScope, - Prefix); - if (T.isNull()) + CXXScopeSpec SS; + SS.MakeTrivial(SemaRef.Context, Prefix, Range); + + TypeSourceInfo *TSInfo + = SemaRef.Context.getTrivialTypeSourceInfo(QualType(NNS->getAsType(), 0), + Range.getEnd()); + TSInfo = TransformTypeInObjectScope(TSInfo, + ObjectType, + FirstQualifierInScope, + SS); + if (!TSInfo) return 0; + QualType T = TSInfo->getType(); if (!getDerived().AlwaysRebuild() && Prefix == NNS->getPrefix() && T == QualType(NNS->getAsType(), 0)) @@ -3332,113 +3334,86 @@ TreeTransform::TransformQualifiedType(TypeLocBuilder &TLB, return Result; } -/// \brief Transforms a type that was written in a scope specifier, -/// given an object type, the results of unqualified lookup, and -/// an already-instantiated prefix. -/// -/// The object type is provided iff the scope specifier qualifies the -/// member of a dependent member-access expression. The prefix is -/// provided iff the the scope specifier in which this appears has a -/// prefix. -/// -/// This is private to TreeTransform. -template -QualType -TreeTransform::TransformTypeInObjectScope(QualType T, - QualType ObjectType, - NamedDecl *UnqualLookup, - NestedNameSpecifier *Prefix) { - if (getDerived().AlreadyTransformed(T)) - return T; - - TypeSourceInfo *TSI = - SemaRef.Context.getTrivialTypeSourceInfo(T, getDerived().getBaseLocation()); - - TSI = getDerived().TransformTypeInObjectScope(TSI, ObjectType, - UnqualLookup, Prefix); - if (!TSI) return QualType(); - return TSI->getType(); -} - template -TypeSourceInfo * -TreeTransform::TransformTypeInObjectScope(TypeSourceInfo *TSI, +TypeLoc +TreeTransform::TransformTypeInObjectScope(TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup, - NestedNameSpecifier *Prefix) { - // TODO: in some cases, we might have some verification to do here. - if (ObjectType.isNull()) - return getDerived().TransformType(TSI); - - QualType T = TSI->getType(); + CXXScopeSpec &SS) { + QualType T = TL.getType(); if (getDerived().AlreadyTransformed(T)) - return TSI; - + return TL; + TypeLocBuilder TLB; QualType Result; - + if (isa(T)) { - TemplateSpecializationTypeLoc TL - = cast(TSI->getTypeLoc()); - + TemplateSpecializationTypeLoc SpecTL + = cast(TL); + TemplateName Template = - getDerived().TransformTemplateName(TL.getTypePtr()->getTemplateName(), + getDerived().TransformTemplateName(SS, + SpecTL.getTypePtr()->getTemplateName(), + SpecTL.getTemplateNameLoc(), ObjectType, UnqualLookup); - if (Template.isNull()) return 0; - - Result = getDerived() - .TransformTemplateSpecializationType(TLB, TL, Template); + if (Template.isNull()) + return TypeLoc(); + + Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL, + Template); } else if (isa(T)) { - DependentTemplateSpecializationTypeLoc TL - = cast(TSI->getTypeLoc()); - - TemplateName Template - = SemaRef.Context.getDependentTemplateName( - TL.getTypePtr()->getQualifier(), - TL.getTypePtr()->getIdentifier()); + DependentTemplateSpecializationTypeLoc SpecTL + = cast(TL); - Template = getDerived().TransformTemplateName(Template, ObjectType, - UnqualLookup); + TemplateName Template + = getDerived().RebuildTemplateName(SS, + *SpecTL.getTypePtr()->getIdentifier(), + SpecTL.getNameLoc(), + ObjectType, UnqualLookup); if (Template.isNull()) - return 0; - - Result = getDerived().TransformDependentTemplateSpecializationType(TLB, TL, + return TypeLoc(); + + Result = getDerived().TransformDependentTemplateSpecializationType(TLB, + SpecTL, Template); } else { // Nothing special needs to be done for these. - Result = getDerived().TransformType(TLB, TSI->getTypeLoc()); + Result = getDerived().TransformType(TLB, TL); } - - if (Result.isNull()) return 0; - return TLB.getTypeSourceInfo(SemaRef.Context, Result); + + if (Result.isNull()) + return TypeLoc(); + + return TLB.getTypeSourceInfo(SemaRef.Context, Result)->getTypeLoc(); } template -TypeLoc -TreeTransform::TransformTypeInObjectScope(TypeLoc TL, +TypeSourceInfo * +TreeTransform::TransformTypeInObjectScope(TypeSourceInfo *TSInfo, QualType ObjectType, NamedDecl *UnqualLookup, CXXScopeSpec &SS) { // FIXME: Painfully copy-paste from the above! - QualType T = TL.getType(); + QualType T = TSInfo->getType(); if (getDerived().AlreadyTransformed(T)) - return TL; + return TSInfo; TypeLocBuilder TLB; QualType Result; + TypeLoc TL = TSInfo->getTypeLoc(); if (isa(T)) { TemplateSpecializationTypeLoc SpecTL = cast(TL); - TemplateName Template = - getDerived().TransformTemplateName(SS, + TemplateName Template + = getDerived().TransformTemplateName(SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(), ObjectType, UnqualLookup); if (Template.isNull()) - return TypeLoc(); + return 0; Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL, Template); @@ -3452,20 +3427,20 @@ TreeTransform::TransformTypeInObjectScope(TypeLoc TL, SpecTL.getNameLoc(), ObjectType, UnqualLookup); if (Template.isNull()) - return TypeLoc(); + return 0; Result = getDerived().TransformDependentTemplateSpecializationType(TLB, SpecTL, - Template); + Template); } else { // Nothing special needs to be done for these. Result = getDerived().TransformType(TLB, TL); } if (Result.isNull()) - return TypeLoc(); + return 0; - return TLB.getTypeSourceInfo(SemaRef.Context, Result)->getTypeLoc(); + return TLB.getTypeSourceInfo(SemaRef.Context, Result); } template static inline @@ -6912,8 +6887,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( if (E->getDestroyedTypeInfo()) { TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(), - ObjectType, 0, - QualifierLoc.getNestedNameSpecifier()); + ObjectType, 0, SS); if (!DestroyedTypeInfo) return ExprError(); Destroyed = DestroyedTypeInfo;