-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers #128392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers #128392
Conversation
… use it in StandaloneEmptyCheck The use replaces CXXRecordDecl::lookupDependentName() which HeuristicResolver aims to supersede.
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); ```
@llvm/pr-subscribers-clang Author: Nathan Ridge (HighCommander4) ChangesThis function has been superseded by HeuristicResolver::lookupDependentName(), which implements the same heuristics and more. Porting note for any out-of-tree callers:
can be replaced with:
Full diff: https://github.com/llvm/llvm-project/pull/128392.diff 2 Files Affected:
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, but my concern would be that we're less clear about the number of uses of this function out-of-tree (and how hard it could be to migrate them to HeuristicResolver), so as an alternative, can we turn the implementation to use HeuristicResolver and explicitly deprecate it for a while before eventually removing it?
I tried this, but this would require linking FWIW I did a Github code search and could only find one out-of-tree use in public code available on Github, and it looks straightforward to port to HeuristicResolver. |
We make no stability guarantees whatsoever for the C++ interfaces (except we don't change in in abi breaking ways in point releases). |
This function has been superseded by HeuristicResolver::lookupDependentName(), which implements the same heuristics and more.
Porting note for any out-of-tree callers:
can be replaced with: