[clang-tidy] Avoid binding nullptr to a reference

That's undefined behavior. Found by -fsanitize=null.
This commit is contained in:
Benjamin Kramer 2022-01-21 15:54:33 +01:00
parent 4d82ae67b2
commit b8102449a7
1 changed files with 3 additions and 3 deletions

View File

@ -68,9 +68,9 @@ void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) {
}
bool IsRValueReferenceParam(const Expr *Invocation,
const QualType &InvocationParmType,
const QualType *InvocationParmType,
const Expr *Arg) {
if (Invocation && InvocationParmType->isRValueReferenceType() &&
if (Invocation && (*InvocationParmType)->isRValueReferenceType() &&
Arg->isLValue()) {
if (!Invocation->getType()->isRecordType())
return true;
@ -138,7 +138,7 @@ void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) {
// std::move shouldn't be removed when an lvalue wrapped by std::move is
// passed to the function with an rvalue reference parameter.
bool IsRVRefParam =
IsRValueReferenceParam(ReceivingExpr, *InvocationParmType, Arg);
IsRValueReferenceParam(ReceivingExpr, InvocationParmType, Arg);
const auto *Var =
IsVariable ? dyn_cast<DeclRefExpr>(Arg)->getDecl() : nullptr;