[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 19 23:21:50 PST 2025
================
@@ -422,7 +425,15 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveDependentMember(
if (!RD->hasDefinition())
return {};
RD = RD->getDefinition();
- return lookupDependentName(RD, Name, Filter);
+ return lookupDependentName(RD, Name, [&](const NamedDecl *ND) {
+ if (!Filter(ND))
+ return false;
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(ND)) {
+ if (QT.isConstQualified() && !MD->isConst())
+ return false;
----------------
zyn0217 wrote:
We also have `isVolatileQualfied()/isRestrictQualified()`... do we also want to handle them?
With that in mind, I'm also thinking if we can reuse something from Sema e.g. we have [`hasInconsistentOrSupersetQualifiersOf()`](https://searchfox.org/llvm/source/clang/lib/Sema/SemaTemplateDeduction.cpp#1315-1340) that does the similar job in SemaTemplateDeduction.cpp that you might want to take a look.
https://github.com/llvm/llvm-project/pull/123551
More information about the cfe-commits
mailing list