aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/DeclCXX.cpp15
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp10
-rw-r--r--lib/Sema/Sema.h3
-rw-r--r--lib/Sema/SemaDeclCXX.cpp28
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp22
5 files changed, 41 insertions, 37 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 75b355889d..eed3702e53 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -1010,10 +1010,11 @@ NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC,
}
UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, SourceRange NNR, SourceLocation UL,
- NestedNameSpecifier* TargetNNS, DeclarationName Name,
- bool IsTypeNameArg) {
- return new (C) UsingDecl(DC, L, NNR, UL, TargetNNS, Name, IsTypeNameArg);
+ SourceRange NNR, SourceLocation UL,
+ NestedNameSpecifier* TargetNNS,
+ const DeclarationNameInfo &NameInfo,
+ bool IsTypeNameArg) {
+ return new (C) UsingDecl(DC, NNR, UL, TargetNNS, NameInfo, IsTypeNameArg);
}
UnresolvedUsingValueDecl *
@@ -1021,11 +1022,9 @@ UnresolvedUsingValueDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation UsingLoc,
SourceRange TargetNNR,
NestedNameSpecifier *TargetNNS,
- SourceLocation TargetNameLoc,
- DeclarationName TargetName) {
+ const DeclarationNameInfo &NameInfo) {
return new (C) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc,
- TargetNNR, TargetNNS,
- TargetNameLoc, TargetName);
+ TargetNNR, TargetNNS, NameInfo);
}
UnresolvedUsingTypenameDecl *
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index cb18108cad..212eaa1332 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -626,6 +626,7 @@ void PCHDeclReader::VisitUsingDecl(UsingDecl *D) {
D->setUsingLocation(Reader.ReadSourceLocation(Record, Idx));
D->setNestedNameRange(Reader.ReadSourceRange(Record, Idx));
D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx));
+ // FIXME: read the DNLoc component.
// FIXME: It would probably be more efficient to read these into a vector
// and then re-cosntruct the shadow decl set over that vector since it
@@ -668,6 +669,7 @@ void PCHDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx));
D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx));
D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx));
+ // FIXME: read the DNLoc component.
}
void PCHDeclReader::VisitUnresolvedUsingTypenameDecl(
@@ -1378,8 +1380,8 @@ Decl *PCHReader::ReadDeclRecord(unsigned Index, pch::DeclID ID) {
SourceLocation(), 0);
break;
case pch::DECL_USING:
- D = UsingDecl::Create(*Context, 0, SourceLocation(), SourceRange(),
- SourceLocation(), 0, DeclarationName(), false);
+ D = UsingDecl::Create(*Context, 0, SourceRange(), SourceLocation(),
+ 0, DeclarationNameInfo(), false);
break;
case pch::DECL_USING_SHADOW:
D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0);
@@ -1391,8 +1393,8 @@ Decl *PCHReader::ReadDeclRecord(unsigned Index, pch::DeclID ID) {
break;
case pch::DECL_UNRESOLVED_USING_VALUE:
D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(),
- SourceRange(), 0, SourceLocation(),
- DeclarationName());
+ SourceRange(), 0,
+ DeclarationNameInfo());
break;
case pch::DECL_UNRESOLVED_USING_TYPENAME:
D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(),
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 31c7e0ef7c..ff3fc401ca 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -2248,8 +2248,7 @@ public:
NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
SourceLocation UsingLoc,
CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- DeclarationName Name,
+ const DeclarationNameInfo &NameInfo,
AttributeList *AttrList,
bool IsInstantiation,
bool IsTypeName,
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 4156df0772..c27ca913c0 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -3476,8 +3476,9 @@ Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,
<< SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc);
return DeclPtrTy();
}
-
- DeclarationName TargetName = GetNameFromUnqualifiedId(Name).getName();
+
+ DeclarationNameInfo TargetNameInfo = GetNameFromUnqualifiedId(Name);
+ DeclarationName TargetName = TargetNameInfo.getName();
if (!TargetName)
return DeclPtrTy();
@@ -3493,8 +3494,7 @@ Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,
}
NamedDecl *UD = BuildUsingDeclaration(S, AS, UsingLoc, SS,
- Name.getSourceRange().getBegin(),
- TargetName, AttrList,
+ TargetNameInfo, AttrList,
/* IsInstantiation */ false,
IsTypeName, TypenameLoc);
if (UD)
@@ -3743,13 +3743,13 @@ void Sema::HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow) {
NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
SourceLocation UsingLoc,
CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- DeclarationName Name,
+ const DeclarationNameInfo &NameInfo,
AttributeList *AttrList,
bool IsInstantiation,
bool IsTypeName,
SourceLocation TypenameLoc) {
assert(!SS.isInvalid() && "Invalid CXXScopeSpec.");
+ SourceLocation IdentLoc = NameInfo.getLoc();
assert(IdentLoc.isValid() && "Invalid TargetName location.");
// FIXME: We ignore attributes for now.
@@ -3761,7 +3761,7 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
}
// Do the redeclaration lookup in the current scope.
- LookupResult Previous(*this, Name, IdentLoc, LookupUsingDeclName,
+ LookupResult Previous(*this, NameInfo, LookupUsingDeclName,
ForRedeclaration);
Previous.setHideTags(false);
if (S) {
@@ -3800,15 +3800,15 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
D = UnresolvedUsingTypenameDecl::Create(Context, CurContext,
UsingLoc, TypenameLoc,
SS.getRange(), NNS,
- IdentLoc, Name);
+ IdentLoc, NameInfo.getName());
} else {
D = UnresolvedUsingValueDecl::Create(Context, CurContext,
- UsingLoc, SS.getRange(), NNS,
- IdentLoc, Name);
+ UsingLoc, SS.getRange(),
+ NNS, NameInfo);
}
} else {
- D = UsingDecl::Create(Context, CurContext, IdentLoc,
- SS.getRange(), UsingLoc, NNS, Name,
+ D = UsingDecl::Create(Context, CurContext,
+ SS.getRange(), UsingLoc, NNS, NameInfo,
IsTypeName);
}
D->setAccess(AS);
@@ -3824,7 +3824,7 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
// Look up the target name.
- LookupResult R(*this, Name, IdentLoc, LookupOrdinaryName);
+ LookupResult R(*this, NameInfo, LookupOrdinaryName);
// Unlike most lookups, we don't always want to hide tag
// declarations: tag names are visible through the using declaration
@@ -3837,7 +3837,7 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
if (R.empty()) {
Diag(IdentLoc, diag::err_no_member)
- << Name << LookupContext << SS.getRange();
+ << NameInfo.getName() << LookupContext << SS.getRange();
UD->setInvalidDecl();
return UD;
}
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index fe21ace686..cbdd9d51c2 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1544,22 +1544,22 @@ Decl *TemplateDeclInstantiator::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
// The nested name specifier is non-dependent, so no transformation
- // is required.
+ // is required. The same holds for the name info.
+ DeclarationNameInfo NameInfo = D->getNameInfo();
// We only need to do redeclaration lookups if we're in a class
// scope (in fact, it's not really even possible in non-class
// scopes).
bool CheckRedeclaration = Owner->isRecord();
- LookupResult Prev(SemaRef, D->getDeclName(), D->getLocation(),
- Sema::LookupUsingDeclName, Sema::ForRedeclaration);
+ LookupResult Prev(SemaRef, NameInfo, Sema::LookupUsingDeclName,
+ Sema::ForRedeclaration);
UsingDecl *NewUD = UsingDecl::Create(SemaRef.Context, Owner,
- D->getLocation(),
D->getNestedNameRange(),
D->getUsingLocation(),
D->getTargetNestedNameDecl(),
- D->getDeclName(),
+ NameInfo,
D->isTypeName());
CXXScopeSpec SS;
@@ -1635,10 +1635,12 @@ Decl * TemplateDeclInstantiator
SS.setRange(D->getTargetNestedNameRange());
SS.setScopeRep(NNS);
+ // Since NameInfo refers to a typename, it cannot be a C++ special name.
+ // Hence, no tranformation is required for it.
+ DeclarationNameInfo NameInfo(D->getDeclName(), D->getLocation());
NamedDecl *UD =
SemaRef.BuildUsingDeclaration(/*Scope*/ 0, D->getAccess(),
- D->getUsingLoc(), SS, D->getLocation(),
- D->getDeclName(), 0,
+ D->getUsingLoc(), SS, NameInfo, 0,
/*instantiation*/ true,
/*typename*/ true, D->getTypenameLoc());
if (UD)
@@ -1660,10 +1662,12 @@ Decl * TemplateDeclInstantiator
SS.setRange(D->getTargetNestedNameRange());
SS.setScopeRep(NNS);
+ DeclarationNameInfo NameInfo
+ = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
+
NamedDecl *UD =
SemaRef.BuildUsingDeclaration(/*Scope*/ 0, D->getAccess(),
- D->getUsingLoc(), SS, D->getLocation(),
- D->getDeclName(), 0,
+ D->getUsingLoc(), SS, NameInfo, 0,
/*instantiation*/ true,
/*typename*/ false, SourceLocation());
if (UD)