[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

Arnaud Bienner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 10:16:48 PDT 2023


ArnaudBienner added a comment.

Giving this a second thought, I feel like the initial check:

  if (!ArgExpr->getType()->isAnyPointerType() ||
      !ArgExpr->getType()->getPointeeType()->isAnyCharacterType())

is better than the new one. To me it reads like "expr type is a pointer and it points to character type" which is more understandable IMHO.

If you're worried about the expression being a bit long, I could move type to a temp variable:

  if (const QualType type = ArgExpr->getType();
      !type->isAnyPointerType() ||
      !type->getPointeeType()->isAnyCharacterType())

Though I'm not sure this is really more readable.

What do you think?

Any other suggestion/comment about this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150430/new/

https://reviews.llvm.org/D150430



More information about the cfe-commits mailing list