From: Daniel Jasper Date: Mon, 19 Dec 2016 10:09:25 +0000 (+0000) Subject: Revert "[c++1z] P0195R2: Support pack-expansion of using-declarations." X-Git-Tag: llvmorg-4.0.0-rc1~1716 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9949ead55ad85698096af2fda29e8c6bb00a09b9;p=platform%2Fupstream%2Fllvm.git Revert "[c++1z] P0195R2: Support pack-expansion of using-declarations." This reverts commit r290080 as it leads to many Clang crashes, e.g.: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814 llvm-svn: 290092 --- diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 06ecd3c..46434c4 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -3140,77 +3140,6 @@ public: friend class ASTDeclWriter; }; -/// Represents a pack of using declarations that a single -/// using-declarator pack-expanded into. -/// -/// \code -/// template struct X : T... { -/// using T::operator()...; -/// using T::operator T...; -/// }; -/// \endcode -/// -/// In the second case above, the UsingPackDecl will have the name -/// 'operator T' (which contains an unexpanded pack), but the individual -/// UsingDecls and UsingShadowDecls will have more reasonable names. -class UsingPackDecl final - : public NamedDecl, public Mergeable, - private llvm::TrailingObjects { - void anchor() override; - - /// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from - /// which this waas instantiated. - NamedDecl *InstantiatedFrom; - - /// The number of using-declarations created by this pack expansion. - unsigned NumExpansions; - - UsingPackDecl(DeclContext *DC, NamedDecl *InstantiatedFrom, - ArrayRef UsingDecls) - : NamedDecl(UsingPack, DC, - InstantiatedFrom ? InstantiatedFrom->getLocation() - : SourceLocation(), - InstantiatedFrom ? InstantiatedFrom->getDeclName() - : DeclarationName()), - InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) { - std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(), - getTrailingObjects()); - } - -public: - /// Get the using declaration from which this was instantiated. This will - /// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl - /// that is a pack expansion. - NamedDecl *getInstantiatedFromUsingDecl() { return InstantiatedFrom; } - - /// Get the set of using declarations that this pack expanded into. Note that - /// some of these may still be unresolved. - ArrayRef expansions() const { - return llvm::makeArrayRef(getTrailingObjects(), NumExpansions); - } - - static UsingPackDecl *Create(ASTContext &C, DeclContext *DC, - NamedDecl *InstantiatedFrom, - ArrayRef UsingDecls); - - static UsingPackDecl *CreateDeserialized(ASTContext &C, unsigned ID, - unsigned NumExpansions); - - SourceRange getSourceRange() const override LLVM_READONLY { - return InstantiatedFrom->getSourceRange(); - } - - UsingPackDecl *getCanonicalDecl() override { return getFirstDecl(); } - const UsingPackDecl *getCanonicalDecl() const { return getFirstDecl(); } - - static bool classof(const Decl *D) { return classofKind(D->getKind()); } - static bool classofKind(Kind K) { return K == UsingPack; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; - friend TrailingObjects; -}; - /// \brief Represents a dependent using declaration which was not marked with /// \c typename. /// @@ -3229,9 +3158,6 @@ class UnresolvedUsingValueDecl : public ValueDecl, /// \brief The source location of the 'using' keyword SourceLocation UsingLocation; - /// \brief If this is a pack expansion, the location of the '...'. - SourceLocation EllipsisLoc; - /// \brief The nested-name-specifier that precedes the name. NestedNameSpecifierLoc QualifierLoc; @@ -3242,12 +3168,11 @@ class UnresolvedUsingValueDecl : public ValueDecl, UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, - const DeclarationNameInfo &NameInfo, - SourceLocation EllipsisLoc) + const DeclarationNameInfo &NameInfo) : ValueDecl(UnresolvedUsingValue, DC, NameInfo.getLoc(), NameInfo.getName(), Ty), - UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc), - QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo()) + UsingLocation(UsingLoc), QualifierLoc(QualifierLoc), + DNLoc(NameInfo.getInfo()) { } public: @@ -3273,20 +3198,10 @@ public: return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } - /// \brief Determine whether this is a pack expansion. - bool isPackExpansion() const { - return EllipsisLoc.isValid(); - } - - /// \brief Get the location of the ellipsis if this is a pack expansion. - SourceLocation getEllipsisLoc() const { - return EllipsisLoc; - } - static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, - const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc); + const DeclarationNameInfo &NameInfo); static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID); @@ -3327,9 +3242,6 @@ class UnresolvedUsingTypenameDecl /// \brief The source location of the 'typename' keyword SourceLocation TypenameLocation; - /// \brief If this is a pack expansion, the location of the '...'. - SourceLocation EllipsisLoc; - /// \brief The nested-name-specifier that precedes the name. NestedNameSpecifierLoc QualifierLoc; @@ -3337,12 +3249,10 @@ class UnresolvedUsingTypenameDecl SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, - IdentifierInfo *TargetName, - SourceLocation EllipsisLoc) + IdentifierInfo *TargetName) : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName, UsingLoc), - TypenameLocation(TypenameLoc), EllipsisLoc(EllipsisLoc), - QualifierLoc(QualifierLoc) { } + TypenameLocation(TypenameLoc), QualifierLoc(QualifierLoc) { } friend class ASTDeclReader; @@ -3362,25 +3272,10 @@ public: return QualifierLoc.getNestedNameSpecifier(); } - DeclarationNameInfo getNameInfo() const { - return DeclarationNameInfo(getDeclName(), getLocation()); - } - - /// \brief Determine whether this is a pack expansion. - bool isPackExpansion() const { - return EllipsisLoc.isValid(); - } - - /// \brief Get the location of the ellipsis if this is a pack expansion. - SourceLocation getEllipsisLoc() const { - return EllipsisLoc; - } - static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, - SourceLocation TargetNameLoc, DeclarationName TargetName, - SourceLocation EllipsisLoc); + SourceLocation TargetNameLoc, DeclarationName TargetName); static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID); diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index afacfd5..058ab1f 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1505,8 +1505,6 @@ DEF_TRAVERSE_DECL(UsingDecl, { TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo())); }) -DEF_TRAVERSE_DECL(UsingPackDecl, {}) - DEF_TRAVERSE_DECL(UsingDirectiveDecl, { TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); }) diff --git a/clang/include/clang/Basic/DeclNodes.td b/clang/include/clang/Basic/DeclNodes.td index 7b581d3..6da2c2c 100644 --- a/clang/include/clang/Basic/DeclNodes.td +++ b/clang/include/clang/Basic/DeclNodes.td @@ -67,7 +67,6 @@ def Named : Decl<1>; def TemplateTemplateParm : DDecl