================
@@ -73,6 +73,20 @@ void UndefinedAssignmentChecker::checkBind(SVal location,
SVal val,
}
}
+ if (const auto *MD =
+ dyn_cast<CXXMethodDecl>(C.getStackFrame()->getDecl())) {
+ if ((MD->isCopyAssignmentOperator() ||
+ MD->isMoveAssignmentOperator()) &&
+ MD->isDefaulted() && B->isAssignmentOp()) {
+ OS << "Value assigned to field '"
+ << cast<MemberExpr>(B->getRHS()->IgnoreImpCasts())
+ ->getMemberDecl()
+ ->getName()
+ << "' in " << (!MD->isImplicit() ? "default" : "implicit")
+ << " assignment operator is uninitialized";
----------------
steakhal wrote:
I don't understand this. The LHS is some arbitrary expression - right? It
doesn't matter if the operator we are passing it to is defaulted or not. For
example: `getFoo().operator=(someOtherFoo);` would result in a `getFoo()`
(`CallExpr`) as the LHS, and the `someOtherFoo` (`DeclRefExpr`) I think.
Similarly, you could always wrap any expression with arbitrary number of
braces. For example: `(((getFoo()))).operator=(someOtherFoo);`
Note that `getFoo()` returns a mutable reference.
https://github.com/llvm/llvm-project/pull/208173
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits