[clang-tools-extra] [clang-tidy] Fix false positive in cppcoreguidelines-avoid-const-or-ref-data-members when detecting templated classes with inheritance (PR #115180)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 15:14:24 PST 2024
================
@@ -13,79 +13,92 @@
using namespace clang::ast_matchers;
namespace clang::tidy::cppcoreguidelines {
-namespace {
-AST_MATCHER(FieldDecl, isMemberOfLambda) {
- return Node.getParent()->isLambda();
+static bool hasCopyConstructor(CXXRecordDecl const &Node) {
+ if (Node.needsOverloadResolutionForCopyConstructor() &&
+ Node.needsImplicitCopyConstructor()) {
+ // unresolved
+ for (CXXBaseSpecifier const &BS : Node.bases()) {
+ CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
+ if (BRD != nullptr)
+ if (!hasCopyConstructor(*BRD))
+ return false;
----------------
5chmidti wrote:
These `if`s can be merged (x4 for all four `hasX`)
https://github.com/llvm/llvm-project/pull/115180
More information about the cfe-commits
mailing list