diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 31 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 32 |
3 files changed, 31 insertions, 34 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 8e1792bf1d..89b2263329 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3919,16 +3919,16 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig, if (OrigDC == CurContext) { Diag(Using->getLocation(), diag::err_using_decl_nested_name_specifier_is_current_class) - << Using->getNestedNameRange(); + << Using->getQualifierLoc().getSourceRange(); Diag(Orig->getLocation(), diag::note_using_decl_target); return true; } - Diag(Using->getNestedNameRange().getBegin(), + Diag(Using->getQualifierLoc().getBeginLoc(), diag::err_using_decl_nested_name_specifier_is_not_base_class) - << Using->getTargetNestedNameDecl() + << Using->getQualifier() << cast<CXXRecordDecl>(CurContext) - << Using->getNestedNameRange(); + << Using->getQualifierLoc().getSourceRange(); Diag(Orig->getLocation(), diag::note_using_decl_target); return true; } @@ -4134,8 +4134,6 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, LookupQualifiedName(Previous, CurContext); } - NestedNameSpecifier *NNS = SS.getScopeRep(); - // Check for invalid redeclarations. if (CheckUsingDeclRedeclaration(UsingLoc, IsTypeName, SS, IdentLoc, Previous)) return 0; @@ -4146,22 +4144,21 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, DeclContext *LookupContext = computeDeclContext(SS); NamedDecl *D; + NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context); if (!LookupContext) { if (IsTypeName) { // FIXME: not all declaration name kinds are legal here D = UnresolvedUsingTypenameDecl::Create(Context, CurContext, UsingLoc, TypenameLoc, - SS.getRange(), NNS, + QualifierLoc, IdentLoc, NameInfo.getName()); } else { - D = UnresolvedUsingValueDecl::Create(Context, CurContext, - UsingLoc, SS.getRange(), - NNS, NameInfo); + D = UnresolvedUsingValueDecl::Create(Context, CurContext, UsingLoc, + QualifierLoc, NameInfo); } } else { - D = UsingDecl::Create(Context, CurContext, - SS.getRange(), UsingLoc, NNS, NameInfo, - IsTypeName); + D = UsingDecl::Create(Context, CurContext, UsingLoc, QualifierLoc, + NameInfo, IsTypeName); } D->setAccess(AS); CurContext->addDecl(D); @@ -4252,7 +4249,7 @@ bool Sema::CheckInheritedConstructorUsingDecl(UsingDecl *UD) { return true; } - const Type *SourceType = UD->getTargetNestedNameDecl()->getAsType(); + const Type *SourceType = UD->getQualifier()->getAsType(); assert(SourceType && "Using decl naming constructor doesn't have type in scope spec."); CXXRecordDecl *TargetClass = cast<CXXRecordDecl>(CurContext); @@ -4309,15 +4306,15 @@ bool Sema::CheckUsingDeclRedeclaration(SourceLocation UsingLoc, NestedNameSpecifier *DQual; if (UsingDecl *UD = dyn_cast<UsingDecl>(D)) { DTypename = UD->isTypeName(); - DQual = UD->getTargetNestedNameDecl(); + DQual = UD->getQualifier(); } else if (UnresolvedUsingValueDecl *UD = dyn_cast<UnresolvedUsingValueDecl>(D)) { DTypename = false; - DQual = UD->getTargetNestedNameSpecifier(); + DQual = UD->getQualifier(); } else if (UnresolvedUsingTypenameDecl *UD = dyn_cast<UnresolvedUsingTypenameDecl>(D)) { DTypename = true; - DQual = UD->getTargetNestedNameSpecifier(); + DQual = UD->getQualifier(); } else continue; // using decls differ if one says 'typename' and the other doesn't. diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 474a18df7f..8f7b7da6f3 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -6036,7 +6036,7 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, << Name << Ctx << FullRange; if (UnresolvedUsingValueDecl *Using = dyn_cast<UnresolvedUsingValueDecl>(Result.getRepresentativeDecl())){ - SourceLocation Loc = Using->getTargetNestedNameRange().getBegin(); + SourceLocation Loc = Using->getQualifierLoc().getBeginLoc(); Diag(Loc, diag::note_using_value_decl_missing_typename) << FixItHint::CreateInsertion(Loc, "typename "); } diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index de4cd46e7a..e1a7065197 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1661,12 +1661,12 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) { // template struct t<int>; // Here, in using s1::f1, s1 refers to t<T>::s1; // we need to substitute for t<int>::s1. - NestedNameSpecifier *NNS = - SemaRef.SubstNestedNameSpecifier(D->getTargetNestedNameDecl(), - D->getNestedNameRange(), - TemplateArgs); + NestedNameSpecifier *NNS + = SemaRef.SubstNestedNameSpecifier(D->getQualifier(), + D->getQualifierRange(), + TemplateArgs); if (!NNS) - return 0; + return 0; // The name info is non-dependent, so no transformation // is required. @@ -1680,16 +1680,18 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) { LookupResult Prev(SemaRef, NameInfo, Sema::LookupUsingDeclName, Sema::ForRedeclaration); + CXXScopeSpec SS; + if (NNS == D->getQualifier()) + SS.Adopt(D->getQualifierLoc()); + else + SS.MakeTrivial(SemaRef.Context, NNS, D->getQualifierRange()); + UsingDecl *NewUD = UsingDecl::Create(SemaRef.Context, Owner, - D->getNestedNameRange(), D->getUsingLocation(), - NNS, + SS.getWithLocInContext(SemaRef.Context), NameInfo, D->isTypeName()); - CXXScopeSpec SS; - SS.MakeTrivial(SemaRef.Context, NNS, D->getNestedNameRange()); - if (CheckRedeclaration) { Prev.setHideTags(false); SemaRef.LookupQualifiedName(Prev, Owner); @@ -1749,14 +1751,13 @@ Decl *TemplateDeclInstantiator::VisitUsingShadowDecl(UsingShadowDecl *D) { Decl * TemplateDeclInstantiator ::VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) { NestedNameSpecifier *NNS = - SemaRef.SubstNestedNameSpecifier(D->getTargetNestedNameSpecifier(), - D->getTargetNestedNameRange(), + SemaRef.SubstNestedNameSpecifier(D->getQualifier(), D->getQualifierRange(), TemplateArgs); if (!NNS) return 0; CXXScopeSpec SS; - SS.MakeTrivial(SemaRef.Context, NNS, D->getTargetNestedNameRange()); + SS.MakeTrivial(SemaRef.Context, NNS, D->getQualifierRange()); // Since NameInfo refers to a typename, it cannot be a C++ special name. // Hence, no tranformation is required for it. @@ -1775,14 +1776,13 @@ Decl * TemplateDeclInstantiator Decl * TemplateDeclInstantiator ::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { NestedNameSpecifier *NNS = - SemaRef.SubstNestedNameSpecifier(D->getTargetNestedNameSpecifier(), - D->getTargetNestedNameRange(), + SemaRef.SubstNestedNameSpecifier(D->getQualifier(), D->getQualifierRange(), TemplateArgs); if (!NNS) return 0; CXXScopeSpec SS; - SS.MakeTrivial(SemaRef.Context, NNS, D->getTargetNestedNameRange()); + SS.MakeTrivial(SemaRef.Context, NNS, D->getQualifierRange()); DeclarationNameInfo NameInfo = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs); |