================
@@ -177,6 +177,27 @@ static auto isPointerComparisonOperatorCall(std::string 
operator_name) {
                             pointee(anyOf(statusOrType(), statusType())))))));
 }
 
+static auto isStatusOrValueAssignmentCall() {
+  using namespace ::clang::ast_matchers; // NOLINT: Too many names
+  return cxxOperatorCallExpr(
+      hasOverloadedOperatorName("="),
+      callee(cxxMethodDecl(ofClass(statusOrClass()))),
+      hasArgument(1, anyOf(hasType(hasUnqualifiedDesugaredType(
+                               type(equalsBoundNode("T")))),
+                           nullPointerConstant())));
----------------
jvoung wrote:

is the `nullPointerConstant()` a special case because the operator= more 
broadly accepts some type `U` as long as IsAssignmentValid(T, U), but here it 
is directly checking for `T` types?

(and the nullptr constant  `U = nullptr_t` instead of `T = void*`) ?

If so, would be good to leave a comment as to why.

I think the std::optional checker is more relaxed during the matching, and then 
tries to split in the transfer function if it is `U` or `std::optional<U>` 
(https://github.com/llvm/llvm-project/blob/9a5ae34eb6e90c51e2231ceb1a8cf933341f3222/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp#L689)

which could be another way to do it.



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

Reply via email to