================
@@ -0,0 +1,174 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ExpensiveValueOrCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "../utils/TypeTraits.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+static bool hasOperatorStar(const CXXRecordDecl *RD) {
+  return llvm::any_of(RD->methods(), [](const CXXMethodDecl *M) {
+    return M->getOverloadedOperator() == OO_Star;
+  });
+}
+
+static StringRef findValueMethod(const CXXRecordDecl *RD) {
+  for (const auto *M : RD->methods()) {
+    if (!M->getDeclName().isIdentifier())
+      continue;
+    StringRef Name = M->getName();
+    if (Name == "value" || Name == "Value")
+      return Name;
+  }
+  return {};
+}
----------------
gamesh411 wrote:

Good catch. I have checked that `RD->methods()` indeed only iterates direct 
declarations, missing methods from using declarations.
Now hasOperatorStar and findValueMethod use DeclContext::lookup, which finds 
both direct and using-introduced names.
Added a test case with the inherited-via-using pattern.


https://github.com/llvm/llvm-project/pull/200166
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to