Skip to content

Commit

Permalink
[clang-tidy] Avoid binding nullptr to a reference
Browse files Browse the repository at this point in the history
That's undefined behavior. Found by -fsanitize=null.
  • Loading branch information
d0k committed Jan 21, 2022
1 parent 4d82ae6 commit b810244
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit b810244

Please sign in to comment.