[clang] 6b85cc1 - [clang][dataflow] Use existing accessors to check for copy and move assignment ops.

Martin Braenne via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 07:32:18 PDT 2023


Author: Martin Braenne
Date: 2023-04-24T14:32:09Z
New Revision: 6b85cc18eb7be0fdc01b8586347750e65e56a4c3

URL: https://github.com/llvm/llvm-project/commit/6b85cc18eb7be0fdc01b8586347750e65e56a4c3
DIFF: https://github.com/llvm/llvm-project/commit/6b85cc18eb7be0fdc01b8586347750e65e56a4c3.diff

LOG: [clang][dataflow] Use existing accessors to check for copy and move assignment ops.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D148612

Added: 
    

Modified: 
    clang/lib/Analysis/FlowSensitive/Transfer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 2d85e7b90f73..0814257d5cd3 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -646,9 +646,12 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
       assert(Arg1 != nullptr);
 
       // Evaluate only copy and move assignment operators.
-      auto *Arg0Type = Arg0->getType()->getUnqualifiedDesugaredType();
-      auto *Arg1Type = Arg1->getType()->getUnqualifiedDesugaredType();
-      if (Arg0Type != Arg1Type)
+      const auto *Method =
+          dyn_cast_or_null<CXXMethodDecl>(S->getDirectCallee());
+      if (!Method)
+        return;
+      if (!Method->isCopyAssignmentOperator() &&
+          !Method->isMoveAssignmentOperator())
         return;
 
       auto *ObjectLoc = Env.getStorageLocation(*Arg0, SkipPast::Reference);


        


More information about the cfe-commits mailing list