]> granicus.if.org Git - clang/commitdiff
Kill off one of the TreeTransform::TransformTypeInObjectScope()
authorDouglas Gregor <dgregor@apple.com>
Wed, 2 Mar 2011 18:32:08 +0000 (18:32 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 2 Mar 2011 18:32:08 +0000 (18:32 +0000)
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

lib/Sema/TreeTransform.h

index f11f1ef0524e4170a5ef538c7ab7dd5d7da135a3..31a4bec23322d86d1db2dfe5447b4c084a11b76b 100644 (file)
@@ -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<typename Derived>
@@ -2540,13 +2535,20 @@ TreeTransform<Derived>::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<Derived>::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<typename Derived>
-QualType
-TreeTransform<Derived>::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<typename Derived>
-TypeSourceInfo *
-TreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSI,
+TypeLoc
+TreeTransform<Derived>::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<TemplateSpecializationType>(T)) {
-    TemplateSpecializationTypeLoc TL
-      = cast<TemplateSpecializationTypeLoc>(TSI->getTypeLoc());
-
+    TemplateSpecializationTypeLoc SpecTL
+      = cast<TemplateSpecializationTypeLoc>(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<DependentTemplateSpecializationType>(T)) {
-    DependentTemplateSpecializationTypeLoc TL
-      = cast<DependentTemplateSpecializationTypeLoc>(TSI->getTypeLoc());
-
-    TemplateName Template
-      = SemaRef.Context.getDependentTemplateName(
-                                                TL.getTypePtr()->getQualifier(),
-                                              TL.getTypePtr()->getIdentifier());
+    DependentTemplateSpecializationTypeLoc SpecTL
+      = cast<DependentTemplateSpecializationTypeLoc>(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<typename Derived>
-TypeLoc
-TreeTransform<Derived>::TransformTypeInObjectScope(TypeLoc TL,
+TypeSourceInfo *
+TreeTransform<Derived>::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<TemplateSpecializationType>(T)) {
     TemplateSpecializationTypeLoc SpecTL
       = cast<TemplateSpecializationTypeLoc>(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<Derived>::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 <class TyLoc> static inline
@@ -6912,8 +6887,7 @@ TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
   if (E->getDestroyedTypeInfo()) {
     TypeSourceInfo *DestroyedTypeInfo
       = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
-                                                ObjectType, 0, 
-                                        QualifierLoc.getNestedNameSpecifier());
+                                                ObjectType, 0, SS);
     if (!DestroyedTypeInfo)
       return ExprError();
     Destroyed = DestroyedTypeInfo;