{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/comments/107316139","pull_request_review_id":28279643,"id":107316139,"diff_hunk":"@@ -10621,6 +10621,73 @@ void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,\n                                         << RHSExpr->getSourceRange();\n }\n \n+\n+//===--- CHECK: Checked scope -------------------------===//\n+void Sema::DiagnoseCheckedDecl(const DeclStmt *DS) {\n+  // Checked C - check consistency between compound stmt checked property\n+  // and declaration type\n+  DeclGroupRef DG = DS->getDeclGroup();\n+  for (DeclGroupRef::const_iterator D = DG.begin(), DEnd = DG.end(); D != DEnd;\n+       ++D) {\n+    if (const VarDecl *VD = dyn_cast<VarDecl>(*D)) {\n+      DiagnoseCheckedDecl(VD);\n+    }\n+  }\n+}\n+\n+// type restrictions on declaration in checked blocks\n+void Sema::DiagnoseCheckedDecl(const DeclaratorDecl *Decl) {\n+  // Checked C - check consistency between checked property and declaration\n+  // checked pointer type or unchecked pointer type with bounds-safe interface\n+  // is only allowed in checked scope or funcion\n+  const DeclaratorDecl *TargetDecl = nullptr;\n+  int DeclKind;\n+  QualType Ty;\n+  if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(Decl)) {\n+    TargetDecl = Parm;\n+    DeclKind = 0; // function param\n+    Ty = Parm->getType();\n+  }\n+  else if (const FunctionDecl *Func = dyn_cast<FunctionDecl>(Decl)) {\n+    TargetDecl = Func;\n+    DeclKind = 1; // function return\n+    Ty = Func->getReturnType();\n+  }\n+  else if (const VarDecl *Var = dyn_cast<VarDecl>(Decl)) {\n+    TargetDecl = Var;\n+    DeclKind = 2; // decl var\n+    Ty = Var->getType();\n+  }\n+  else if (const FieldDecl *Field = dyn_cast<FieldDecl>(Decl)) {\n+    TargetDecl = Field;\n+    DeclKind = 3; // member\n+    Ty = Field->getType();\n+  }\n+\n+  bool checkedScopeError = false;\n+  int TypeKind = 0;\n+  if (TargetDecl) {\n+    // type is unchecked pointer w/o bounds-safe interface\n+    // type is unchecked pointer & its bounds-safe interface is also unchecked\n+    QualType InterOpTy = GetCheckedCInteropType(TargetDecl);\n+    if ((Ty->isUncheckedPointerType() || Ty->isUncheckedArrayType()) &&\n+        (InterOpTy.isNull() || (InterOpTy->isUncheckedPointerType() ||\n+                                InterOpTy->isUncheckedArrayType()))) {\n+      checkedScopeError = true;\n+      TypeKind =","path":"lib/Sema/SemaChecking.cpp","position":57,"original_position":57,"commit_id":"43ccad3405255d803b7c84cf705f83ac0a8d98b5","original_commit_id":"43ccad3405255d803b7c84cf705f83ac0a8d98b5","user":{"login":"wonsubkim","id":25519089,"avatar_url":"https://avatars2.githubusercontent.com/u/25519089?v=3","gravatar_id":"","url":"https://api.github.com/users/wonsubkim","html_url":"https://github.com/wonsubkim","followers_url":"https://api.github.com/users/wonsubkim/followers","following_url":"https://api.github.com/users/wonsubkim/following{/other_user}","gists_url":"https://api.github.com/users/wonsubkim/gists{/gist_id}","starred_url":"https://api.github.com/users/wonsubkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wonsubkim/subscriptions","organizations_url":"https://api.github.com/users/wonsubkim/orgs","repos_url":"https://api.github.com/users/wonsubkim/repos","events_url":"https://api.github.com/users/wonsubkim/events{/privacy}","received_events_url":"https://api.github.com/users/wonsubkim/received_events","type":"User","site_admin":false},"body":"I have missed that interoperation type (itype) SHOULD require checked type\r\nIf interop type is not null, it is definitely checked type.\r\nSo, it is not necessary to check if interop type is checked or unchecked\r\nI will simplify above codes","created_at":"2017-03-22T01:34:35Z","updated_at":"2017-03-22T01:34:35Z","html_url":"https://github.com/Microsoft/checkedc-clang/pull/193#discussion_r107316139","pull_request_url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/comments/107316139"},"html":{"href":"https://github.com/Microsoft/checkedc-clang/pull/193#discussion_r107316139"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193","id":110998208,"html_url":"https://github.com/Microsoft/checkedc-clang/pull/193","diff_url":"https://github.com/Microsoft/checkedc-clang/pull/193.diff","patch_url":"https://github.com/Microsoft/checkedc-clang/pull/193.patch","issue_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/193","number":193,"state":"open","locked":false,"title":"Add initial version of checked scope/function implementation","user":{"login":"wonsubkim","id":25519089,"avatar_url":"https://avatars2.githubusercontent.com/u/25519089?v=3","gravatar_id":"","url":"https://api.github.com/users/wonsubkim","html_url":"https://github.com/wonsubkim","followers_url":"https://api.github.com/users/wonsubkim/followers","following_url":"https://api.github.com/users/wonsubkim/following{/other_user}","gists_url":"https://api.github.com/users/wonsubkim/gists{/gist_id}","starred_url":"https://api.github.com/users/wonsubkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wonsubkim/subscriptions","organizations_url":"https://api.github.com/users/wonsubkim/orgs","repos_url":"https://api.github.com/users/wonsubkim/repos","events_url":"https://api.github.com/users/wonsubkim/events{/privacy}","received_events_url":"https://api.github.com/users/wonsubkim/received_events","type":"User","site_admin":false},"body":"Implemented checked scope/function\r\nchecked function\r\n - checked keyword is before function definition\r\n - checked keyword is regarded as function specifier in implementation\r\n - checked function specifier affects function declaration scope & function definition scope\r\n - in function declaration, it checks if function parameter type & return type is proper for checked scope\r\n - in function definition, it checks if function definition statement body is regarded as checked compound scope\r\n\r\nchecked scope\r\n - checked keyword is before l_brace\r\n - this compound statment is regarded as checked block\r\n - in checked compound statments, all declaration can have checked pointer type or unchecked pointer type with bounds-safe interface\r\n - otherwise, compiler emits compilation error\r\n\r\nAlso relative alignment bug fix is added in this pull request","created_at":"2017-03-16T05:54:21Z","updated_at":"2017-03-22T01:34:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e4159d098a48364c589f0de559dbf47e4fe801f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193/commits","review_comments_url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193/comments","review_comment_url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/193/comments","statuses_url":"https://api.github.com/repos/Microsoft/checkedc-clang/statuses/43ccad3405255d803b7c84cf705f83ac0a8d98b5","head":{"label":"wonsubkim:issue-189","ref":"issue-189","sha":"43ccad3405255d803b7c84cf705f83ac0a8d98b5","user":{"login":"wonsubkim","id":25519089,"avatar_url":"https://avatars2.githubusercontent.com/u/25519089?v=3","gravatar_id":"","url":"https://api.github.com/users/wonsubkim","html_url":"https://github.com/wonsubkim","followers_url":"https://api.github.com/users/wonsubkim/followers","following_url":"https://api.github.com/users/wonsubkim/following{/other_user}","gists_url":"https://api.github.com/users/wonsubkim/gists{/gist_id}","starred_url":"https://api.github.com/users/wonsubkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wonsubkim/subscriptions","organizations_url":"https://api.github.com/users/wonsubkim/orgs","repos_url":"https://api.github.com/users/wonsubkim/repos","events_url":"https://api.github.com/users/wonsubkim/events{/privacy}","received_events_url":"https://api.github.com/users/wonsubkim/received_events","type":"User","site_admin":false},"repo":{"id":80797887,"name":"checkedc-clang","full_name":"wonsubkim/checkedc-clang","owner":{"login":"wonsubkim","id":25519089,"avatar_url":"https://avatars2.githubusercontent.com/u/25519089?v=3","gravatar_id":"","url":"https://api.github.com/users/wonsubkim","html_url":"https://github.com/wonsubkim","followers_url":"https://api.github.com/users/wonsubkim/followers","following_url":"https://api.github.com/users/wonsubkim/following{/other_user}","gists_url":"https://api.github.com/users/wonsubkim/gists{/gist_id}","starred_url":"https://api.github.com/users/wonsubkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wonsubkim/subscriptions","organizations_url":"https://api.github.com/users/wonsubkim/orgs","repos_url":"https://api.github.com/users/wonsubkim/repos","events_url":"https://api.github.com/users/wonsubkim/events{/privacy}","received_events_url":"https://api.github.com/users/wonsubkim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wonsubkim/checkedc-clang","description":"This repo contains a version of clang that is being modified to support Checked C.   Checked C is an extension to C that adds checking to detect or prevent common programming errors such as out-of-bounds memory accesses.","fork":true,"url":"https://api.github.com/repos/wonsubkim/checkedc-clang","forks_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/forks","keys_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/teams","hooks_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/hooks","issue_events_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/issues/events{/number}","events_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/events","assignees_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/assignees{/user}","branches_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/branches{/branch}","tags_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/tags","blobs_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/git/refs{/sha}","trees_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/statuses/{sha}","languages_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/languages","stargazers_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/stargazers","contributors_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/contributors","subscribers_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/subscribers","subscription_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/subscription","commits_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/commits{/sha}","git_commits_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/git/commits{/sha}","comments_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/comments{/number}","issue_comment_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/issues/comments{/number}","contents_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/contents/{+path}","compare_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/merges","archive_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/downloads","issues_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/issues{/number}","pulls_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/pulls{/number}","milestones_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/milestones{/number}","notifications_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/labels{/name}","releases_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/releases{/id}","deployments_url":"https://api.github.com/repos/wonsubkim/checkedc-clang/deployments","created_at":"2017-02-03T04:47:46Z","updated_at":"2017-02-03T04:48:13Z","pushed_at":"2017-03-21T09:46:49Z","git_url":"git://github.com/wonsubkim/checkedc-clang.git","ssh_url":"git@github.com:wonsubkim/checkedc-clang.git","clone_url":"https://github.com/wonsubkim/checkedc-clang.git","svn_url":"https://github.com/wonsubkim/checkedc-clang","homepage":"","size":272229,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"be76e36f61d516c27622fb9153b66470e4d25cc9","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":60645050,"name":"checkedc-clang","full_name":"Microsoft/checkedc-clang","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars1.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/checkedc-clang","description":"This repo contains a version of clang that is being modified to support Checked C.   Checked C is an extension to C that adds checking to detect or prevent common programming errors such as out-of-bounds memory accesses.","fork":false,"url":"https://api.github.com/repos/Microsoft/checkedc-clang","forks_url":"https://api.github.com/repos/Microsoft/checkedc-clang/forks","keys_url":"https://api.github.com/repos/Microsoft/checkedc-clang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/checkedc-clang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/checkedc-clang/teams","hooks_url":"https://api.github.com/repos/Microsoft/checkedc-clang/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/checkedc-clang/events","assignees_url":"https://api.github.com/repos/Microsoft/checkedc-clang/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/checkedc-clang/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/checkedc-clang/tags","blobs_url":"https://api.github.com/repos/Microsoft/checkedc-clang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/checkedc-clang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/checkedc-clang/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/checkedc-clang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/checkedc-clang/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/checkedc-clang/languages","stargazers_url":"https://api.github.com/repos/Microsoft/checkedc-clang/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/checkedc-clang/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/checkedc-clang/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/checkedc-clang/subscription","commits_url":"https://api.github.com/repos/Microsoft/checkedc-clang/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/checkedc-clang/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/checkedc-clang/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/checkedc-clang/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/checkedc-clang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/checkedc-clang/merges","archive_url":"https://api.github.com/repos/Microsoft/checkedc-clang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/checkedc-clang/downloads","issues_url":"https://api.github.com/repos/Microsoft/checkedc-clang/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/checkedc-clang/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/checkedc-clang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/checkedc-clang/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/checkedc-clang/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/checkedc-clang/deployments","created_at":"2016-06-07T20:43:32Z","updated_at":"2017-03-21T14:44:03Z","pushed_at":"2017-03-21T17:24:19Z","git_url":"git://github.com/Microsoft/checkedc-clang.git","ssh_url":"git@github.com:Microsoft/checkedc-clang.git","clone_url":"https://github.com/Microsoft/checkedc-clang.git","svn_url":"https://github.com/Microsoft/checkedc-clang","homepage":"","size":271920,"stargazers_count":116,"watchers_count":116,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":61,"forks":16,"open_issues":61,"watchers":116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193"},"html":{"href":"https://github.com/Microsoft/checkedc-clang/pull/193"},"issue":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/193"},"comments":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/issues/193/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/pulls/193/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/checkedc-clang/statuses/43ccad3405255d803b7c84cf705f83ac0a8d98b5"}}}}
{"actor":{"display_login":"wonsubkim"}}