)]}'
{
  "commit": "22357fe33a8a8cc221632e32cb443676f1feeda9",
  "tree": "95c5d9388d3ff83fe0de33c071fbfeae9c11291a",
  "parents": [
    "1113224f9444f5c2cf69784cd3c110b8dd560897"
  ],
  "author": {
    "name": "flovent",
    "email": "flbven@protonmail.com",
    "time": "Mon Jul 07 19:46:30 2025 +0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Jul 07 13:46:30 2025 +0200"
  },
  "message": "[analyzer] Avoid unnecessary super region invalidation in `CStringChecker` (#146212)\n\nBounded string functions takes smallest of two values as it\u0027s copy size\n(`amountCopied` variable in `evalStrcpyCommon`), and it\u0027s used to\ndecided whether this operation will cause out-of-bound access and\ninvalidate it\u0027s super region if it does.\n\nfor `strlcat`: `amountCopied \u003d min (size - dstLen - 1 , srcLen)`\nfor others: `amountCopied \u003d min (srcLen, size)`\n\nCurrently when one of two values is unknown or `SValBuilder` can\u0027t\ndecide which one is smaller, `amountCopied` will remain `UnknownVal`,\nwhich will invalidate copy destination\u0027s super region unconditionally.\n\nThis patch add check to see if one of these two values is definitely\nin-bound, if so `amountCopied` has to be in-bound too, because it‘s less\nthan or equal to them, we can avoid the invalidation of super region and\nsome related false positives in this situation.\n\nNote: This patch uses `size` as an approximation of `size - dstLen - 1`\nin `strlcat` case because currently analyzer doesn\u0027t handle complex\nexpressions like this very well.\n\nCloses #143807.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4d12fdcec1f1a8ee291e4498d7afcb904d8e1a6a",
      "old_mode": 33188,
      "old_path": "clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp",
      "new_id": "31cb150892a5dc4577986156b7cda1c22f8ade6b",
      "new_mode": 33188,
      "new_path": "clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "abd4689b2f9b9fc9c7012074b4b8c34a15144bbb",
      "new_mode": 33188,
      "new_path": "clang/test/Analysis/cstring-should-not-invalidate.cpp"
    }
  ]
}
