diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/Decl.cpp | 6 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 24 | ||||
-rw-r--r-- | lib/AST/DeclCXX.cpp | 9 | ||||
-rw-r--r-- | lib/AST/DeclPrinter.cpp | 7 |
4 files changed, 32 insertions, 14 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index a6996a4bfe..bdc804722c 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -289,6 +289,10 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const { if (isa<ObjCInterfaceDecl>(this) && isa<ObjCCompatibleAliasDecl>(OldD)) return true; + if (isa<UsingShadowDecl>(this) && isa<UsingShadowDecl>(OldD)) + return cast<UsingShadowDecl>(this)->getTargetDecl() == + cast<UsingShadowDecl>(OldD)->getTargetDecl(); + // For non-function declarations, if the declarations are of the // same kind then this must be a redeclaration, or semantic analysis // would not have given us the new declaration. @@ -308,7 +312,7 @@ bool NamedDecl::hasLinkage() const { NamedDecl *NamedDecl::getUnderlyingDecl() { NamedDecl *ND = this; while (true) { - if (UsingDecl *UD = dyn_cast<UsingDecl>(ND)) + if (UsingShadowDecl *UD = dyn_cast<UsingShadowDecl>(ND)) ND = UD->getTargetDecl(); else if (ObjCCompatibleAliasDecl *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND)) diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 6cfdcdd3e5..da3b19df5b 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -97,7 +97,7 @@ bool Decl::isTemplateParameterPack() const { } bool Decl::isFunctionOrFunctionTemplate() const { - if (const UsingDecl *UD = dyn_cast<UsingDecl>(this)) + if (const UsingShadowDecl *UD = dyn_cast<UsingShadowDecl>(this)) return UD->getTargetDecl()->isFunctionOrFunctionTemplate(); return isa<FunctionDecl>(this) || isa<FunctionTemplateDecl>(this); @@ -189,10 +189,11 @@ ASTContext &Decl::getASTContext() const { unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { switch (DeclKind) { - default: - if (DeclKind >= FunctionFirst && DeclKind <= FunctionLast) - return IDNS_Ordinary; - assert(0 && "Unknown decl kind!"); + case Function: + case CXXMethod: + case CXXConstructor: + case CXXDestructor: + case CXXConversion: case OverloadedFunction: case Typedef: case EnumConstant: @@ -200,8 +201,6 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { case ImplicitParam: case ParmVar: case NonTypeTemplateParm: - case Using: - case UnresolvedUsing: case ObjCMethod: case ObjCContainer: case ObjCCategory: @@ -210,6 +209,15 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { case ObjCCompatibleAlias: return IDNS_Ordinary; + case UsingShadow: + return 0; // we'll actually overwrite this later + + case UnresolvedUsing: + return IDNS_Tag | IDNS_Ordinary | IDNS_Using; + + case Using: + return IDNS_Using; + case ObjCProtocol: return IDNS_ObjCProtocol; @@ -256,6 +264,8 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { case ClassTemplatePartialSpecialization: return 0; } + + return 0; } void Decl::addAttr(Attr *NewAttr) { diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 3768796627..520206d248 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -914,11 +914,10 @@ NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC, } UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, SourceRange NNR, SourceLocation TargetNL, - SourceLocation UL, NamedDecl* Target, - NestedNameSpecifier* TargetNNS, bool IsTypeNameArg) { - return new (C) UsingDecl(DC, L, NNR, TargetNL, UL, Target, - TargetNNS, IsTypeNameArg); + SourceLocation L, SourceRange NNR, SourceLocation UL, + NestedNameSpecifier* TargetNNS, DeclarationName Name, + bool IsTypeNameArg) { + return new (C) UsingDecl(DC, L, NNR, UL, TargetNNS, Name, IsTypeNameArg); } UnresolvedUsingDecl *UnresolvedUsingDecl::Create(ASTContext &C, DeclContext *DC, diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index b88a971f1e..199ed356d6 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -73,6 +73,7 @@ namespace { void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); void VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D); void VisitUsingDecl(UsingDecl *D); + void VisitUsingShadowDecl(UsingShadowDecl *D); }; } @@ -825,7 +826,7 @@ void DeclPrinter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PID) { void DeclPrinter::VisitUsingDecl(UsingDecl *D) { Out << "using "; D->getTargetNestedNameDecl()->print(Out, Policy); - Out << D->getTargetDecl()->getNameAsString(); + Out << D->getNameAsString(); } void DeclPrinter::VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D) { @@ -833,3 +834,7 @@ void DeclPrinter::VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D) { D->getTargetNestedNameSpecifier()->print(Out, Policy); Out << D->getTargetName().getAsString(); } + +void DeclPrinter::VisitUsingShadowDecl(UsingShadowDecl *D) { + // ignore +} |