{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/109535478","pull_request_review_id":30644983,"id":109535478,"diff_hunk":"@@ -692,11 +705,74 @@ addCommonInvocationArguments(std::vector<std::string> &invocationArgStrs,\n     llvm::itostr(ctx.LangOpts.EffectiveLanguageVersion[0]));\n }\n \n+bool ClangImporter::canReadPCH(const std::string PCHFilename) {\n+  return clang::ASTReader::isAcceptableASTFile(PCHFilename,\n+    Impl.Instance->getFileManager(),\n+    Impl.Instance->getPCHContainerReader(),\n+    Impl.Instance->getLangOpts(),\n+    Impl.Instance->getTargetOpts(),\n+    Impl.Instance->getPreprocessorOpts(),\n+    Impl.Instance->getSpecificModuleCachePath());\n+}\n+\n+Optional<std::string>\n+ClangImporter::getPCHFilename(ClangImporterOptions &ImporterOptions,\n+                              const std::string SwiftPCHHash) {\n+  if (llvm::sys::path::extension(ImporterOptions.BridgingHeader)\n+        .endswith(PCH_EXTENSION)) {\n+    return ImporterOptions.BridgingHeader;\n+  }\n+\n+  const auto &BridgingHeader = ImporterOptions.BridgingHeader;\n+  const auto &PCHOutputDir = ImporterOptions.PrecompiledHeaderOutputDir;\n+  if (SwiftPCHHash.empty() || BridgingHeader.empty() || PCHOutputDir.empty()) {\n+    return None;\n+  }\n+\n+  SmallString<256> PCHBasename { llvm::sys::path::filename(BridgingHeader) };\n+  llvm::sys::path::replace_extension(PCHBasename, \"\");\n+  PCHBasename.append(\"-swift_\");\n+  PCHBasename.append(SwiftPCHHash);\n+  PCHBasename.append(\"-clang_\");\n+  PCHBasename.append(getClangModuleHash());\n+  llvm::sys::path::replace_extension(PCHBasename, \".pch\");\n+  SmallString<256> PCHFilename { PCHOutputDir };\n+  llvm::sys::path::append(PCHFilename, PCHBasename);\n+  return PCHFilename.str().str();\n+}\n+\n+\n+Optional<std::string>\n+ClangImporter::getOrCreatePCH(ClangImporterOptions &ImporterOptions,\n+                              const std::string SwiftPCHHash) {\n+  auto PCHFilename = getPCHFilename(ImporterOptions, SwiftPCHHash);\n+  if (!PCHFilename.hasValue()) {\n+    return None;\n+  }\n+  if (!canReadPCH(PCHFilename.getValue())) {\n+    SmallString<256> Message;\n+    llvm::raw_svector_ostream OS(Message);\n+    auto Diags = std::make_shared<clang::TextDiagnosticPrinter>(OS, &Impl.Instance->getDiagnosticOpts());\n+    auto FailedToEmit = emitBridgingPCH(ImporterOptions.BridgingHeader,\n+                                        PCHFilename.getValue(),\n+                                        Diags.get());\n+    if (Diags->getNumErrors() > 0) {\n+      llvm::errs() << OS.str() << \"\\n\";","path":"lib/ClangImporter/ClangImporter.cpp","position":132,"original_position":132,"commit_id":"26c52e7fb9cf21163579a51be51a81b9d7b48cfb","original_commit_id":"26c52e7fb9cf21163579a51be51a81b9d7b48cfb","user":{"login":"jrose-apple","id":15097531,"avatar_url":"https://avatars1.githubusercontent.com/u/15097531?v=3","gravatar_id":"","url":"https://api.github.com/users/jrose-apple","html_url":"https://github.com/jrose-apple","followers_url":"https://api.github.com/users/jrose-apple/followers","following_url":"https://api.github.com/users/jrose-apple/following{/other_user}","gists_url":"https://api.github.com/users/jrose-apple/gists{/gist_id}","starred_url":"https://api.github.com/users/jrose-apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrose-apple/subscriptions","organizations_url":"https://api.github.com/users/jrose-apple/orgs","repos_url":"https://api.github.com/users/jrose-apple/repos","events_url":"https://api.github.com/users/jrose-apple/events{/privacy}","received_events_url":"https://api.github.com/users/jrose-apple/received_events","type":"User","site_admin":false},"body":"I guess so. It does mean you'd never find out about *why* a PCH is failing, but they probably wouldn't be able to do anything about that anyway in the SourceKit case.","created_at":"2017-04-03T22:02:53Z","updated_at":"2017-04-03T22:02:53Z","html_url":"https://github.com/apple/swift/pull/8400#discussion_r109535478","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/8400","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/109535478"},"html":{"href":"https://github.com/apple/swift/pull/8400#discussion_r109535478"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/8400"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/8400","id":113086805,"html_url":"https://github.com/apple/swift/pull/8400","diff_url":"https://github.com/apple/swift/pull/8400.diff","patch_url":"https://github.com/apple/swift/pull/8400.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/8400","number":8400,"state":"open","locked":false,"title":"Bridging PCH Caching for Code Completion","user":{"login":"bitjammer","id":693829,"avatar_url":"https://avatars2.githubusercontent.com/u/693829?v=3","gravatar_id":"","url":"https://api.github.com/users/bitjammer","html_url":"https://github.com/bitjammer","followers_url":"https://api.github.com/users/bitjammer/followers","following_url":"https://api.github.com/users/bitjammer/following{/other_user}","gists_url":"https://api.github.com/users/bitjammer/gists{/gist_id}","starred_url":"https://api.github.com/users/bitjammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitjammer/subscriptions","organizations_url":"https://api.github.com/users/bitjammer/orgs","repos_url":"https://api.github.com/users/bitjammer/repos","events_url":"https://api.github.com/users/bitjammer/events{/privacy}","received_events_url":"https://api.github.com/users/bitjammer/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-28T23:11:23Z","updated_at":"2017-04-03T22:02:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1891f2b38868d452dde49096cb3ba26b9889ef11","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/8400/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/8400/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/8400/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/26c52e7fb9cf21163579a51be51a81b9d7b48cfb","head":{"label":"bitjammer:pch-caching","ref":"pch-caching","sha":"26c52e7fb9cf21163579a51be51a81b9d7b48cfb","user":{"login":"bitjammer","id":693829,"avatar_url":"https://avatars2.githubusercontent.com/u/693829?v=3","gravatar_id":"","url":"https://api.github.com/users/bitjammer","html_url":"https://github.com/bitjammer","followers_url":"https://api.github.com/users/bitjammer/followers","following_url":"https://api.github.com/users/bitjammer/following{/other_user}","gists_url":"https://api.github.com/users/bitjammer/gists{/gist_id}","starred_url":"https://api.github.com/users/bitjammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitjammer/subscriptions","organizations_url":"https://api.github.com/users/bitjammer/orgs","repos_url":"https://api.github.com/users/bitjammer/repos","events_url":"https://api.github.com/users/bitjammer/events{/privacy}","received_events_url":"https://api.github.com/users/bitjammer/received_events","type":"User","site_admin":false},"repo":{"id":47589068,"name":"swift","full_name":"bitjammer/swift","owner":{"login":"bitjammer","id":693829,"avatar_url":"https://avatars2.githubusercontent.com/u/693829?v=3","gravatar_id":"","url":"https://api.github.com/users/bitjammer","html_url":"https://github.com/bitjammer","followers_url":"https://api.github.com/users/bitjammer/followers","following_url":"https://api.github.com/users/bitjammer/following{/other_user}","gists_url":"https://api.github.com/users/bitjammer/gists{/gist_id}","starred_url":"https://api.github.com/users/bitjammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitjammer/subscriptions","organizations_url":"https://api.github.com/users/bitjammer/orgs","repos_url":"https://api.github.com/users/bitjammer/repos","events_url":"https://api.github.com/users/bitjammer/events{/privacy}","received_events_url":"https://api.github.com/users/bitjammer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bitjammer/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/bitjammer/swift","forks_url":"https://api.github.com/repos/bitjammer/swift/forks","keys_url":"https://api.github.com/repos/bitjammer/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitjammer/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitjammer/swift/teams","hooks_url":"https://api.github.com/repos/bitjammer/swift/hooks","issue_events_url":"https://api.github.com/repos/bitjammer/swift/issues/events{/number}","events_url":"https://api.github.com/repos/bitjammer/swift/events","assignees_url":"https://api.github.com/repos/bitjammer/swift/assignees{/user}","branches_url":"https://api.github.com/repos/bitjammer/swift/branches{/branch}","tags_url":"https://api.github.com/repos/bitjammer/swift/tags","blobs_url":"https://api.github.com/repos/bitjammer/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitjammer/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitjammer/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitjammer/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitjammer/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/bitjammer/swift/languages","stargazers_url":"https://api.github.com/repos/bitjammer/swift/stargazers","contributors_url":"https://api.github.com/repos/bitjammer/swift/contributors","subscribers_url":"https://api.github.com/repos/bitjammer/swift/subscribers","subscription_url":"https://api.github.com/repos/bitjammer/swift/subscription","commits_url":"https://api.github.com/repos/bitjammer/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitjammer/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitjammer/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitjammer/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitjammer/swift/contents/{+path}","compare_url":"https://api.github.com/repos/bitjammer/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitjammer/swift/merges","archive_url":"https://api.github.com/repos/bitjammer/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitjammer/swift/downloads","issues_url":"https://api.github.com/repos/bitjammer/swift/issues{/number}","pulls_url":"https://api.github.com/repos/bitjammer/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/bitjammer/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/bitjammer/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitjammer/swift/labels{/name}","releases_url":"https://api.github.com/repos/bitjammer/swift/releases{/id}","deployments_url":"https://api.github.com/repos/bitjammer/swift/deployments","created_at":"2015-12-08T00:54:04Z","updated_at":"2017-02-14T05:58:57Z","pushed_at":"2017-03-31T13:39:06Z","git_url":"git://github.com/bitjammer/swift.git","ssh_url":"git@github.com:bitjammer/swift.git","clone_url":"https://github.com/bitjammer/swift.git","svn_url":"https://github.com/bitjammer/swift","homepage":"","size":172709,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"d01a528e6d2002214c5bc18e76e9172b7723e715","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars3.githubusercontent.com/u/10639145?v=3","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"name":"swift","full_name":"apple/swift","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars3.githubusercontent.com/u/10639145?v=3","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2017-04-03T21:46:36Z","pushed_at":"2017-04-03T21:54:17Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org/","size":181723,"stargazers_count":37717,"watchers_count":37717,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5582,"mirror_url":null,"open_issues_count":163,"forks":5582,"open_issues":163,"watchers":37717,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/8400"},"html":{"href":"https://github.com/apple/swift/pull/8400"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/8400"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/8400/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/8400/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/8400/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/26c52e7fb9cf21163579a51be51a81b9d7b48cfb"}}}}
{"actor":{"display_login":"jrose-apple"}}