Author: Nathan Ridge Date: 2025-02-24T15:05:14-05:00 New Revision: 8ce17c15577d223e14b62f9198d4b2ae9856b9fb
URL: https://github.com/llvm/llvm-project/commit/8ce17c15577d223e14b62f9198d4b2ae9856b9fb DIFF: https://github.com/llvm/llvm-project/commit/8ce17c15577d223e14b62f9198d4b2ae9856b9fb.diff LOG: [clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers (#128392) This function has been superseded by HeuristicResolver::lookupDependentName(), which implements the same heuristics and more. Porting note for any out-of-tree callers: ``` RD->lookupDependentName(Name, Filter); ``` can be replaced with: ``` HeuristicResolver(RD->getASTContext())->lookupDependentName(Name, Filter); ``` Added: Modified: clang/include/clang/AST/DeclCXX.h clang/lib/AST/CXXInheritance.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 266b93a64a390..dbd02ef7f8011 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1720,14 +1720,6 @@ class CXXRecordDecl : public RecordDecl { /// static analysis, or similar. bool hasMemberName(DeclarationName N) const; - /// Performs an imprecise lookup of a dependent name in this class. - /// - /// This function does not follow strict semantic rules and should be used - /// only when lookup rules can be relaxed, e.g. indexing. - std::vector<const NamedDecl *> - lookupDependentName(DeclarationName Name, - llvm::function_ref<bool(const NamedDecl *ND)> Filter); - /// Renders and displays an inheritance diagram /// for this C++ class and all of its base classes (transitively) using /// GraphViz. diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index ee5775837d535..ab862d57eae89 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -411,59 +411,6 @@ bool CXXRecordDecl::hasMemberName(DeclarationName Name) const { Paths); } -static bool -findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier, - CXXBasePath &Path, DeclarationName Name) { - const TemplateSpecializationType *TST = - Specifier->getType()->getAs<TemplateSpecializationType>(); - if (!TST) { - auto *RT = Specifier->getType()->getAs<RecordType>(); - if (!RT) - return false; - return findOrdinaryMember(cast<CXXRecordDecl>(RT->getDecl()), Path, Name); - } - TemplateName TN = TST->getTemplateName(); - const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl()); - if (!TD) - return false; - CXXRecordDecl *RD = TD->getTemplatedDecl(); - if (!RD) - return false; - return findOrdinaryMember(RD, Path, Name); -} - -std::vector<const NamedDecl *> CXXRecordDecl::lookupDependentName( - DeclarationName Name, - llvm::function_ref<bool(const NamedDecl *ND)> Filter) { - std::vector<const NamedDecl *> Results; - // Lookup in the class. - bool AnyOrdinaryMembers = false; - for (const NamedDecl *ND : lookup(Name)) { - if (isOrdinaryMember(ND)) - AnyOrdinaryMembers = true; - if (Filter(ND)) - Results.push_back(ND); - } - if (AnyOrdinaryMembers) - return Results; - - // Perform lookup into our base classes. - CXXBasePaths Paths; - Paths.setOrigin(this); - if (!lookupInBases( - [&](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) { - return findOrdinaryMemberInDependentClasses(Specifier, Path, Name); - }, - Paths, /*LookupInDependent=*/true)) - return Results; - for (DeclContext::lookup_iterator I = Paths.front().Decls, E = I.end(); - I != E; ++I) { - if (isOrdinaryMember(*I) && Filter(*I)) - Results.push_back(*I); - } - return Results; -} - void OverridingMethods::add(unsigned OverriddenSubobject, UniqueVirtualMethod Overriding) { SmallVectorImpl<UniqueVirtualMethod> &SubobjectOverrides _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
