{"action":"created","comment":{"url":"https://api.github.com/repos/Semmle/ql/pulls/comments/231251373","pull_request_review_id":172181621,"id":231251373,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTI1MTM3Mw==","diff_hunk":"@@ -523,57 +507,104 @@ module Internal {\n      */\n     cached\n     predicate impliesStep(Expr e1, AbstractValue v1, Expr e2, AbstractValue v2) {\n-      e1.(BitwiseAndExpr).getAnOperand() = e2 and\n-      v1 = TBooleanValue(true) and\n-      v2 = v1\n-      or\n-      e1.(BitwiseOrExpr).getAnOperand() = e2 and\n-      v1 = TBooleanValue(false) and\n-      v2 = v1\n-      or\n-      e1.(LogicalAndExpr).getAnOperand() = e2 and\n-      v1 = TBooleanValue(true) and\n-      v2 = v1\n+      exists(BinaryOperation bo |\n+        bo instanceof BitwiseAndExpr or\n+        bo instanceof LogicalAndExpr\n+      |\n+        bo = e1 and\n+        e2 = bo.getAnOperand() and\n+        v1 = TBooleanValue(true) and\n+        v2 = v1\n+        or\n+        bo = e2 and\n+        e1 = bo.getAnOperand() and\n+        v1 = TBooleanValue(false) and\n+        v2 = v1\n+      )\n       or\n-      e1.(LogicalOrExpr).getAnOperand() = e2 and\n-      v1 = TBooleanValue(false) and\n-      v2 = v1\n+      exists(BinaryOperation bo |\n+        bo instanceof BitwiseOrExpr or\n+        bo instanceof LogicalOrExpr\n+      |\n+        bo = e1 and\n+        e2 = bo.getAnOperand() and\n+        v1 = TBooleanValue(false) and\n+        v2 = v1\n+        or\n+        bo = e2 and\n+        e1 = bo.getAnOperand() and\n+        v1 = TBooleanValue(true) and\n+        v2 = v1\n+      )\n       or\n       e1.(LogicalNotExpr).getOperand() = e2 and\n       v2 = TBooleanValue(v1.(BooleanValue).getValue().booleanNot())\n       or\n-      exists(ComparisonTest ct, boolean polarity, BoolLiteral boolLit |\n-        e1 = ct.getExpr() and\n-        ct.getAnArgument() = e2 and\n+      e1 = e2.(LogicalNotExpr).getOperand() and\n+      v2 = TBooleanValue(v1.(BooleanValue).getValue().booleanNot())\n+      or\n+      exists(ComparisonTest ct, boolean polarity, BoolLiteral boolLit, boolean b |\n         ct.getAnArgument() = boolLit and\n-        v2 = TBooleanValue(v1.(BooleanValue).getValue().booleanXor(polarity).booleanXor(boolLit.getBoolValue())) |\n+        b = boolLit.getBoolValue() and\n+        v2 = TBooleanValue(v1.(BooleanValue).getValue().booleanXor(polarity).booleanXor(b)) |\n         ct.getComparisonKind().isEquality() and\n-        polarity = true\n+        polarity = true and\n+        (\n+          // e1 === e2 == b, v1 === !(v2 xor b)\n+          e1 = ct.getExpr() and\n+          e2 = ct.getAnArgument()\n+          or\n+          // e2 === e1 == b, v1 === !(v2 xor b)\n+          e1 = ct.getAnArgument() and\n+          e2 = ct.getExpr()\n+        )\n         or\n         ct.getComparisonKind().isInequality() and\n-        polarity = false\n+        polarity = false and\n+        (\n+          // e1 === e2 != b, v1 === v2 xor b\n+          e1 = ct.getExpr() and\n+          e2 = ct.getAnArgument()\n+          or\n+          // e2 === e1 != true, v1 === v2 xor b","path":"csharp/ql/src/semmle/code/csharp/controlflow/Guards.qll","position":710,"original_position":131,"commit_id":"2d25a04a2ee4146ab04e691900db3751760dbc19","original_commit_id":"f5e6b79addb8676e4a31d7ff5e1b2e8c887a24ef","user":{"login":"hvitved","id":3667920,"node_id":"MDQ6VXNlcjM2Njc5MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3667920?v=4","gravatar_id":"","url":"https://api.github.com/users/hvitved","html_url":"https://github.com/hvitved","followers_url":"https://api.github.com/users/hvitved/followers","following_url":"https://api.github.com/users/hvitved/following{/other_user}","gists_url":"https://api.github.com/users/hvitved/gists{/gist_id}","starred_url":"https://api.github.com/users/hvitved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvitved/subscriptions","organizations_url":"https://api.github.com/users/hvitved/orgs","repos_url":"https://api.github.com/users/hvitved/repos","events_url":"https://api.github.com/users/hvitved/events{/privacy}","received_events_url":"https://api.github.com/users/hvitved/received_events","type":"User","site_admin":false},"body":"Yes, but not worth fixing here I think; I have a follow-up PR anyway.","created_at":"2018-11-06T19:03:31Z","updated_at":"2018-11-06T19:03:32Z","html_url":"https://github.com/Semmle/ql/pull/355#discussion_r231251373","pull_request_url":"https://api.github.com/repos/Semmle/ql/pulls/355","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Semmle/ql/pulls/comments/231251373"},"html":{"href":"https://github.com/Semmle/ql/pull/355#discussion_r231251373"},"pull_request":{"href":"https://api.github.com/repos/Semmle/ql/pulls/355"}},"in_reply_to_id":231223295},"pull_request":{"url":"https://api.github.com/repos/Semmle/ql/pulls/355","id":225324444,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1MzI0NDQ0","html_url":"https://github.com/Semmle/ql/pull/355","diff_url":"https://github.com/Semmle/ql/pull/355.diff","patch_url":"https://github.com/Semmle/ql/pull/355.patch","issue_url":"https://api.github.com/repos/Semmle/ql/issues/355","number":355,"state":"open","locked":false,"title":"C#: Unify logic in guards library","user":{"login":"hvitved","id":3667920,"node_id":"MDQ6VXNlcjM2Njc5MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3667920?v=4","gravatar_id":"","url":"https://api.github.com/users/hvitved","html_url":"https://github.com/hvitved","followers_url":"https://api.github.com/users/hvitved/followers","following_url":"https://api.github.com/users/hvitved/following{/other_user}","gists_url":"https://api.github.com/users/hvitved/gists{/gist_id}","starred_url":"https://api.github.com/users/hvitved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvitved/subscriptions","organizations_url":"https://api.github.com/users/hvitved/orgs","repos_url":"https://api.github.com/users/hvitved/repos","events_url":"https://api.github.com/users/hvitved/events{/privacy}","received_events_url":"https://api.github.com/users/hvitved/received_events","type":"User","site_admin":false},"body":"Follow-up on https://github.com/Semmle/ql/pull/284. This PR joins the predicates `controls()`, `controlsNullness()`, and `controlsMatching()`, as well as the predicates `isGuardedBy()`, `isGuardedByNullness()`, and `isGuardedByMatching()`.\r\n\r\n@calumgrant ","created_at":"2018-10-24T09:16:07Z","updated_at":"2018-11-06T19:03:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c64084d6df4f674bc63a393c8b78328269fc8db3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1013652574,"node_id":"MDU6TGFiZWwxMDEzNjUyNTc0","url":"https://api.github.com/repos/Semmle/ql/labels/C%23","name":"C#","color":"75eada","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Semmle/ql/pulls/355/commits","review_comments_url":"https://api.github.com/repos/Semmle/ql/pulls/355/comments","review_comment_url":"https://api.github.com/repos/Semmle/ql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Semmle/ql/issues/355/comments","statuses_url":"https://api.github.com/repos/Semmle/ql/statuses/2d25a04a2ee4146ab04e691900db3751760dbc19","head":{"label":"hvitved:csharp/guards-logic","ref":"csharp/guards-logic","sha":"2d25a04a2ee4146ab04e691900db3751760dbc19","user":{"login":"hvitved","id":3667920,"node_id":"MDQ6VXNlcjM2Njc5MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3667920?v=4","gravatar_id":"","url":"https://api.github.com/users/hvitved","html_url":"https://github.com/hvitved","followers_url":"https://api.github.com/users/hvitved/followers","following_url":"https://api.github.com/users/hvitved/following{/other_user}","gists_url":"https://api.github.com/users/hvitved/gists{/gist_id}","starred_url":"https://api.github.com/users/hvitved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvitved/subscriptions","organizations_url":"https://api.github.com/users/hvitved/orgs","repos_url":"https://api.github.com/users/hvitved/repos","events_url":"https://api.github.com/users/hvitved/events{/privacy}","received_events_url":"https://api.github.com/users/hvitved/received_events","type":"User","site_admin":false},"repo":{"id":143420270,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM0MjAyNzA=","name":"ql","full_name":"hvitved/ql","private":false,"owner":{"login":"hvitved","id":3667920,"node_id":"MDQ6VXNlcjM2Njc5MjA=","avatar_url":"https://avatars2.githubusercontent.com/u/3667920?v=4","gravatar_id":"","url":"https://api.github.com/users/hvitved","html_url":"https://github.com/hvitved","followers_url":"https://api.github.com/users/hvitved/followers","following_url":"https://api.github.com/users/hvitved/following{/other_user}","gists_url":"https://api.github.com/users/hvitved/gists{/gist_id}","starred_url":"https://api.github.com/users/hvitved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hvitved/subscriptions","organizations_url":"https://api.github.com/users/hvitved/orgs","repos_url":"https://api.github.com/users/hvitved/repos","events_url":"https://api.github.com/users/hvitved/events{/privacy}","received_events_url":"https://api.github.com/users/hvitved/received_events","type":"User","site_admin":false},"html_url":"https://github.com/hvitved/ql","description":null,"fork":true,"url":"https://api.github.com/repos/hvitved/ql","forks_url":"https://api.github.com/repos/hvitved/ql/forks","keys_url":"https://api.github.com/repos/hvitved/ql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hvitved/ql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hvitved/ql/teams","hooks_url":"https://api.github.com/repos/hvitved/ql/hooks","issue_events_url":"https://api.github.com/repos/hvitved/ql/issues/events{/number}","events_url":"https://api.github.com/repos/hvitved/ql/events","assignees_url":"https://api.github.com/repos/hvitved/ql/assignees{/user}","branches_url":"https://api.github.com/repos/hvitved/ql/branches{/branch}","tags_url":"https://api.github.com/repos/hvitved/ql/tags","blobs_url":"https://api.github.com/repos/hvitved/ql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hvitved/ql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hvitved/ql/git/refs{/sha}","trees_url":"https://api.github.com/repos/hvitved/ql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hvitved/ql/statuses/{sha}","languages_url":"https://api.github.com/repos/hvitved/ql/languages","stargazers_url":"https://api.github.com/repos/hvitved/ql/stargazers","contributors_url":"https://api.github.com/repos/hvitved/ql/contributors","subscribers_url":"https://api.github.com/repos/hvitved/ql/subscribers","subscription_url":"https://api.github.com/repos/hvitved/ql/subscription","commits_url":"https://api.github.com/repos/hvitved/ql/commits{/sha}","git_commits_url":"https://api.github.com/repos/hvitved/ql/git/commits{/sha}","comments_url":"https://api.github.com/repos/hvitved/ql/comments{/number}","issue_comment_url":"https://api.github.com/repos/hvitved/ql/issues/comments{/number}","contents_url":"https://api.github.com/repos/hvitved/ql/contents/{+path}","compare_url":"https://api.github.com/repos/hvitved/ql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hvitved/ql/merges","archive_url":"https://api.github.com/repos/hvitved/ql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hvitved/ql/downloads","issues_url":"https://api.github.com/repos/hvitved/ql/issues{/number}","pulls_url":"https://api.github.com/repos/hvitved/ql/pulls{/number}","milestones_url":"https://api.github.com/repos/hvitved/ql/milestones{/number}","notifications_url":"https://api.github.com/repos/hvitved/ql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hvitved/ql/labels{/name}","releases_url":"https://api.github.com/repos/hvitved/ql/releases{/id}","deployments_url":"https://api.github.com/repos/hvitved/ql/deployments","created_at":"2018-08-03T11:40:27Z","updated_at":"2018-08-07T00:46:53Z","pushed_at":"2018-11-06T15:46:14Z","git_url":"git://github.com/hvitved/ql.git","ssh_url":"git@github.com:hvitved/ql.git","clone_url":"https://github.com/hvitved/ql.git","svn_url":"https://github.com/hvitved/ql","homepage":null,"size":9158,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Semmle:master","ref":"master","sha":"336f6051530a9e45cadd73cd86c17f4ebec697e7","user":{"login":"Semmle","id":1101495,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMDE0OTU=","avatar_url":"https://avatars0.githubusercontent.com/u/1101495?v=4","gravatar_id":"","url":"https://api.github.com/users/Semmle","html_url":"https://github.com/Semmle","followers_url":"https://api.github.com/users/Semmle/followers","following_url":"https://api.github.com/users/Semmle/following{/other_user}","gists_url":"https://api.github.com/users/Semmle/gists{/gist_id}","starred_url":"https://api.github.com/users/Semmle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Semmle/subscriptions","organizations_url":"https://api.github.com/users/Semmle/orgs","repos_url":"https://api.github.com/users/Semmle/repos","events_url":"https://api.github.com/users/Semmle/events{/privacy}","received_events_url":"https://api.github.com/users/Semmle/received_events","type":"Organization","site_admin":false},"repo":{"id":143040428,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMwNDA0Mjg=","name":"ql","full_name":"Semmle/ql","private":false,"owner":{"login":"Semmle","id":1101495,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMDE0OTU=","avatar_url":"https://avatars0.githubusercontent.com/u/1101495?v=4","gravatar_id":"","url":"https://api.github.com/users/Semmle","html_url":"https://github.com/Semmle","followers_url":"https://api.github.com/users/Semmle/followers","following_url":"https://api.github.com/users/Semmle/following{/other_user}","gists_url":"https://api.github.com/users/Semmle/gists{/gist_id}","starred_url":"https://api.github.com/users/Semmle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Semmle/subscriptions","organizations_url":"https://api.github.com/users/Semmle/orgs","repos_url":"https://api.github.com/users/Semmle/repos","events_url":"https://api.github.com/users/Semmle/events{/privacy}","received_events_url":"https://api.github.com/users/Semmle/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Semmle/ql","description":"The standard QL libraries and queries that power LGTM.com and other Semmle Products","fork":false,"url":"https://api.github.com/repos/Semmle/ql","forks_url":"https://api.github.com/repos/Semmle/ql/forks","keys_url":"https://api.github.com/repos/Semmle/ql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Semmle/ql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Semmle/ql/teams","hooks_url":"https://api.github.com/repos/Semmle/ql/hooks","issue_events_url":"https://api.github.com/repos/Semmle/ql/issues/events{/number}","events_url":"https://api.github.com/repos/Semmle/ql/events","assignees_url":"https://api.github.com/repos/Semmle/ql/assignees{/user}","branches_url":"https://api.github.com/repos/Semmle/ql/branches{/branch}","tags_url":"https://api.github.com/repos/Semmle/ql/tags","blobs_url":"https://api.github.com/repos/Semmle/ql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Semmle/ql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Semmle/ql/git/refs{/sha}","trees_url":"https://api.github.com/repos/Semmle/ql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Semmle/ql/statuses/{sha}","languages_url":"https://api.github.com/repos/Semmle/ql/languages","stargazers_url":"https://api.github.com/repos/Semmle/ql/stargazers","contributors_url":"https://api.github.com/repos/Semmle/ql/contributors","subscribers_url":"https://api.github.com/repos/Semmle/ql/subscribers","subscription_url":"https://api.github.com/repos/Semmle/ql/subscription","commits_url":"https://api.github.com/repos/Semmle/ql/commits{/sha}","git_commits_url":"https://api.github.com/repos/Semmle/ql/git/commits{/sha}","comments_url":"https://api.github.com/repos/Semmle/ql/comments{/number}","issue_comment_url":"https://api.github.com/repos/Semmle/ql/issues/comments{/number}","contents_url":"https://api.github.com/repos/Semmle/ql/contents/{+path}","compare_url":"https://api.github.com/repos/Semmle/ql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Semmle/ql/merges","archive_url":"https://api.github.com/repos/Semmle/ql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Semmle/ql/downloads","issues_url":"https://api.github.com/repos/Semmle/ql/issues{/number}","pulls_url":"https://api.github.com/repos/Semmle/ql/pulls{/number}","milestones_url":"https://api.github.com/repos/Semmle/ql/milestones{/number}","notifications_url":"https://api.github.com/repos/Semmle/ql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Semmle/ql/labels{/name}","releases_url":"https://api.github.com/repos/Semmle/ql/releases{/id}","deployments_url":"https://api.github.com/repos/Semmle/ql/deployments","created_at":"2018-07-31T16:35:51Z","updated_at":"2018-11-06T18:51:21Z","pushed_at":"2018-11-06T18:51:13Z","git_url":"git://github.com/Semmle/ql.git","ssh_url":"git@github.com:Semmle/ql.git","clone_url":"https://github.com/Semmle/ql.git","svn_url":"https://github.com/Semmle/ql","homepage":"https://semmle.com/ql","size":9399,"stargazers_count":57,"watchers_count":57,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":42,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":39,"open_issues":42,"watchers":57,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Semmle/ql/pulls/355"},"html":{"href":"https://github.com/Semmle/ql/pull/355"},"issue":{"href":"https://api.github.com/repos/Semmle/ql/issues/355"},"comments":{"href":"https://api.github.com/repos/Semmle/ql/issues/355/comments"},"review_comments":{"href":"https://api.github.com/repos/Semmle/ql/pulls/355/comments"},"review_comment":{"href":"https://api.github.com/repos/Semmle/ql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Semmle/ql/pulls/355/commits"},"statuses":{"href":"https://api.github.com/repos/Semmle/ql/statuses/2d25a04a2ee4146ab04e691900db3751760dbc19"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"hvitved"}}