[clang][dataflow] Use existing accessors to check for copy and move assignment ops.
authorMartin Braenne <mboehme@google.com>
Mon, 24 Apr 2023 13:11:02 +0000 (13:11 +0000)
committerMartin Braenne <mboehme@google.com>
Mon, 24 Apr 2023 14:32:09 +0000 (14:32 +0000)
Reviewed By: gribozavr2

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

clang/lib/Analysis/FlowSensitive/Transfer.cpp

index 2d85e7b..0814257 100644 (file)
@@ -646,9 +646,12 @@ public:
       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);