{"action":"created","comment":{"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments/49521013","id":49521013,"diff_hunk":"@@ -186,23 +186,133 @@ ModuleLayoutSection ValidationState_t::getLayoutStage() const {\n }\n \n void ValidationState_t::progressToNextLayoutStageOrder() {\n-  module_layout_order_stage_ +=\n-      module_layout_order_stage_ < GetModuleOrder().size();\n-  if (module_layout_order_stage_ >= GetModuleOrder().size()) {\n-    current_layout_stage_ = libspirv::ModuleLayoutSection::kFunction;\n+  if (current_layout_stage_ <= GetModuleOrder().size()) {\n+    current_layout_stage_ =\n+        static_cast<ModuleLayoutSection>(current_layout_stage_ + 1);\n   }\n }\n \n bool ValidationState_t::isOpcodeInCurrentLayoutStage(SpvOp op) {\n-  const vector<SpvOp>& currentStage =\n-      GetModuleOrder()[module_layout_order_stage_];\n+  const vector<SpvOp>& currentStage = GetModuleOrder()[current_layout_stage_];\n   return end(currentStage) != find(begin(currentStage), end(currentStage), op);\n }\n \n-libspirv::DiagnosticStream ValidationState_t::diag(\n-    spv_result_t error_code) const {\n+DiagnosticStream ValidationState_t::diag(spv_result_t error_code) const {\n   return libspirv::DiagnosticStream(\n       {0, 0, static_cast<size_t>(instruction_counter_)}, diagnostic_,\n       error_code);\n }\n+\n+Functions& ValidationState_t::get_functions() { return module_functions_; }\n+\n+bool ValidationState_t::in_function_body() const {\n+  return module_functions_.in_function_body();\n+}\n+\n+bool ValidationState_t::in_block() const {\n+  return module_functions_.in_block();\n+}\n+\n+Functions::Functions(ValidationState_t& module)\n+    : module_(module), in_function_(false), in_block_(false) {}\n+\n+bool Functions::in_function_body() const { return in_function_; }\n+\n+bool Functions::in_block() const { return in_block_; }\n+\n+spv_result_t Functions::RegisterFunction(uint32_t id, uint32_t ret_type_id,\n+                                         uint32_t function_control,\n+                                         uint32_t function_type_id) {\n+  assert(in_function_ == false &&\n+         \"Function instructions can not be declared in a function\");\n+  in_function_ = true;\n+  id_.emplace_back(id);\n+  type_id_.emplace_back(function_type_id);\n+  declaration_type_.emplace_back(FunctionDecl::kFunctionDeclUnknown);\n+  block_ids_.emplace_back();\n+  variable_ids_.emplace_back();\n+  parameter_ids_.emplace_back();\n+\n+  // TODO(umar): validate function type and type_id\n+  (void)ret_type_id;\n+  (void)function_control;\n+\n+  return SPV_SUCCESS;\n+}\n+\n+spv_result_t Functions::RegisterFunctionParameter(uint32_t id,\n+                                                  uint32_t type_id) {\n+  assert(in_function_ == true &&\n+         \"Function parameter instructions can not be declared of a function\");\n+  (void)id;\n+  (void)type_id;","path":"source/validate_types.cpp","position":100,"original_position":100,"commit_id":"6a4e5a6c6adafaed8fb8c9ea6f5983eb1c5eadd8","original_commit_id":"6a4e5a6c6adafaed8fb8c9ea6f5983eb1c5eadd8","user":{"login":"umar456","id":457510,"avatar_url":"https://avatars.githubusercontent.com/u/457510?v=3","gravatar_id":"","url":"https://api.github.com/users/umar456","html_url":"https://github.com/umar456","followers_url":"https://api.github.com/users/umar456/followers","following_url":"https://api.github.com/users/umar456/following{/other_user}","gists_url":"https://api.github.com/users/umar456/gists{/gist_id}","starred_url":"https://api.github.com/users/umar456/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umar456/subscriptions","organizations_url":"https://api.github.com/users/umar456/orgs","repos_url":"https://api.github.com/users/umar456/repos","events_url":"https://api.github.com/users/umar456/events{/privacy}","received_events_url":"https://api.github.com/users/umar456/received_events","type":"User","site_admin":false},"body":"I am eventually going to check the parameter type and use the id in some way. This is done to avoid unused parameter warnings in clang.","created_at":"2016-01-12T22:03:28Z","updated_at":"2016-01-12T22:03:28Z","html_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/51#discussion_r49521013","pull_request_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51","_links":{"self":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments/49521013"},"html":{"href":"https://github.com/KhronosGroup/SPIRV-Tools/pull/51#discussion_r49521013"},"pull_request":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51","id":54597187,"html_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/51","diff_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/51.diff","patch_url":"https://github.com/KhronosGroup/SPIRV-Tools/pull/51.patch","issue_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/51","number":51,"state":"open","locked":false,"title":"Additional logical layout checks","user":{"login":"umar456","id":457510,"avatar_url":"https://avatars.githubusercontent.com/u/457510?v=3","gravatar_id":"","url":"https://api.github.com/users/umar456","html_url":"https://github.com/umar456","followers_url":"https://api.github.com/users/umar456/followers","following_url":"https://api.github.com/users/umar456/following{/other_user}","gists_url":"https://api.github.com/users/umar456/gists{/gist_id}","starred_url":"https://api.github.com/users/umar456/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umar456/subscriptions","organizations_url":"https://api.github.com/users/umar456/orgs","repos_url":"https://api.github.com/users/umar456/repos","events_url":"https://api.github.com/users/umar456/events{/privacy}","received_events_url":"https://api.github.com/users/umar456/received_events","type":"User","site_admin":false},"body":"This PR should provide complete checks for logical layout of a module. \r\n\r\nAdded:\r\n* Missing memory model check\r\n* Variable storage class checks\r\n* Function definition and declaration ordering\r\n* Label/branch instruction checks","created_at":"2015-12-26T05:00:08Z","updated_at":"2016-01-12T22:03:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efcb53d209eb12e1d0e920d00a0c86b151982cef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51/commits","review_comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51/comments","review_comment_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/51/comments","statuses_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/statuses/6a4e5a6c6adafaed8fb8c9ea6f5983eb1c5eadd8","head":{"label":"umar456:layout","ref":"layout","sha":"6a4e5a6c6adafaed8fb8c9ea6f5983eb1c5eadd8","user":{"login":"umar456","id":457510,"avatar_url":"https://avatars.githubusercontent.com/u/457510?v=3","gravatar_id":"","url":"https://api.github.com/users/umar456","html_url":"https://github.com/umar456","followers_url":"https://api.github.com/users/umar456/followers","following_url":"https://api.github.com/users/umar456/following{/other_user}","gists_url":"https://api.github.com/users/umar456/gists{/gist_id}","starred_url":"https://api.github.com/users/umar456/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umar456/subscriptions","organizations_url":"https://api.github.com/users/umar456/orgs","repos_url":"https://api.github.com/users/umar456/repos","events_url":"https://api.github.com/users/umar456/events{/privacy}","received_events_url":"https://api.github.com/users/umar456/received_events","type":"User","site_admin":false},"repo":{"id":46513608,"name":"SPIRV-Tools","full_name":"umar456/SPIRV-Tools","owner":{"login":"umar456","id":457510,"avatar_url":"https://avatars.githubusercontent.com/u/457510?v=3","gravatar_id":"","url":"https://api.github.com/users/umar456","html_url":"https://github.com/umar456","followers_url":"https://api.github.com/users/umar456/followers","following_url":"https://api.github.com/users/umar456/following{/other_user}","gists_url":"https://api.github.com/users/umar456/gists{/gist_id}","starred_url":"https://api.github.com/users/umar456/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umar456/subscriptions","organizations_url":"https://api.github.com/users/umar456/orgs","repos_url":"https://api.github.com/users/umar456/repos","events_url":"https://api.github.com/users/umar456/events{/privacy}","received_events_url":"https://api.github.com/users/umar456/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/umar456/SPIRV-Tools","description":"","fork":true,"url":"https://api.github.com/repos/umar456/SPIRV-Tools","forks_url":"https://api.github.com/repos/umar456/SPIRV-Tools/forks","keys_url":"https://api.github.com/repos/umar456/SPIRV-Tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/umar456/SPIRV-Tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/umar456/SPIRV-Tools/teams","hooks_url":"https://api.github.com/repos/umar456/SPIRV-Tools/hooks","issue_events_url":"https://api.github.com/repos/umar456/SPIRV-Tools/issues/events{/number}","events_url":"https://api.github.com/repos/umar456/SPIRV-Tools/events","assignees_url":"https://api.github.com/repos/umar456/SPIRV-Tools/assignees{/user}","branches_url":"https://api.github.com/repos/umar456/SPIRV-Tools/branches{/branch}","tags_url":"https://api.github.com/repos/umar456/SPIRV-Tools/tags","blobs_url":"https://api.github.com/repos/umar456/SPIRV-Tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/umar456/SPIRV-Tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/umar456/SPIRV-Tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/umar456/SPIRV-Tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/umar456/SPIRV-Tools/statuses/{sha}","languages_url":"https://api.github.com/repos/umar456/SPIRV-Tools/languages","stargazers_url":"https://api.github.com/repos/umar456/SPIRV-Tools/stargazers","contributors_url":"https://api.github.com/repos/umar456/SPIRV-Tools/contributors","subscribers_url":"https://api.github.com/repos/umar456/SPIRV-Tools/subscribers","subscription_url":"https://api.github.com/repos/umar456/SPIRV-Tools/subscription","commits_url":"https://api.github.com/repos/umar456/SPIRV-Tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/umar456/SPIRV-Tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/umar456/SPIRV-Tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/umar456/SPIRV-Tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/umar456/SPIRV-Tools/contents/{+path}","compare_url":"https://api.github.com/repos/umar456/SPIRV-Tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/umar456/SPIRV-Tools/merges","archive_url":"https://api.github.com/repos/umar456/SPIRV-Tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/umar456/SPIRV-Tools/downloads","issues_url":"https://api.github.com/repos/umar456/SPIRV-Tools/issues{/number}","pulls_url":"https://api.github.com/repos/umar456/SPIRV-Tools/pulls{/number}","milestones_url":"https://api.github.com/repos/umar456/SPIRV-Tools/milestones{/number}","notifications_url":"https://api.github.com/repos/umar456/SPIRV-Tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/umar456/SPIRV-Tools/labels{/name}","releases_url":"https://api.github.com/repos/umar456/SPIRV-Tools/releases{/id}","created_at":"2015-11-19T18:58:25Z","updated_at":"2015-11-19T18:58:27Z","pushed_at":"2016-01-11T15:29:09Z","git_url":"git://github.com/umar456/SPIRV-Tools.git","ssh_url":"git@github.com:umar456/SPIRV-Tools.git","clone_url":"https://github.com/umar456/SPIRV-Tools.git","svn_url":"https://github.com/umar456/SPIRV-Tools","homepage":null,"size":1000,"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":"KhronosGroup:master","ref":"master","sha":"43401d2ed0e4f815fcb19b8ec224c73749f44bf1","user":{"login":"KhronosGroup","id":1608701,"avatar_url":"https://avatars.githubusercontent.com/u/1608701?v=3","gravatar_id":"","url":"https://api.github.com/users/KhronosGroup","html_url":"https://github.com/KhronosGroup","followers_url":"https://api.github.com/users/KhronosGroup/followers","following_url":"https://api.github.com/users/KhronosGroup/following{/other_user}","gists_url":"https://api.github.com/users/KhronosGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/KhronosGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhronosGroup/subscriptions","organizations_url":"https://api.github.com/users/KhronosGroup/orgs","repos_url":"https://api.github.com/users/KhronosGroup/repos","events_url":"https://api.github.com/users/KhronosGroup/events{/privacy}","received_events_url":"https://api.github.com/users/KhronosGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45981801,"name":"SPIRV-Tools","full_name":"KhronosGroup/SPIRV-Tools","owner":{"login":"KhronosGroup","id":1608701,"avatar_url":"https://avatars.githubusercontent.com/u/1608701?v=3","gravatar_id":"","url":"https://api.github.com/users/KhronosGroup","html_url":"https://github.com/KhronosGroup","followers_url":"https://api.github.com/users/KhronosGroup/followers","following_url":"https://api.github.com/users/KhronosGroup/following{/other_user}","gists_url":"https://api.github.com/users/KhronosGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/KhronosGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KhronosGroup/subscriptions","organizations_url":"https://api.github.com/users/KhronosGroup/orgs","repos_url":"https://api.github.com/users/KhronosGroup/repos","events_url":"https://api.github.com/users/KhronosGroup/events{/privacy}","received_events_url":"https://api.github.com/users/KhronosGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KhronosGroup/SPIRV-Tools","description":"","fork":false,"url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools","forks_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/forks","keys_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/teams","hooks_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/hooks","issue_events_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/events{/number}","events_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/events","assignees_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/assignees{/user}","branches_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/branches{/branch}","tags_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/tags","blobs_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/statuses/{sha}","languages_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/languages","stargazers_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/stargazers","contributors_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/contributors","subscribers_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/subscribers","subscription_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/subscription","commits_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/contents/{+path}","compare_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/merges","archive_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/downloads","issues_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues{/number}","pulls_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls{/number}","milestones_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/milestones{/number}","notifications_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/labels{/name}","releases_url":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/releases{/id}","created_at":"2015-11-11T12:56:25Z","updated_at":"2016-01-12T13:13:38Z","pushed_at":"2016-01-12T20:18:23Z","git_url":"git://github.com/KhronosGroup/SPIRV-Tools.git","ssh_url":"git@github.com:KhronosGroup/SPIRV-Tools.git","clone_url":"https://github.com/KhronosGroup/SPIRV-Tools.git","svn_url":"https://github.com/KhronosGroup/SPIRV-Tools","homepage":null,"size":1081,"stargazers_count":48,"watchers_count":48,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":9,"forks":10,"open_issues":9,"watchers":48,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51"},"html":{"href":"https://github.com/KhronosGroup/SPIRV-Tools/pull/51"},"issue":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/51"},"comments":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/KhronosGroup/SPIRV-Tools/statuses/6a4e5a6c6adafaed8fb8c9ea6f5983eb1c5eadd8"}}}}