================
@@ -0,0 +1,100 @@
+//===--- InefficientCopyAssignCheck.cpp - clang-tidy
----------------------===//
+//
+// 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 "InefficientCopyAssignCheck.h"
+
+#include "../utils/DeclRefExprUtils.h"
+
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/STLExtras.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+using utils::decl_ref_expr::allDeclRefExprs;
+
+void InefficientCopyAssignCheck::registerMatchers(MatchFinder *Finder) {
+ auto AssignOperatorExpr =
+ cxxOperatorCallExpr(
+ hasOperatorName("="),
+ hasArgument(
+ 0, hasType(cxxRecordDecl(hasMethod(isMoveAssignmentOperator()))
+ .bind("assign-target-type"))),
+ hasArgument(
+ 1, declRefExpr(
+ to(varDecl(hasLocalStorage()).bind("assign-value-decl")))
+ .bind("assign-value")),
+ hasAncestor(functionDecl().bind("within-func")))
+ .bind("assign");
+ Finder->addMatcher(AssignOperatorExpr, this);
+}
+
+CFG *InefficientCopyAssignCheck::getCFG(const FunctionDecl *FD,
+ ASTContext *Context) {
----------------
vbvictor wrote:
```suggestion
const ASTContext *Context) {
```
Maybe `CFG::buildCFG` accept const?
https://github.com/llvm/llvm-project/pull/179467
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits