whisperity created this revision. whisperity added reviewers: rsmith, rjmccall. whisperity added a project: clang. Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
The function and its called static helpers don't modify the received `CXXRecordDecl` arguments at all as the method result is put into an output parameter. Thus, they can be `const` which allows for neatly grabbing the conversion methods in a context where we only have a `const ASTUnit` at hand. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D71805 Files: clang/include/clang/AST/DeclCXX.h clang/lib/AST/DeclCXX.cpp Index: clang/lib/AST/DeclCXX.cpp =================================================================== --- clang/lib/AST/DeclCXX.cpp +++ clang/lib/AST/DeclCXX.cpp @@ -1512,14 +1512,12 @@ /// \param VOutput the set to which to add conversions from virtual bases /// \param HiddenVBaseCs the set of conversions which were hidden in a /// virtual base along some inheritance path -static void CollectVisibleConversions(ASTContext &Context, - CXXRecordDecl *Record, - bool InVirtual, - AccessSpecifier Access, - const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes, - ASTUnresolvedSet &Output, - UnresolvedSetImpl &VOutput, - llvm::SmallPtrSet<NamedDecl*, 8> &HiddenVBaseCs) { +static void CollectVisibleConversions( + ASTContext &Context, const CXXRecordDecl *Record, bool InVirtual, + AccessSpecifier Access, + const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes, + ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput, + llvm::SmallPtrSet<NamedDecl *, 8> &HiddenVBaseCs) { // The set of types which have conversions in this class or its // subclasses. As an optimization, we don't copy the derived set // unless it might change. @@ -1560,7 +1558,7 @@ // Collect information recursively from any base classes. for (const auto &I : Record->bases()) { - const RecordType *RT = I.getType()->getAs<RecordType>(); + const auto *RT = I.getType()->getAs<RecordType>(); if (!RT) continue; AccessSpecifier BaseAccess @@ -1578,7 +1576,7 @@ /// This would be extremely straightforward if it weren't for virtual /// bases. It might be worth special-casing that, really. static void CollectVisibleConversions(ASTContext &Context, - CXXRecordDecl *Record, + const CXXRecordDecl *Record, ASTUnresolvedSet &Output) { // The collection of all conversions in virtual bases that we've // found. These will be added to the output as long as they don't @@ -1602,7 +1600,7 @@ // Recursively collect conversions from base classes. for (const auto &I : Record->bases()) { - const RecordType *RT = I.getType()->getAs<RecordType>(); + const auto *RT = I.getType()->getAs<RecordType>(); if (!RT) continue; CollectVisibleConversions(Context, cast<CXXRecordDecl>(RT->getDecl()), @@ -1621,7 +1619,7 @@ /// getVisibleConversionFunctions - get all conversion functions visible /// in current class; including conversion function templates. llvm::iterator_range<CXXRecordDecl::conversion_iterator> -CXXRecordDecl::getVisibleConversionFunctions() { +CXXRecordDecl::getVisibleConversionFunctions() const { ASTContext &Ctx = getASTContext(); ASTUnresolvedSet *Set; Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -1046,7 +1046,8 @@ /// Get all conversion functions visible in current class, /// including conversion function templates. - llvm::iterator_range<conversion_iterator> getVisibleConversionFunctions(); + llvm::iterator_range<conversion_iterator> + getVisibleConversionFunctions() const; /// Determine whether this class is an aggregate (C++ [dcl.init.aggr]), /// which is a class with no user-declared constructors, no private
Index: clang/lib/AST/DeclCXX.cpp =================================================================== --- clang/lib/AST/DeclCXX.cpp +++ clang/lib/AST/DeclCXX.cpp @@ -1512,14 +1512,12 @@ /// \param VOutput the set to which to add conversions from virtual bases /// \param HiddenVBaseCs the set of conversions which were hidden in a /// virtual base along some inheritance path -static void CollectVisibleConversions(ASTContext &Context, - CXXRecordDecl *Record, - bool InVirtual, - AccessSpecifier Access, - const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes, - ASTUnresolvedSet &Output, - UnresolvedSetImpl &VOutput, - llvm::SmallPtrSet<NamedDecl*, 8> &HiddenVBaseCs) { +static void CollectVisibleConversions( + ASTContext &Context, const CXXRecordDecl *Record, bool InVirtual, + AccessSpecifier Access, + const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes, + ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput, + llvm::SmallPtrSet<NamedDecl *, 8> &HiddenVBaseCs) { // The set of types which have conversions in this class or its // subclasses. As an optimization, we don't copy the derived set // unless it might change. @@ -1560,7 +1558,7 @@ // Collect information recursively from any base classes. for (const auto &I : Record->bases()) { - const RecordType *RT = I.getType()->getAs<RecordType>(); + const auto *RT = I.getType()->getAs<RecordType>(); if (!RT) continue; AccessSpecifier BaseAccess @@ -1578,7 +1576,7 @@ /// This would be extremely straightforward if it weren't for virtual /// bases. It might be worth special-casing that, really. static void CollectVisibleConversions(ASTContext &Context, - CXXRecordDecl *Record, + const CXXRecordDecl *Record, ASTUnresolvedSet &Output) { // The collection of all conversions in virtual bases that we've // found. These will be added to the output as long as they don't @@ -1602,7 +1600,7 @@ // Recursively collect conversions from base classes. for (const auto &I : Record->bases()) { - const RecordType *RT = I.getType()->getAs<RecordType>(); + const auto *RT = I.getType()->getAs<RecordType>(); if (!RT) continue; CollectVisibleConversions(Context, cast<CXXRecordDecl>(RT->getDecl()), @@ -1621,7 +1619,7 @@ /// getVisibleConversionFunctions - get all conversion functions visible /// in current class; including conversion function templates. llvm::iterator_range<CXXRecordDecl::conversion_iterator> -CXXRecordDecl::getVisibleConversionFunctions() { +CXXRecordDecl::getVisibleConversionFunctions() const { ASTContext &Ctx = getASTContext(); ASTUnresolvedSet *Set; Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -1046,7 +1046,8 @@ /// Get all conversion functions visible in current class, /// including conversion function templates. - llvm::iterator_range<conversion_iterator> getVisibleConversionFunctions(); + llvm::iterator_range<conversion_iterator> + getVisibleConversionFunctions() const; /// Determine whether this class is an aggregate (C++ [dcl.init.aggr]), /// which is a class with no user-declared constructors, no private
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits