[llvm-branch-commits] [clang] [clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers (PR #128392)

Nathan Ridge via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Feb 22 19:53:29 PST 2025


https://github.com/HighCommander4 created https://github.com/llvm/llvm-project/pull/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);
```

>From 4bb5f832edc9370e3d782427db8cd51b8ffdc835 Mon Sep 17 00:00:00 2001
From: Nathan Ridge <zeratul976 at hotmail.com>
Date: Sat, 22 Feb 2025 22:48:03 -0500
Subject: [PATCH] [clang][NFC] Remove CXXRecordDecl::lookupDependentName() and
 its helpers

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);
```
---
 clang/include/clang/AST/DeclCXX.h |  8 -----
 clang/lib/AST/CXXInheritance.cpp  | 53 -------------------------------
 2 files changed, 61 deletions(-)

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



More information about the llvm-branch-commits mailing list