]> granicus.if.org Git - clang/commitdiff
Fixed redundant NNS loading.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Tue, 10 Aug 2010 13:46:45 +0000 (13:46 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Tue, 10 Aug 2010 13:46:45 +0000 (13:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110677 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
lib/Sema/SemaType.cpp
lib/Sema/TreeTransform.h

index 1c324b8a023fffd0fa3d744003ae5bd61c6b61ad..ee3f8b5487aacaac6820b5c9288ac75646a0f02a 100644 (file)
@@ -5256,8 +5256,6 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
   
   TypeSourceInfo *InnerTSI = 0;
   QualType T = GetTypeFromParser(Ty, &InnerTSI);
-  NestedNameSpecifier *NNS
-    = static_cast<NestedNameSpecifier *>(SS.getScopeRep());
 
   assert(isa<TemplateSpecializationType>(T) && 
          "Expected a template specialization type");
@@ -5274,7 +5272,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
     else
       Builder.push<TemplateSpecializationTypeLoc>(T).initialize(TemplateLoc);
 
-    T = Context.getElaboratedType(ETK_Typename, NNS, T);
+    /* Note: NNS already embedded in template specialization type T. */
+    T = Context.getElaboratedType(ETK_Typename, /*NNS=*/0, T);
     ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T);
     TL.setKeywordLoc(TypenameLoc);
     TL.setQualifierRange(SS.getRange());
@@ -5289,7 +5288,10 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
   DependentTemplateName *DTN =
     TST->getTemplateName().getAsDependentTemplateName();
   assert(DTN && "dependent template has non-dependent name?");
-  T = Context.getDependentTemplateSpecializationType(ETK_Typename, NNS,
+  assert(DTN->getQualifier()
+         == static_cast<NestedNameSpecifier*>(SS.getScopeRep()));
+  T = Context.getDependentTemplateSpecializationType(ETK_Typename,
+                                                     DTN->getQualifier(),
                                                      DTN->getIdentifier(),
                                                      TST->getNumArgs(),
                                                      TST->getArgs());
index b3df9eb43665b34ae8993321130f2b3eff5edf87..4d10fd030b1696c115460e4291f090f64d5a2f69 100644 (file)
@@ -1317,9 +1317,9 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
             
         case NestedNameSpecifier::TypeSpec:
         case NestedNameSpecifier::TypeSpecWithTemplate:
+          // Note: NNSPrefix (if any) is included in ClsType
+          // (hence, no need to wrap ClsType in an elaborated type).
           ClsType = QualType(NNS->getAsType(), 0);
-          if (NNSPrefix)
-            ClsType = Context.getElaboratedType(ETK_None, NNSPrefix, ClsType);
           break;
         }
       } else {
index a61768bcf432e621fe8287fb87ed3d7fd225cf65..1ff6d5335d1be77f44c8455b27f3daa92ca3b53f 100644 (file)
@@ -559,7 +559,8 @@ public:
       getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
     if (T.isNull()) return QualType();
 
-    return SemaRef.Context.getElaboratedType(Keyword, NNS, T);
+    // NOTE: NNS is already recorded in template specialization type T.
+    return SemaRef.Context.getElaboratedType(Keyword, /*NNS=*/0, T);
   }
 
   /// \brief Build a new typename type that refers to an identifier.