{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/55","repository_url":"https://api.github.com/repos/Microsoft/checkedc-clang","labels_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/55/comments","events_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/55/events","html_url":"https://github.com/Microsoft/checkedc-clang/pull/55","id":177613172,"number":55,"title":"Parse and represent bounds-safe interface type annotations","user":{"login":"dtarditi","id":11841034,"avatar_url":"https://avatars.githubusercontent.com/u/11841034?v=3","gravatar_id":"","url":"https://api.github.com/users/dtarditi","html_url":"https://github.com/dtarditi","followers_url":"https://api.github.com/users/dtarditi/followers","following_url":"https://api.github.com/users/dtarditi/following{/other_user}","gists_url":"https://api.github.com/users/dtarditi/gists{/gist_id}","starred_url":"https://api.github.com/users/dtarditi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtarditi/subscriptions","organizations_url":"https://api.github.com/users/dtarditi/orgs","repos_url":"https://api.github.com/users/dtarditi/repos","events_url":"https://api.github.com/users/dtarditi/events{/privacy}","received_events_url":"https://api.github.com/users/dtarditi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/checkedc-clang/labels/cla-not-required","name":"cla-not-required","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"awruef","id":2530731,"avatar_url":"https://avatars.githubusercontent.com/u/2530731?v=3","gravatar_id":"","url":"https://api.github.com/users/awruef","html_url":"https://github.com/awruef","followers_url":"https://api.github.com/users/awruef/followers","following_url":"https://api.github.com/users/awruef/following{/other_user}","gists_url":"https://api.github.com/users/awruef/gists{/gist_id}","starred_url":"https://api.github.com/users/awruef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awruef/subscriptions","organizations_url":"https://api.github.com/users/awruef/orgs","repos_url":"https://api.github.com/users/awruef/repos","events_url":"https://api.github.com/users/awruef/events{/privacy}","received_events_url":"https://api.github.com/users/awruef/received_events","type":"User","site_admin":false},"assignees":[{"login":"awruef","id":2530731,"avatar_url":"https://avatars.githubusercontent.com/u/2530731?v=3","gravatar_id":"","url":"https://api.github.com/users/awruef","html_url":"https://github.com/awruef","followers_url":"https://api.github.com/users/awruef/followers","following_url":"https://api.github.com/users/awruef/following{/other_user}","gists_url":"https://api.github.com/users/awruef/gists{/gist_id}","starred_url":"https://api.github.com/users/awruef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awruef/subscriptions","organizations_url":"https://api.github.com/users/awruef/orgs","repos_url":"https://api.github.com/users/awruef/repos","events_url":"https://api.github.com/users/awruef/events{/privacy}","received_events_url":"https://api.github.com/users/awruef/received_events","type":"User","site_admin":false},{"login":"reubeno","id":10508433,"avatar_url":"https://avatars.githubusercontent.com/u/10508433?v=3","gravatar_id":"","url":"https://api.github.com/users/reubeno","html_url":"https://github.com/reubeno","followers_url":"https://api.github.com/users/reubeno/followers","following_url":"https://api.github.com/users/reubeno/following{/other_user}","gists_url":"https://api.github.com/users/reubeno/gists{/gist_id}","starred_url":"https://api.github.com/users/reubeno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reubeno/subscriptions","organizations_url":"https://api.github.com/users/reubeno/orgs","repos_url":"https://api.github.com/users/reubeno/repos","events_url":"https://api.github.com/users/reubeno/events{/privacy}","received_events_url":"https://api.github.com/users/reubeno/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-09-17T22:13:06Z","updated_at":"2016-09-21T17:33:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/55","html_url":"https://github.com/Microsoft/checkedc-clang/pull/55","diff_url":"https://github.com/Microsoft/checkedc-clang/pull/55.diff","patch_url":"https://github.com/Microsoft/checkedc-clang/pull/55.patch"},"body":"This change implements parsing of bounds-safe interface type annotations.  The type annotations are a generalization of the `int * x : ptr` annotation described in the specification.    That annotation does not provide a way to represent information for pointers with multiple levels of indirection (`int **x` for example).   Instead of just using `ptr`, we will allow a checked pointer type be specified.   The annotation for something like `int **` could be `_Ptr<_Ptr<int>>`.   This richer form is needed so that we can represent bounds-safe interfaces where pointers are passed by reference, for example.\r\n\r\nWe require that the type be a pointer type that starts with `_Ptr` or `_Array_ptr`, so that we can distinguish between whether we need to parse a type or a bounds expression.  We will lave the possibility of generalizing this to handle a typedef'ed name for the future.   We create a subclass of `BoundsExpr` to represent the new annotation, even though this annotation is not really a bounds expression.   It will be needed in the same places in the compiler where bounds expressions are needed.\r\n\r\nThe bounds-safe interface type annotations do not need to be delay parsed for parameters or structure/union members.   They don't refer to other parameters or members.  We special case this in the parser.   This simplifies the code because we don't have to implement delay parsing for types.\r\n\r\nFor structure/union members, we now store the bounds annotation or the tokens to be delayed parsed in the FieldDeclarator structure (which already stores the bitsize expression for a member).   This uet us revent changes to the callback method that passed the tokens as extra arguments.\r\n\r\nThis change also fixes a bug that I noticed in stmt serialization.  We weren't writing out the kind field for RangeBoundsExpr.   It is possible to have an invalid kind field (this could happen if someone serializes IR with invalid bounds expressions.  I also cleaned up serialization code that needs to access some private members.  We had setter methods - I noticed the rest of the serialization code is using friend classes instead.\r\n\r\nTesting:\r\n- Passes existing clang and Checked C tests.\r\n- A new test for parsing these annotations will be added to the Checked C repo by a separate commit."},"comment":{"url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/comments/248685075","html_url":"https://github.com/Microsoft/checkedc-clang/pull/55#issuecomment-248685075","issue_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/55","id":248685075,"user":{"login":"dtarditi","id":11841034,"avatar_url":"https://avatars.githubusercontent.com/u/11841034?v=3","gravatar_id":"","url":"https://api.github.com/users/dtarditi","html_url":"https://github.com/dtarditi","followers_url":"https://api.github.com/users/dtarditi/followers","following_url":"https://api.github.com/users/dtarditi/following{/other_user}","gists_url":"https://api.github.com/users/dtarditi/gists{/gist_id}","starred_url":"https://api.github.com/users/dtarditi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtarditi/subscriptions","organizations_url":"https://api.github.com/users/dtarditi/orgs","repos_url":"https://api.github.com/users/dtarditi/repos","events_url":"https://api.github.com/users/dtarditi/events{/privacy}","received_events_url":"https://api.github.com/users/dtarditi/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T17:33:43Z","updated_at":"2016-09-21T17:33:43Z","body":"Reuben has suggested that we make type annotations in bounds-safe interfaces be parallel bounds declarations and have a keyword that starts them.   This would allow us to parse an arbitrary type name, and allow the use of type names in bounds-safe type annotation.   So we would write something like:\r\n\r\nint *x : type(ptr<int>);\r\n\r\nor\r\n\r\ntypedef ptr<int> pint\r\n\r\nint *x : type(pint);\r\n\r\nThe idenitifer 'type' is my suggestion for the keyword.   I'm open to better suggestions, of course.\r\n\r\nI think Reuben's suggestion is great, so I'm going to update the PR with this change."}}
{"actor":{"display_login":"dtarditi"}}