)]}'
{
  "commit": "c114b7e0b3a327e854cae6b560902230436f1ac7",
  "tree": "a02e9ecf3df08b99e5caf19857624345acc8d1bd",
  "parents": [
    "0cbe341c1a28037ee32d21b589030a7df0b9fdab"
  ],
  "author": {
    "name": "David \u0027Digit\u0027 Turner",
    "email": "digit@google.com",
    "time": "Wed Apr 13 14:21:52 2022 +0200"
  },
  "committer": {
    "name": "Commit Bot",
    "email": "commit-bot@chromium.org",
    "time": "Wed Apr 13 16:06:44 2022 +0000"
  },
  "message": "Add Target::builds_swift_module() method.\n\nThe SwiftValues::builds_module() method would always return false before\nSwiftValues::OnResolvedTarget() is called, and this masked a subtle bug\nwhen performing target resolution (see below).\n\nThis CL fixes the issue by adding a new method to the Target class\n(Target::builds_swift_module()). This is necessary since giving the\ncorrect answer requires knowing which Target instance the SwiftValue\nclass is associated with. Call sites are updated to use the new method.\n\nRegarding the bug itself:\n\n- During a Target::OnResolved() call, the PullRecursiveHardDeps()\n  method is called before SwiftValues::OnTargetResolved().\n\n- The PullRecursiveHardDeps() calls the `hard_dep()`  method on the\n  current target, and its dependencies as in:\n\n```\n  for (const auto\u0026 pair : GetDeps(DEPS_LINKED)) {\n    // Direct hard dependencies.\n    if (hard_dep() || pair.ptr-\u003ehard_dep()) {\n      recursive_hard_deps_.insert(pair.ptr);\n      continue;\n    }\n    ...\n```\n\n  If the current target generates a Swift module, the first `hard_dep()`\n  call would always mistakenly return false (because\n  SwiftValues::OnTargetResolved() has not been called yet).\n\n  Note that the `pair.ptr-\u003ehard_dep()` would always return the correct\n  value since all dependencies of the current target are fully resolved\n  when this code runs (and hence their own\n  SwiftValues::OnTargetResolved() call had been performed).\n\nThe CL ensures that the first `hard_dep()` call always returns the\ncorrect value. This also fixes a unit-test that was expecting the\nprevious behaviour.\n\nBug: None\nChange-Id: I6ce8f2f182e22666282d0f7b889fa8df94c45c48\nReviewed-on: https://gn-review.googlesource.com/c/gn/+/13600\nReviewed-by: Sylvain Defresne \u003csdefresne@chromium.org\u003e\nCommit-Queue: David Turner \u003cdigit@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e6f0cdac8857c92f88e421f36986cad5673efc24",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_binary_target_writer.cc",
      "new_id": "e3e36e56e0a1de5fe7de116724aa5ec8ab406fb2",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_binary_target_writer.cc"
    },
    {
      "type": "modify",
      "old_id": "052f03a4b48397b309427afdf5cb60d0dcdd0252",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_c_binary_target_writer.cc",
      "new_id": "2a13c864de4c9c0ca05c398081dd2d332c236f06",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_c_binary_target_writer.cc"
    },
    {
      "type": "modify",
      "old_id": "ff51121f80bf42f4e9825c9da68a7e32b6f8e368",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_c_binary_target_writer_unittest.cc",
      "new_id": "6056c36885e5be6160a10687d58dd429ea585fe5",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_c_binary_target_writer_unittest.cc"
    },
    {
      "type": "modify",
      "old_id": "a70c72f096de9268fa3c6e950a954ac7b3da90ac",
      "old_mode": 33188,
      "old_path": "src/gn/swift_values.cc",
      "new_id": "3cfd37770c55fd976a4d5c31357dcfc0ff32d69d",
      "new_mode": 33188,
      "new_path": "src/gn/swift_values.cc"
    },
    {
      "type": "modify",
      "old_id": "3852366637a3566d2dcaf7889dc7ce4710e9d162",
      "old_mode": 33188,
      "old_path": "src/gn/swift_values.h",
      "new_id": "91ec066ca1f977b884b26b00d8460b69058c5a1e",
      "new_mode": 33188,
      "new_path": "src/gn/swift_values.h"
    },
    {
      "type": "modify",
      "old_id": "f0c897ef878079f23c86059416b8175b3980b80b",
      "old_mode": 33188,
      "old_path": "src/gn/target.cc",
      "new_id": "7b545b522fcd07ce571bd6a9bec7d482284ba2ba",
      "new_mode": 33188,
      "new_path": "src/gn/target.cc"
    },
    {
      "type": "modify",
      "old_id": "de076a84dbfb10ffee51c588018d76816afa2ff1",
      "old_mode": 33188,
      "old_path": "src/gn/target.h",
      "new_id": "66e5c6cf5087353aca557fb3101dd183897f02b1",
      "new_mode": 33188,
      "new_path": "src/gn/target.h"
    }
  ]
}
