================
@@ -76,6 +76,35 @@ AST_MATCHER(CXXMethodDecl, usesThis) {
return UsageOfThis.Used;
}
+static bool hasSameParameterTypes(const CXXMethodDecl &MD1,
+ const CXXMethodDecl &MD2) {
+ if (MD1.getNumParams() != MD2.getNumParams())
+ return false;
+ for (unsigned I = 0, E = MD1.getNumParams(); I < E; ++I)
+ if (MD1.getParamDecl(I)->getType().getCanonicalType() !=
+ MD2.getParamDecl(I)->getType().getCanonicalType())
+ return false;
+ return true;
+}
+
+AST_MATCHER(CXXMethodDecl, hasNonConstOverload) {
+ const auto *Method = &Node;
+ const DeclContext::lookup_result LookupResult =
+ Method->getParent()->lookup(Method->getNameInfo().getName());
+ if (LookupResult.isSingleResult())
+ return false;
+
+ for (const Decl *D : LookupResult) {
+ if (const auto *Overload = dyn_cast<CXXMethodDecl>(D)) {
+ if (Overload != Method && !Overload->isConst() &&
+ hasSameParameterTypes(*Method, *Overload)) {
+ return true;
+ }
+ }
----------------
unterumarmung wrote:
this can be one `if` and `{` `}` are not needed
https://github.com/llvm/llvm-project/pull/191712
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits