From: Abramo Bagnara Date: Tue, 10 Aug 2010 13:46:45 +0000 (+0000) Subject: Fixed redundant NNS loading. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22f638a58ed05579c51ee6a35a1d16a7c2157f90;p=clang Fixed redundant NNS loading. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110677 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 1c324b8a02..ee3f8b5487 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -5256,8 +5256,6 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, TypeSourceInfo *InnerTSI = 0; QualType T = GetTypeFromParser(Ty, &InnerTSI); - NestedNameSpecifier *NNS - = static_cast(SS.getScopeRep()); assert(isa(T) && "Expected a template specialization type"); @@ -5274,7 +5272,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, else Builder.push(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(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(SS.getScopeRep())); + T = Context.getDependentTemplateSpecializationType(ETK_Typename, + DTN->getQualifier(), DTN->getIdentifier(), TST->getNumArgs(), TST->getArgs()); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index b3df9eb436..4d10fd030b 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -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 { diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index a61768bcf4..1ff6d5335d 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -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.