From 665b49c62d637d16826036118f92d35f116f3ef3 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 28 Aug 2009 05:30:28 +0000 Subject: [PATCH] Check in UnresolvedUsingDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80336 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclCXX.h | 50 +++++++++++++++++++++++++++++++-- include/clang/AST/DeclNodes.def | 1 + lib/AST/DeclBase.cpp | 1 + lib/AST/DeclCXX.cpp | 11 ++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index b08a51f016..2d16557d95 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1576,20 +1576,23 @@ public: /// UsingDecl - Represents a C++ using-declaration. For example: /// using someNameSpace::someIdentifier; class UsingDecl : public NamedDecl { - /// \brief The source range that covers the nested-name-specifier /// preceding the declaration name. SourceRange NestedNameRange; + /// \brief The source location of the target declaration name. SourceLocation TargetNameLocation; + /// \brief The source location of the "using" location itself. SourceLocation UsingLocation; + /// \brief Target declaration. NamedDecl* TargetDecl; - /// \brief Target declaration. + + /// \brief Target nested name specifier. NestedNameSpecifier* TargetNestedNameDecl; - // Had 'typename' keyword. + // \brief Has 'typename' keyword. bool IsTypeName; UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR, @@ -1635,6 +1638,47 @@ public: } static bool classof(const UsingDecl *D) { return true; } }; + +/// UnresolvedUsingDecl - Represents a using declaration whose name can not +/// yet be resolved. +class UnresolvedUsingDecl : public NamedDecl { + /// \brief The source range that covers the nested-name-specifier + /// preceding the declaration name. + SourceRange TargetNestedNameRange; + + /// \brief The source location of the target declaration name. + SourceLocation TargetNameLocation; + + NestedNameSpecifier *TargetNestedNameSpecifier; + + DeclarationName TargetName; + + // \brief Has 'typename' keyword. + bool IsTypeName; + + UnresolvedUsingDecl(DeclContext *DC, SourceLocation UsingLoc, + SourceRange TargetNNR, NestedNameSpecifier *TargetNNS, + SourceLocation TargetNameLoc, DeclarationName TargetName, + bool IsTypeNameArg) + : NamedDecl(Decl::UnresolvedUsing, DC, UsingLoc, TargetName), + TargetNestedNameRange(TargetNNR), TargetNameLocation(TargetNameLoc), + TargetNestedNameSpecifier(TargetNNS), TargetName(TargetName), + IsTypeName(IsTypeNameArg) { } + +public: + static UnresolvedUsingDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation UsingLoc, + SourceRange TargetNNR, + NestedNameSpecifier *TargetNNS, + SourceLocation TargetNameLoc, + DeclarationName TargetName, + bool IsTypeNameArg); + + static bool classof(const Decl *D) { + return D->getKind() == Decl::UnresolvedUsing; + } + static bool classof(const UnresolvedUsingDecl *D) { return true; } +}; /// StaticAssertDecl - Represents a C++0x static_assert declaration. class StaticAssertDecl : public Decl { diff --git a/include/clang/AST/DeclNodes.def b/include/clang/AST/DeclNodes.def index 629197be59..996d042d14 100644 --- a/include/clang/AST/DeclNodes.def +++ b/include/clang/AST/DeclNodes.def @@ -111,6 +111,7 @@ ABSTRACT_DECL(Named, Decl) DECL(ClassTemplate, TemplateDecl) DECL(TemplateTemplateParm, TemplateDecl) DECL(Using, NamedDecl) + DECL(UnresolvedUsing, NamedDecl) DECL(ObjCMethod, NamedDecl) DECL(ObjCContainer, NamedDecl) DECL(ObjCCategory, ObjCContainerDecl) diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index cd5b0063a6..28d543785f 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -191,6 +191,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { case OriginalParmVar: case NonTypeTemplateParm: case Using: + case UnresolvedUsing: case ObjCMethod: case ObjCContainer: case ObjCCategory: diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index e3a0f486d5..70e48976da 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -832,6 +832,17 @@ UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, TargetNNS, IsTypeNameArg); } +UnresolvedUsingDecl *UnresolvedUsingDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation UsingLoc, + SourceRange TargetNNR, + NestedNameSpecifier *TargetNNS, + SourceLocation TargetNameLoc, + DeclarationName TargetName, + bool IsTypeNameArg) { + return new (C) UnresolvedUsingDecl(DC, UsingLoc, TargetNNR, TargetNNS, + TargetNameLoc, TargetName, IsTypeNameArg); +} + StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, Expr *AssertExpr, StringLiteral *Message) { -- 2.40.0