<div dir="ltr">The clangd tests should be fixed now <a href="http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9231" target="_blank">http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9231</a><div><br></div><div>The remaining test failure seems to be related to r326357</div><div><br><div class="gmail_quote"></div><div class="gmail_quote"><div dir="ltr">On Wed, Feb 28, 2018 at 9:34 PM Eric Liu <<a href="mailto:ioeric@google.com" target="_blank">ioeric@google.com</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Attempt a fix with r326365</div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><div dir="ltr">On Wed, Feb 28, 2018 at 9:10 PM Eric Liu <<a href="mailto:ioeric@google.com" target="_blank">ioeric@google.com</a>> wrote:<br></div></div></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think I had missed the failure on <a href="http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/" target="_blank">http://lab.llvm.org:8011/builders/clang-x64-ninja-win7</a>; my apologies! I'll look into this now.</div><br><div class="gmail_quote"></div><div class="gmail_quote"><div dir="ltr">On Wed, Feb 28, 2018 at 9:04 PM Eric Liu <<a href="mailto:ioeric@google.com" target="_blank">ioeric@google.com</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sorry that I forgot to provide update on this thread; someone pointed out the failure to me in another email thread, so moved the conversation there. I sent r325482 which I thought had fixed the windows build bot. I'll take another look.<br></div><br></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div dir="ltr">On Wed, Feb 28, 2018 at 8:37 PM Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>> wrote:<br></div></div></blockquote></div></blockquote></div></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Looks like <a href="http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/" target="_blank">http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/</a> has been red ever since this landed too. Can you take a look or revert if it takes a while to sort out?</div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 16, 2018 at 6:59 PM, Galina Kistanova via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Eric,<br><br>It looks like your commit broke tests to one of our builders:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/15408" target="_blank">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/15408</a><br><br>. . .<br>Failing Tests (1):<br>    Extra Tools Unit Tests :: clangd/./ClangdTests.exe/SymbolCollectorTest.IWYUPragma<br><br>Please have a look?<br><br>Thanks<br><br>Galina<br></div></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 16, 2018 at 6:15 AM, Eric Liu via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br></div></div></blockquote></div></div></blockquote></div></blockquote></div></blockquote></div></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ioeric<br>
Date: Fri Feb 16 06:15:55 2018<br>
New Revision: 325343<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=325343&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=325343&view=rev</a><br>
Log:<br>
[clangd] collect symbol #include & insert #include in global code completion.<br>
<br>
Summary:<br>
o Collect suitable #include paths for index symbols. This also does smart mapping<br>
for STL symbols and IWYU pragma (code borrowed from include-fixer).<br>
o For global code completion, add a command for inserting new #include in each code<br>
completion item.<br>
<br>
Reviewers: sammccall<br>
<br>
Reviewed By: sammccall<br>
<br>
Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, hintonda, cfe-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D42640" rel="noreferrer" target="_blank">https://reviews.llvm.org/D42640</a><br>
<br>
Added:<br>
  Â  clang-tools-extra/trunk/clangd/Headers.cpp<br>
  Â  clang-tools-extra/trunk/clangd/Headers.h<br>
  Â  clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp<br>
  Â  clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h<br>
  Â  clang-tools-extra/trunk/test/clangd/insert-include.test<br>
  Â  clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp<br>
Modified:<br>
  Â  clang-tools-extra/trunk/clangd/CMakeLists.txt<br>
  Â  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp<br>
  Â  clang-tools-extra/trunk/clangd/ClangdServer.cpp<br>
  Â  clang-tools-extra/trunk/clangd/ClangdServer.h<br>
  Â  clang-tools-extra/trunk/clangd/CodeComplete.cpp<br>
  Â  clang-tools-extra/trunk/clangd/Protocol.cpp<br>
  Â  clang-tools-extra/trunk/clangd/Protocol.h<br>
  Â  clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp<br>
  Â  clang-tools-extra/trunk/clangd/index/Index.cpp<br>
  Â  clang-tools-extra/trunk/clangd/index/Index.h<br>
  Â  clang-tools-extra/trunk/clangd/index/Merge.cpp<br>
  Â  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp<br>
  Â  clang-tools-extra/trunk/clangd/index/SymbolCollector.h<br>
  Â  clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp<br>
  Â  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp<br>
  Â  clang-tools-extra/trunk/test/clangd/completion-snippets.test<br>
  Â  clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test<br>
  Â  clang-tools-extra/trunk/test/clangd/initialize-params.test<br>
  Â  clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt<br>
  Â  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp<br>
  Â  clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp<br>
<br>
Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)<br>
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Feb 16 06:15:55 2018<br>
@@ -14,6 +14,7 @@ add_clang_library(clangDaemon<br>
  Â DraftStore.cpp<br>
  Â FuzzyMatch.cpp<br>
  Â GlobalCompilationDatabase.cpp<br>
+  Headers.cpp<br>
  Â JSONExpr.cpp<br>
  Â JSONRPCDispatcher.cpp<br>
  Â Logger.cpp<br>
@@ -25,6 +26,7 @@ add_clang_library(clangDaemon<br>
  Â TUScheduler.cpp<br>
  Â URI.cpp<br>
  Â XRefs.cpp<br>
+  index/CanonicalIncludes.cpp<br>
  Â index/FileIndex.cpp<br>
  Â index/Index.cpp<br>
  Â index/MemIndex.cpp<br>
<br>
Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)<br>
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Feb 16 06:15:55 2018<br>
@@ -121,7 +121,9 @@ void ClangdLSPServer::onInitialize(Initi<br>
  Â  Â  Â  Â  Â  Â {"renameProvider", true},<br>
  Â  Â  Â  Â  Â  Â {"executeCommandProvider",<br>
  Â  Â  Â  Â  Â  Â  json::obj{<br>
-  Â  Â  Â  Â  Â  Â  Â  Â {"commands", {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},<br>
+  Â  Â  Â  Â  Â  Â  Â  Â {"commands",<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE}},<br>
  Â  Â  Â  Â  Â  Â  }},<br>
  Â  Â  Â  Â }}}});<br>
 }<br>
@@ -155,6 +157,14 @@ void ClangdLSPServer::onFileEvent(DidCha<br>
 }<br>
<br>
 void ClangdLSPServer::onCommand(ExecuteCommandParams &Params) {<br>
+  auto ApplyEdit = [](WorkspaceEdit WE) {<br>
+  Â  ApplyWorkspaceEditParams Edit;<br>
+  Â  Edit.edit = std::move(WE);<br>
+  Â  // We don't need the response so id == 1 is OK.<br>
+  Â  // Ideally, we would wait for the response and if there is no error, we<br>
+  Â  // would reply success/failure to the original RPC.<br>
+  Â  call("workspace/applyEdit", Edit);<br>
+  };<br>
  Â if (Params.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND &&<br>
  Â  Â  Â Params.workspaceEdit) {<br>
  Â  Â // The flow for "apply-fix" :<br>
@@ -166,13 +176,35 @@ void ClangdLSPServer::onCommand(ExecuteC<br>
  Â  Â // 6. The editor applies the changes (applyEdit), and sends us a reply (but<br>
  Â  Â // we ignore it)<br>
<br>
-  Â  ApplyWorkspaceEditParams ApplyEdit;<br>
-  Â  ApplyEdit.edit = *Params.workspaceEdit;<br>
  Â  Â reply("Fix applied.");<br>
-  Â  // We don't need the response so id == 1 is OK.<br>
-  Â  // Ideally, we would wait for the response and if there is no error, we<br>
-  Â  // would reply success/failure to the original RPC.<br>
-  Â  call("workspace/applyEdit", ApplyEdit);<br>
+  Â  ApplyEdit(*Params.workspaceEdit);<br>
+  } else if (Params.command ==<br>
+  Â  Â  Â  Â  Â  Â ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE) {<br>
+  Â  auto &FileURI = Params.includeInsertion->textDocument.uri;<br>
+  Â  auto Code = Server.getDocument(FileURI.file());<br>
+  Â  if (!Code)<br>
+  Â  Â  return replyError(ErrorCode::InvalidParams,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  ("command " +<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE +<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â " called on non-added file " + FileURI.file())<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  .str());<br>
+  Â  auto Replaces = Server.insertInclude(FileURI.file(), *Code,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Params.includeInsertion->header);<br>
+  Â  if (!Replaces) {<br>
+  Â  Â  std::string ErrMsg =<br>
+  Â  Â  Â  Â  ("Failed to generate include insertion edits for adding " +<br>
+  Â  Â  Â  Â  Â Params.includeInsertion->header + " into " + FileURI.file())<br>
+  Â  Â  Â  Â  Â  Â  .str();<br>
+  Â  Â  log(ErrMsg + ":" + llvm::toString(Replaces.takeError()));<br>
+  Â  Â  replyError(ErrorCode::InternalError, ErrMsg);<br>
+  Â  Â  return;<br>
+  Â  }<br>
+  Â  auto Edits = replacementsToEdits(*Code, *Replaces);<br>
+  Â  WorkspaceEdit WE;<br>
+  Â  WE.changes = {{FileURI.uri(), Edits}};<br>
+<br>
+  Â  reply("Inserted header " + Params.includeInsertion->header);<br>
+  Â  ApplyEdit(std::move(WE));<br>
  Â } else {<br>
  Â  Â // We should not get here because ExecuteCommandParams would not have<br>
  Â  Â // parsed in the first place and this handler should not be called. But if<br>
<br>
Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)<br>
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Fri Feb 16 06:15:55 2018<br>
@@ -9,6 +9,7 @@<br>
<br>
 #include "ClangdServer.h"<br>
 #include "CodeComplete.h"<br>
+#include "Headers.h"<br>
 #include "SourceCode.h"<br>
 #include "XRefs.h"<br>
 #include "index/Merge.h"<br>
@@ -310,6 +311,47 @@ void ClangdServer::rename(<br>
  Â  Â  Â BindWithForward(Action, File.str(), NewName.str(), std::move(Callback)));<br>
 }<br>
<br>
+Expected<tooling::Replacements><br>
+ClangdServer::insertInclude(PathRef File, StringRef Code,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  llvm::StringRef Header) {<br>
+  std::string ToInclude;<br>
+  if (Header.startswith("<") || Header.startswith("\"")) {<br>
+  Â  ToInclude = Header;<br>
+  } else {<br>
+  Â  auto U = URI::parse(Header);<br>
+  Â  if (!U)<br>
+  Â  Â  return U.takeError();<br>
+  Â  auto Resolved = URI::resolve(*U, /*HintPath=*/File);<br>
+  Â  if (!Resolved)<br>
+  Â  Â  return Resolved.takeError();<br>
+<br>
+  Â  auto FS = FSProvider.getTaggedFileSystem(File).Value;<br>
+  Â  tooling::CompileCommand CompileCommand =<br>
+  Â  Â  Â  CompileArgs.getCompileCommand(File);<br>
+  Â  FS->setCurrentWorkingDirectory(CompileCommand.Directory);<br>
+<br>
+  Â  auto Include =<br>
+  Â  Â  Â  shortenIncludePath(File, Code, *Resolved, CompileCommand, FS);<br>
+  Â  if (!Include)<br>
+  Â  Â  return Include.takeError();<br>
+  Â  if (Include->empty())<br>
+  Â  Â  return tooling::Replacements();<br>
+  Â  ToInclude = std::move(*Include);<br>
+  }<br>
+<br>
+  auto Style = format::getStyle("file", File, "llvm");<br>
+  if (!Style) {<br>
+  Â  llvm::consumeError(Style.takeError());<br>
+  Â  // FIXME(ioeric): needs more consistent style support in clangd server.<br>
+  Â  Style = format::getLLVMStyle();<br>
+  }<br>
+  // Replacement with offset UINT_MAX and length 0 will be treated as include<br>
+  // insertion.<br>
+  tooling::Replacement R(File, /*Offset=*/UINT_MAX, 0, "#include " + ToInclude);<br>
+  return format::cleanupAroundReplacements(Code, tooling::Replacements(R),<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â *Style);<br>
+}<br>
+<br>
 llvm::Optional<std::string> ClangdServer::getDocument(PathRef File) {<br>
  Â auto Latest = DraftMgr.getDraft(File);<br>
  Â if (!Latest.Draft)<br>
<br>
Modified: clang-tools-extra/trunk/clangd/ClangdServer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)<br>
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Fri Feb 16 06:15:55 2018<br>
@@ -231,6 +231,13 @@ public:<br>
  Â  Â  Â  Â  Â  Â  Â UniqueFunction<void(Expected<std::vector<tooling::Replacement>>)><br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â Callback);<br>
<br>
+  /// Inserts a new #include of \p Header into \p File, if it's not present.<br>
+  /// \p Header is either an URI that can be resolved to an #include path that<br>
+  /// is suitable to be inserted or a literal string quoted with <> or "" that<br>
+  /// can be #included directly.<br>
+  Expected<tooling::Replacements> insertInclude(PathRef File, StringRef Code,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  StringRef Header);<br>
+<br>
  Â /// Gets current document contents for \p File. Returns None if \p File is not<br>
  Â /// currently tracked.<br>
  Â /// FIXME(ibiryukov): This function is here to allow offset-to-Position<br>
<br>
Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)<br>
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Feb 16 06:15:55 2018<br>
@@ -19,13 +19,16 @@<br>
 #include "Compiler.h"<br>
 #include "FuzzyMatch.h"<br>
 #include "Logger.h"<br>
+#include "SourceCode.h"<br>
 #include "Trace.h"<br>
 #include "index/Index.h"<br>
+#include "clang/Format/Format.h"<br>
 #include "clang/Frontend/CompilerInstance.h"<br>
 #include "clang/Frontend/FrontendActions.h"<br>
 #include "clang/Index/USRGeneration.h"<br>
 #include "clang/Sema/CodeCompleteConsumer.h"<br>
 #include "clang/Sema/Sema.h"<br>
+#include "clang/Tooling/Core/Replacement.h"<br>
 #include "llvm/Support/Format.h"<br>
 #include <queue><br>
<br>
@@ -249,7 +252,8 @@ struct CompletionCandidate {<br>
  Â }<br>
<br>
  Â // Builds an LSP completion item.<br>
-  CompletionItem build(const CompletionItemScores &Scores,<br>
+  CompletionItem build(llvm::StringRef FileName,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â const CompletionItemScores &Scores,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  const CodeCompleteOptions &Opts,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  CodeCompletionString *SemaCCS) const {<br>
  Â  Â assert(bool(SemaResult) == bool(SemaCCS));<br>
@@ -282,6 +286,28 @@ struct CompletionCandidate {<br>
  Â  Â  Â  Â  Â I.documentation = D->Documentation;<br>
  Â  Â  Â  Â if (I.detail.empty())<br>
  Â  Â  Â  Â  Â I.detail = D->CompletionDetail;<br>
+  Â  Â  Â  // We only insert #include for items with details, since we can't tell<br>
+  Â  Â  Â  // whether the file URI of the canonical declaration would be the<br>
+  Â  Â  Â  // canonical #include without checking IncludeHeader in the detail.<br>
+  Â  Â  Â  // FIXME: delay creating include insertion command to<br>
+  Â  Â  Â  // "completionItem/resolve", when it is supported<br>
+  Â  Â  Â  if (!D->IncludeHeader.empty() ||<br>
+  Â  Â  Â  Â  Â  !IndexResult->CanonicalDeclaration.FileURI.empty()) {<br>
+  Â  Â  Â  Â  // LSP favors additionalTextEdits over command. But we are still using<br>
+  Â  Â  Â  Â  // command here because it would be expensive to calculate #include<br>
+  Â  Â  Â  Â  // insertion edits for all candidates, and the include insertion edit<br>
+  Â  Â  Â  Â  // is unlikely to conflict with the code completion edits.<br>
+  Â  Â  Â  Â  Command Cmd;<br>
+  Â  Â  Â  Â  // Command title is not added since this is not a user-facing command.<br>
+  Â  Â  Â  Â  Cmd.command = ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE;<br>
+  Â  Â  Â  Â  IncludeInsertion Insertion;<br>
+  Â  Â  Â  Â  Insertion.header = D->IncludeHeader.empty()<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â ? IndexResult->CanonicalDeclaration.FileURI<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â : D->IncludeHeader;<br>
+  Â  Â  Â  Â  Insertion.textDocument.uri = URIForFile(FileName);<br>
+  Â  Â  Â  Â  Cmd.includeInsertion = std::move(Insertion);<br>
+  Â  Â  Â  Â  I.command = std::move(Cmd);<br>
+  Â  Â  Â  }<br>
  Â  Â  Â }<br>
  Â  Â }<br>
  Â  Â I.scoreInfo = Scores;<br>
@@ -806,6 +832,7 @@ clang::CodeCompleteOptions CodeCompleteO<br>
 //  Â  Â This score is combined with the result quality score for the final score.<br>
 //  Â - TopN determines the results with the best score.<br>
 class CodeCompleteFlow {<br>
+  PathRef FileName;<br>
  Â const CodeCompleteOptions &Opts;<br>
  Â // Sema takes ownership of Recorder. Recorder is valid until Sema cleanup.<br>
  Â std::unique_ptr<CompletionRecorder> RecorderOwner;<br>
@@ -816,9 +843,9 @@ class CodeCompleteFlow {<br>
<br>
 public:<br>
  Â // A CodeCompleteFlow object is only useful for calling run() exactly once.<br>
-  CodeCompleteFlow(const CodeCompleteOptions &Opts)<br>
-  Â  Â  : Opts(Opts), RecorderOwner(new CompletionRecorder(Opts)),<br>
-  Â  Â  Â  Recorder(*RecorderOwner) {}<br>
+  CodeCompleteFlow(PathRef FileName, const CodeCompleteOptions &Opts)<br>
+  Â  Â  : FileName(FileName), Opts(Opts),<br>
+  Â  Â  Â  RecorderOwner(new CompletionRecorder(Opts)), Recorder(*RecorderOwner) {}<br>
<br>
  Â CompletionList run(const SemaCompleteInput &SemaCCInput) && {<br>
  Â  Â trace::Span Tracer("CodeCompleteFlow");<br>
@@ -956,7 +983,7 @@ private:<br>
  Â  Â CodeCompletionString *SemaCCS = nullptr;<br>
  Â  Â if (auto *SR = Candidate.SemaResult)<br>
  Â  Â  Â SemaCCS = Recorder.codeCompletionString(*SR, Opts.IncludeBriefComments);<br>
-  Â  return Candidate.build(Scores, Opts, SemaCCS);<br>
+  Â  return Candidate.build(FileName, Scores, Opts, SemaCCS);<br>
  Â }<br>
 };<br>
<br>
@@ -967,8 +994,8 @@ CompletionList codeComplete(PathRef File<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â IntrusiveRefCntPtr<vfs::FileSystem> VFS,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â std::shared_ptr<PCHContainerOperations> PCHs,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â CodeCompleteOptions Opts) {<br>
-  return CodeCompleteFlow(Opts).run(<br>
-  Â  Â  {FileName, Command, Preamble, Contents, Pos, VFS, PCHs});<br>
+  return CodeCompleteFlow(FileName, Opts)<br>
+  Â  Â  .run({FileName, Command, Preamble, Contents, Pos, VFS, PCHs});<br>
 }<br>
<br>
 SignatureHelp signatureHelp(PathRef FileName,<br>
<br>
Added: clang-tools-extra/trunk/clangd/Headers.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=325343&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=325343&view=auto</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/Headers.cpp (added)<br>
+++ clang-tools-extra/trunk/clangd/Headers.cpp Fri Feb 16 06:15:55 2018<br>
@@ -0,0 +1,117 @@<br>
+//===--- Headers.cpp - Include headers ---------------------------*- C++-*-===//<br>
+//<br>
+//  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "Headers.h"<br>
+#include "Compiler.h"<br>
+#include "Logger.h"<br>
+#include "clang/Frontend/CompilerInstance.h"<br>
+#include "clang/Frontend/CompilerInvocation.h"<br>
+#include "clang/Frontend/FrontendActions.h"<br>
+#include "clang/Lex/HeaderSearch.h"<br>
+#include "clang/Lex/PreprocessorOptions.h"<br>
+#include "clang/Tooling/CompilationDatabase.h"<br>
+<br>
+namespace clang {<br>
+namespace clangd {<br>
+namespace {<br>
+<br>
+class RecordHeaders : public PPCallbacks {<br>
+public:<br>
+  RecordHeaders(std::set<std::string> &Headers) : Headers(Headers) {}<br>
+<br>
+  void InclusionDirective(SourceLocation /*HashLoc*/,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  const Token & /*IncludeTok*/,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  llvm::StringRef /*FileName*/, bool /*IsAngled*/,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  CharSourceRange /*FilenameRange*/,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  const FileEntry *File, llvm::StringRef /*SearchPath*/,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  llvm::StringRef /*RelativePath*/,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  const Module * /*Imported*/) override {<br>
+  Â  if (File != nullptr && !File->tryGetRealPathName().empty())<br>
+  Â  Â  Headers.insert(File->tryGetRealPathName());<br>
+  }<br>
+<br>
+private:<br>
+  std::set<std::string> &Headers;<br>
+};<br>
+<br>
+} // namespace<br>
+<br>
+/// FIXME(ioeric): we might not want to insert an absolute include path if the<br>
+/// path is not shortened.<br>
+llvm::Expected<std::string><br>
+shortenIncludePath(llvm::StringRef File, llvm::StringRef Code,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â llvm::StringRef Header,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â const tooling::CompileCommand &CompileCommand,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â IntrusiveRefCntPtr<vfs::FileSystem> FS) {<br>
+  // Set up a CompilerInstance and create a preprocessor to collect existing<br>
+  // #include headers in \p Code. Preprocesor also provides HeaderSearch with<br>
+  // which we can calculate the shortest include path for \p Header.<br>
+  std::vector<const char *> Argv;<br>
+  for (const auto &S : CompileCommand.CommandLine)<br>
+  Â  Argv.push_back(S.c_str());<br>
+  IgnoringDiagConsumer IgnoreDiags;<br>
+  auto CI = clang::createInvocationFromCommandLine(<br>
+  Â  Â  Argv,<br>
+  Â  Â  CompilerInstance::createDiagnostics(new DiagnosticOptions(), &IgnoreDiags,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  false),<br>
+  Â  Â  FS);<br>
+  if (!CI)<br>
+  Â  return llvm::make_error<llvm::StringError>(<br>
+  Â  Â  Â  "Failed to create a compiler instance for " + File,<br>
+  Â  Â  Â  llvm::inconvertibleErrorCode());<br>
+  CI->getFrontendOpts().DisableFree = false;<br>
+  // Parse the main file to get all existing #includes in the file, and then we<br>
+  // can make sure the same header (even with different include path) is not<br>
+  // added more than once.<br>
+  CI->getPreprocessorOpts().SingleFileParseMode = true;<br>
+<br>
+  auto Clang = prepareCompilerInstance(<br>
+  Â  Â  std::move(CI), /*Preamble=*/nullptr,<br>
+  Â  Â  llvm::MemoryBuffer::getMemBuffer(Code, File),<br>
+  Â  Â  std::make_shared<PCHContainerOperations>(), FS, IgnoreDiags);<br>
+  auto &DiagOpts = Clang->getDiagnosticOpts();<br>
+  DiagOpts.IgnoreWarnings = true;<br>
+<br>
+  if (Clang->getFrontendOpts().Inputs.empty())<br>
+  Â  return llvm::make_error<llvm::StringError>(<br>
+  Â  Â  Â  "Empty frontend action inputs empty for file " + File,<br>
+  Â  Â  Â  llvm::inconvertibleErrorCode());<br>
+  PreprocessOnlyAction Action;<br>
+  if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))<br>
+  Â  return llvm::make_error<llvm::StringError>(<br>
+  Â  Â  Â  "Failed to begin preprocessor only action for file " + File,<br>
+  Â  Â  Â  llvm::inconvertibleErrorCode());<br>
+  std::set<std::string> ExistingHeaders;<br>
+  Clang->getPreprocessor().addPPCallbacks(<br>
+  Â  Â  llvm::make_unique<RecordHeaders>(ExistingHeaders));<br>
+  if (!Action.Execute())<br>
+  Â  return llvm::make_error<llvm::StringError>(<br>
+  Â  Â  Â  "Failed to execute preprocessor only action for file " + File,<br>
+  Â  Â  Â  llvm::inconvertibleErrorCode());<br>
+  if (ExistingHeaders.find(Header) != ExistingHeaders.end()) {<br>
+  Â  return llvm::make_error<llvm::StringError>(<br>
+  Â  Â  Â  Header + " is already included in " + File,<br>
+  Â  Â  Â  llvm::inconvertibleErrorCode());<br>
+  }<br>
+<br>
+  auto &HeaderSearchInfo = Clang->getPreprocessor().getHeaderSearchInfo();<br>
+  bool IsSystem = false;<br>
+  std::string Suggested = HeaderSearchInfo.suggestPathToFileForDiagnostics(<br>
+  Â  Â  Header, CompileCommand.Directory, &IsSystem);<br>
+  if (IsSystem)<br>
+  Â  Suggested = "<" + Suggested + ">";<br>
+  else<br>
+  Â  Suggested = "\"" + Suggested + "\"";<br>
+<br>
+  log("Suggested #include for " + Header + " is: " + Suggested);<br>
+  return Suggested;<br>
+}<br>
+<br>
+} // namespace clangd<br>
+} // namespace clang<br>
<br>
Added: clang-tools-extra/trunk/clangd/Headers.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=325343&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=325343&view=auto</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/Headers.h (added)<br>
+++ clang-tools-extra/trunk/clangd/Headers.h Fri Feb 16 06:15:55 2018<br>
@@ -0,0 +1,37 @@<br>
+//===--- Headers.h - Include headers -----------------------------*- C++-*-===//<br>
+//<br>
+//  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_HEADERS_H<br>
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_HEADERS_H<br>
+<br>
+#include "Path.h"<br>
+#include "clang/Basic/VirtualFileSystem.h"<br>
+#include "clang/Tooling/CompilationDatabase.h"<br>
+#include "llvm/ADT/StringRef.h"<br>
+#include "llvm/Support/Error.h"<br>
+<br>
+namespace clang {<br>
+namespace clangd {<br>
+/// Determines the preferred way to #include a file, taking into account the<br>
+/// search path. Usually this will prefer a shorter representation like<br>
+/// 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.<br>
+///<br>
+/// \param Header is an absolute file path.<br>
+/// \return A quoted "path" or <path>. If \p Header is already (directly)<br>
+/// included in the file (including those included via different paths), this<br>
+/// returns an empty string.<br>
+llvm::Expected<std::string><br>
+shortenIncludePath(PathRef File, llvm::StringRef Code, llvm::StringRef Header,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â const tooling::CompileCommand &CompileCommand,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â IntrusiveRefCntPtr<vfs::FileSystem> FS);<br>
+<br>
+} // namespace clangd<br>
+} // namespace clang<br>
+<br>
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_HEADERS_H<br>
<br>
Modified: clang-tools-extra/trunk/clangd/Protocol.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)<br>
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Fri Feb 16 06:15:55 2018<br>
@@ -57,6 +57,10 @@ llvm::raw_ostream &operator<<(llvm::raw_<br>
  Â return OS << U.uri();<br>
 }<br>
<br>
+json::Expr toJSON(const TextDocumentIdentifier &R) {<br>
+  return json::obj{{"uri", R.uri}};<br>
+}<br>
+<br>
 bool fromJSON(const json::Expr &Params, TextDocumentIdentifier &R) {<br>
  Â json::ObjectMapper O(Params);<br>
  Â return O && O.map("uri", R.uri);<br>
@@ -326,6 +330,8 @@ bool fromJSON(const json::Expr &Params,<br>
<br>
 const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =<br>
  Â  Â "clangd.applyFix";<br>
+const llvm::StringLiteral ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE =<br>
+  Â  "clangd.insertInclude";<br>
<br>
 bool fromJSON(const json::Expr &Params, ExecuteCommandParams &R) {<br>
  Â json::ObjectMapper O(Params);<br>
@@ -336,10 +342,22 @@ bool fromJSON(const json::Expr &Params,<br>
  Â if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {<br>
  Â  Â return Args && Args->size() == 1 &&<br>
  Â  Â  Â  Â  Â  fromJSON(Args->front(), R.workspaceEdit);<br>
+  } else if (R.command == ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE) {<br>
+  Â  return Args && Args->size() == 1 &&<br>
+  Â  Â  Â  Â  Â fromJSON(Args->front(), R.includeInsertion);<br>
  Â }<br>
  Â return false; // Unrecognized command.<br>
 }<br>
<br>
+json::Expr toJSON(const Command &C) {<br>
+  auto Cmd = json::obj{{"title", C.title}, {"command", C.command}};<br>
+  if (C.workspaceEdit)<br>
+  Â  Cmd["arguments"] = {*C.workspaceEdit};<br>
+  else if (C.includeInsertion)<br>
+  Â  Cmd["arguments"] = {*C.includeInsertion};<br>
+  return std::move(Cmd);<br>
+}<br>
+<br>
 json::Expr toJSON(const WorkspaceEdit &WE) {<br>
  Â if (!WE.changes)<br>
  Â  Â return json::obj{};<br>
@@ -349,6 +367,15 @@ json::Expr toJSON(const WorkspaceEdit &W<br>
  Â return json::obj{{"changes", std::move(FileChanges)}};<br>
 }<br>
<br>
+bool fromJSON(const json::Expr &II, IncludeInsertion &R) {<br>
+  json::ObjectMapper O(II);<br>
+  return O && O.map("textDocument", R.textDocument) &&<br>
+  Â  Â  Â  Â O.map("header", R.header);<br>
+}<br>
+json::Expr toJSON(const IncludeInsertion &II) {<br>
+  return json::obj{{"textDocument", II.textDocument}, {"header", II.header}};<br>
+}<br>
+<br>
 json::Expr toJSON(const ApplyWorkspaceEditParams &Params) {<br>
  Â return json::obj{{"edit", Params.edit}};<br>
 }<br>
@@ -380,6 +407,8 @@ json::Expr toJSON(const CompletionItem &<br>
  Â  Â Result["textEdit"] = *CI.textEdit;<br>
  Â if (!CI.additionalTextEdits.empty())<br>
  Â  Â Result["additionalTextEdits"] = json::ary(CI.additionalTextEdits);<br>
+  if (CI.command)<br>
+  Â  Result["command"] = *CI.command;<br>
  Â return std::move(Result);<br>
 }<br>
<br>
<br>
Modified: clang-tools-extra/trunk/clangd/Protocol.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/Protocol.h (original)<br>
+++ clang-tools-extra/trunk/clangd/Protocol.h Fri Feb 16 06:15:55 2018<br>
@@ -82,6 +82,7 @@ struct TextDocumentIdentifier {<br>
  Â /// The text document's URI.<br>
  Â URIForFile uri;<br>
 };<br>
+json::Expr toJSON(const TextDocumentIdentifier &);<br>
 bool fromJSON(const json::Expr &, TextDocumentIdentifier &);<br>
<br>
 struct Position {<br>
@@ -424,6 +425,17 @@ struct WorkspaceEdit {<br>
 bool fromJSON(const json::Expr &, WorkspaceEdit &);<br>
 json::Expr toJSON(const WorkspaceEdit &WE);<br>
<br>
+struct IncludeInsertion {<br>
+  /// The document in which the command was invoked.<br>
+  TextDocumentIdentifier textDocument;<br>
+<br>
+  /// The header to be inserted. This could be either a URI ir a literal string<br>
+  /// quoted with <> or "" that can be #included directly.<br>
+  std::string header;<br>
+};<br>
+bool fromJSON(const json::Expr &, IncludeInsertion &);<br>
+json::Expr toJSON(const IncludeInsertion &II);<br>
+<br>
 /// Exact commands are not specified in the protocol so we define the<br>
 /// ones supported by Clangd here. The protocol specifies the command arguments<br>
 /// to be "any[]" but to make this safer and more manageable, each command we<br>
@@ -435,15 +447,25 @@ json::Expr toJSON(const WorkspaceEdit &W<br>
 struct ExecuteCommandParams {<br>
  Â // Command to apply fix-its. Uses WorkspaceEdit as argument.<br>
  Â const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND;<br>
+  // Command to insert an #include into code.<br>
+  const static llvm::StringLiteral CLANGD_INSERT_HEADER_INCLUDE;<br>
<br>
  Â /// The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND<br>
  Â std::string command;<br>
<br>
  Â // Arguments<br>
  Â llvm::Optional<WorkspaceEdit> workspaceEdit;<br>
+<br>
+  llvm::Optional<IncludeInsertion> includeInsertion;<br>
 };<br>
 bool fromJSON(const json::Expr &, ExecuteCommandParams &);<br>
<br>
+struct Command : public ExecuteCommandParams {<br>
+  std::string title;<br>
+};<br>
+<br>
+json::Expr toJSON(const Command &C);<br>
+<br>
 struct ApplyWorkspaceEditParams {<br>
  Â WorkspaceEdit edit;<br>
 };<br>
@@ -560,12 +582,10 @@ struct CompletionItem {<br>
  Â /// themselves.<br>
  Â std::vector<TextEdit> additionalTextEdits;<br>
<br>
+  llvm::Optional<Command> command;<br>
  Â // TODO(krasimir): The following optional fields defined by the language<br>
  Â // server protocol are unsupported:<br>
  Â //<br>
-  // command?: Command - An optional command that is executed *after* inserting<br>
-  //  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â this completion.<br>
-  //<br>
  Â // data?: any - A data entry field that is preserved on a completion item<br>
  Â //  Â  Â  Â  Â  Â  Â  between a completion and a completion resolve request.<br>
 };<br>
<br>
Modified: clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=325343&r1=325342&r2=325343&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=325343&r1=325342&r2=325343&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp (original)<br>
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp Fri Feb 16 06:15:55 2018<br>
@@ -13,10 +13,12 @@<br>
 //<br>
 //===---------------------------------------------------------------------===//<br>
<br>
+#include "index/CanonicalIncludes.h"<br>
 #include "index/Index.h"<br>
 #include "index/Merge.h"<br>
 #include "index/SymbolCollector.h"<br>
 #include "index/SymbolYAML.h"<br>
+#include "clang/Frontend/CompilerInstance.h"<br>
 #include "clang/Frontend/FrontendActions.h"<br>
 #include "clang/Frontend/CompilerInstance.h"<br>
 #include "clang/Index/IndexDataConsumer.h"<br>
@@ -57,11 +59,19 @@ public:<br>
  Â  Â class WrappedIndexAction : public WrapperFrontendAction {<br>
  Â  Â public:<br>
  Â  Â  Â WrappedIndexAction(std::shared_ptr<SymbolCollector> C,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â std::unique_ptr<CanonicalIncludes> Includes,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  const index::IndexingOptions &Opts,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  tooling::ExecutionContext *Ctx)<br>
  Â  Â  Â  Â  Â : WrapperFrontendAction(<br>
  Â  Â  Â  Â  Â  Â  Â  Â index::createIndexingAction(C, Opts, nullptr)),<br>
-  Â  Â  Â  Â  Â  Ctx(Ctx), Collector(C) {}<br>
+  Â  Â  Â  Â  Â  Ctx(Ctx), Collector(C), Includes(std::move(Includes)),<br>
+  Â  Â  Â  Â  Â  PragmaHandler(collectIWYUHeaderMaps(this->Includes.get())) {}<br>
+<br>
+  Â  Â  std::unique_ptr<ASTConsumer><br>
+  Â  Â  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {<br>
+  Â  Â  Â  CI.getPreprocessor().addCommentHandler(PragmaHandler.get());<br>
+  Â  Â  Â  return WrapperFrontendAction::CreateASTConsumer(CI, InFile);<br>
+  Â  Â  }<br>
<br>
  Â  Â  Â void EndSourceFileAction() override {<br>
  Â  Â  Â  Â WrapperFrontendAction::EndSourceFileAction();<br>
@@ -78,6 +88,8 @@ public:<br>
  Â  Â private:<br>
  Â  Â  Â tooling::ExecutionContext *Ctx;<br>
  Â  Â  Â std::shared_ptr<SymbolCollector> Collector;<br>
+  Â  Â  std::unique_ptr<CanonicalIncludes> Includes;<br>
+  Â  Â  std::unique_ptr<CommentHandler> PragmaHandler;<br>
  Â  Â };<br>
<br>
  Â  Â index::IndexingOptions IndexOpts;<br>
@@ -86,9 +98,13 @@ public:<br>
  Â  Â IndexOpts.IndexFunctionLocals = false;<br>
  Â  Â auto CollectorOpts = SymbolCollector::Options();<br>
  Â  Â CollectorOpts.FallbackDir = AssumedHeaderDir;<br>
+  Â  CollectorOpts.CollectIncludePath = true;<br>
+  Â  auto Includes = llvm::make_unique<CanonicalIncludes>();<br>
+  Â  addSystemHeadersMapping(Includes.get());<br>
+  Â  CollectorOpts.Includes = Includes.get();<br>
  Â  Â return new WrappedIndexAction(<br>
-  Â  Â  Â  std::make_shared<SymbolCollector>(std::move(CollectorOpts)), IndexOpts,<br>
-  Â  Â  Â  Ctx);<br>
+  Â  Â  Â  std::make_shared<SymbolCollector>(std::move(CollectorOpts)),<br>
+  Â  Â  Â  std::move(Includes), IndexOpts, Ctx);<br>
  Â }<br>
<br>
  Â tooling::ExecutionContext *Ctx;<br>
<br>
Added: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=325343&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=325343&view=auto</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (added)<br>
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Fri Feb 16 06:15:55 2018<br>
@@ -0,0 +1,704 @@<br>
+//===-- CanonicalIncludes.h - remap #inclue headers--------------*- C++ -*-===//<br>
+//<br>
+//  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "CanonicalIncludes.h"<br>
+#include "llvm/Support/Regex.h"<br>
+<br>
+namespace clang {<br>
+namespace clangd {<br>
+namespace {<br>
+const char IWYUPragma[] = "// IWYU pragma: private, include ";<br>
+} // namespace<br>
+<br>
+void CanonicalIncludes::addMapping(llvm::StringRef Path,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â llvm::StringRef CanonicalPath) {<br>
+  addRegexMapping((llvm::Twine("^") + Path + "$").str(), CanonicalPath);<br>
+};<br>
+<br>
+void CanonicalIncludes::addRegexMapping(llvm::StringRef RE,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  llvm::StringRef CanonicalPath) {<br>
+  this->RegexHeaderMappingTable.emplace_back(llvm::Regex(RE), CanonicalPath);<br>
+}<br>
+<br>
+llvm::StringRef CanonicalIncludes::mapHeader(llvm::StringRef Header) const {<br>
+  for (auto &Entry : RegexHeaderMappingTable) {<br>
+#ifndef NDEBUG<br>
+  Â  std::string Dummy;<br>
+  Â  assert(Entry.first.isValid(Dummy) && "Regex should never be invalid!");<br>
+#endif<br>
+  Â  if (Entry.first.match(Header))<br>
+  Â  Â  return Entry.second;<br>
+  }<br>
+  return Header;<br>
+}<br>
+<br>
+std::unique_ptr<CommentHandler><br>
+collectIWYUHeaderMaps(CanonicalIncludes *Includes) {<br>
+  class PragmaCommentHandler : public clang::CommentHandler {<br>
+  public:<br>
+  Â  PragmaCommentHandler(CanonicalIncludes *Includes) : Includes(Includes) {}<br>
+<br>
+  Â  bool HandleComment(Preprocessor &PP, SourceRange Range) override {<br>
+  Â  Â  StringRef Text =<br>
+  Â  Â  Â  Â  Lexer::getSourceText(CharSourceRange::getCharRange(Range),<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â PP.getSourceManager(), PP.getLangOpts());<br>
+  Â  Â  if (!Text.consume_front(IWYUPragma))<br>
+  Â  Â  Â  return false;<br>
+  Â  Â  // FIXME(ioeric): resolve the header and store actual file path. For now,<br>
+  Â  Â  // we simply assume the written header is suitable to be #included.<br>
+  Â  Â  Includes->addMapping(PP.getSourceManager().getFilename(Range.getBegin()),<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Text.startswith("<") ? Text.str()<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  : ("\"" + Text + "\"").str());<br>
+  Â  Â  return false;<br>
+  Â  }<br>
+<br>
+  private:<br>
+  Â  CanonicalIncludes *const Includes;<br>
+  };<br>
+  return llvm::make_unique<PragmaCommentHandler>(Includes);<br>
+}<br>
+<br>
+void addSystemHeadersMapping(CanonicalIncludes *Includes) {<br>
+  static const std::vector<std::pair<const char *, const char *>><br>
+  Â  Â  SystemHeaderMap = {<br>
+  Â  Â  Â  Â  {"include/__stddef_max_align_t.h$", "<cstddef>"},<br>
+  Â  Â  Â  Â  {"include/__wmmintrin_aes.h$", "<wmmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/__wmmintrin_pclmul.h$", "<wmmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/adxintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/ammintrin.h$", "<ammintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx2intrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512bwintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512cdintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512dqintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512erintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512fintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512ifmaintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512ifmavlintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512pfintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512vbmiintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512vbmivlintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512vlbwintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512vlcdintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512vldqintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avx512vlintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/avxintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/bmi2intrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/bmiintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/emmintrin.h$", "<emmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/f16cintrin.h$", "<emmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/float.h$", "<cfloat>"},<br>
+  Â  Â  Â  Â  {"include/fma4intrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/fmaintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/fxsrintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/ia32intrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/immintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/inttypes.h$", "<cinttypes>"},<br>
+  Â  Â  Â  Â  {"include/limits.h$", "<climits>"},<br>
+  Â  Â  Â  Â  {"include/lzcntintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/mm3dnow.h$", "<mm3dnow.h>"},<br>
+  Â  Â  Â  Â  {"include/mm_malloc.h$", "<mm_malloc.h>"},<br>
+  Â  Â  Â  Â  {"include/mmintrin.h$", "<mmintrin>"},<br>
+  Â  Â  Â  Â  {"include/mwaitxintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/pkuintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/pmmintrin.h$", "<pmmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/popcntintrin.h$", "<popcntintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/prfchwintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/rdseedintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/rtmintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/shaintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/smmintrin.h$", "<smmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/stdalign.h$", "<cstdalign>"},<br>
+  Â  Â  Â  Â  {"include/stdarg.h$", "<cstdarg>"},<br>
+  Â  Â  Â  Â  {"include/stdbool.h$", "<cstdbool>"},<br>
+  Â  Â  Â  Â  {"include/stddef.h$", "<cstddef>"},<br>
+  Â  Â  Â  Â  {"include/stdint.h$", "<cstdint>"},<br>
+  Â  Â  Â  Â  {"include/tbmintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/tmmintrin.h$", "<tmmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/wmmintrin.h$", "<wmmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/x86intrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xmmintrin.h$", "<xmmintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xopintrin.h$", "<x86intrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xsavecintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xsaveintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xsaveoptintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xsavesintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/xtestintrin.h$", "<immintrin.h>"},<br>
+  Â  Â  Â  Â  {"include/_G_config.h$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"include/assert.h$", "<cassert>"},<br>
+  Â  Â  Â  Â  {"algorithm$", "<algorithm>"},<br>
+  Â  Â  Â  Â  {"array$", "<array>"},<br>
+  Â  Â  Â  Â  {"atomic$", "<atomic>"},<br>
+  Â  Â  Â  Â  {"backward/auto_ptr.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"backward/binders.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/algorithmfwd.h$", "<algorithm>"},<br>
+  Â  Â  Â  Â  {"bits/alloc_traits.h$", "<unordered_set>"},<br>
+  Â  Â  Â  Â  {"bits/allocator.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/atomic_base.h$", "<atomic>"},<br>
+  Â  Â  Â  Â  {"bits/atomic_lockfree_defines.h$", "<exception>"},<br>
+  Â  Â  Â  Â  {"bits/basic_ios.h$", "<ios>"},<br>
+  Â  Â  Â  Â  {"bits/basic_ios.tcc$", "<ios>"},<br>
+  Â  Â  Â  Â  {"bits/basic_string.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/basic_string.tcc$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/char_traits.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/codecvt.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/concept_check.h$", "<numeric>"},<br>
+  Â  Â  Â  Â  {"bits/cpp_type_traits.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/cxxabi_forced.h$", "<cxxabi.h>"},<br>
+  Â  Â  Â  Â  {"bits/deque.tcc$", "<deque>"},<br>
+  Â  Â  Â  Â  {"bits/exception_defines.h$", "<exception>"},<br>
+  Â  Â  Â  Â  {"bits/exception_ptr.h$", "<exception>"},<br>
+  Â  Â  Â  Â  {"bits/forward_list.h$", "<forward_list>"},<br>
+  Â  Â  Â  Â  {"bits/forward_list.tcc$", "<forward_list>"},<br>
+  Â  Â  Â  Â  {"bits/fstream.tcc$", "<fstream>"},<br>
+  Â  Â  Â  Â  {"bits/functexcept.h$", "<list>"},<br>
+  Â  Â  Â  Â  {"bits/functional_hash.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/gslice.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/gslice_array.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/hash_bytes.h$", "<typeinfo>"},<br>
+  Â  Â  Â  Â  {"bits/hashtable.h$", "<unordered_set>"},<br>
+  Â  Â  Â  Â  {"bits/hashtable_policy.h$", "<unordered_set>"},<br>
+  Â  Â  Â  Â  {"bits/indirect_array.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/ios_base.h$", "<ios>"},<br>
+  Â  Â  Â  Â  {"bits/istream.tcc$", "<istream>"},<br>
+  Â  Â  Â  Â  {"bits/list.tcc$", "<list>"},<br>
+  Â  Â  Â  Â  {"bits/locale_classes.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/locale_classes.tcc$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/locale_facets.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/locale_facets.tcc$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/locale_facets_nonio.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/locale_facets_nonio.tcc$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/localefwd.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/mask_array.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/memoryfwd.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/move.h$", "<utility>"},<br>
+  Â  Â  Â  Â  {"bits/nested_exception.h$", "<exception>"},<br>
+  Â  Â  Â  Â  {"bits/ostream.tcc$", "<ostream>"},<br>
+  Â  Â  Â  Â  {"bits/ostream_insert.h$", "<ostream>"},<br>
+  Â  Â  Â  Â  {"bits/postypes.h$", "<iosfwd>"},<br>
+  Â  Â  Â  Â  {"bits/ptr_traits.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/random.h$", "<random>"},<br>
+  Â  Â  Â  Â  {"bits/random.tcc$", "<random>"},<br>
+  Â  Â  Â  Â  {"bits/range_access.h$", "<iterator>"},<br>
+  Â  Â  Â  Â  {"bits/regex.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_compiler.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_constants.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_cursor.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_error.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_grep_matcher.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_grep_matcher.tcc$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/regex_nfa.h$", "<regex>"},<br>
+  Â  Â  Â  Â  {"bits/shared_ptr.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/shared_ptr_base.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/slice_array.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/sstream.tcc$", "<sstream>"},<br>
+  Â  Â  Â  Â  {"bits/stl_algo.h$", "<algorithm>"},<br>
+  Â  Â  Â  Â  {"bits/stl_algobase.h$", "<list>"},<br>
+  Â  Â  Â  Â  {"bits/stl_bvector.h$", "<vector>"},<br>
+  Â  Â  Â  Â  {"bits/stl_construct.h$", "<deque>"},<br>
+  Â  Â  Â  Â  {"bits/stl_deque.h$", "<deque>"},<br>
+  Â  Â  Â  Â  {"bits/stl_function.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/stl_heap.h$", "<queue>"},<br>
+  Â  Â  Â  Â  {"bits/stl_iterator.h$", "<iterator>"},<br>
+  Â  Â  Â  Â  {"bits/stl_iterator_base_funcs.h$", "<iterator>"},<br>
+  Â  Â  Â  Â  {"bits/stl_iterator_base_types.h$", "<numeric>"},<br>
+  Â  Â  Â  Â  {"bits/stl_list.h$", "<list>"},<br>
+  Â  Â  Â  Â  {"bits/stl_map.h$", "<map>"},<br>
+  Â  Â  Â  Â  {"bits/stl_multimap.h$", "<map>"},<br>
+  Â  Â  Â  Â  {"bits/stl_multiset.h$", "<set>"},<br>
+  Â  Â  Â  Â  {"bits/stl_numeric.h$", "<numeric>"},<br>
+  Â  Â  Â  Â  {"bits/stl_pair.h$", "<utility>"},<br>
+  Â  Â  Â  Â  {"bits/stl_queue.h$", "<queue>"},<br>
+  Â  Â  Â  Â  {"bits/stl_raw_storage_iter.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/stl_relops.h$", "<utility>"},<br>
+  Â  Â  Â  Â  {"bits/stl_set.h$", "<set>"},<br>
+  Â  Â  Â  Â  {"bits/stl_stack.h$", "<stack>"},<br>
+  Â  Â  Â  Â  {"bits/stl_tempbuf.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/stl_tree.h$", "<map>"},<br>
+  Â  Â  Â  Â  {"bits/stl_uninitialized.h$", "<deque>"},<br>
+  Â  Â  Â  Â  {"bits/stl_vector.h$", "<vector>"},<br>
+  Â  Â  Â  Â  {"bits/stream_iterator.h$", "<iterator>"},<br>
+  Â  Â  Â  Â  {"bits/streambuf.tcc$", "<streambuf>"},<br>
+  Â  Â  Â  Â  {"bits/streambuf_iterator.h$", "<iterator>"},<br>
+  Â  Â  Â  Â  {"bits/stringfwd.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/unique_ptr.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/unordered_map.h$", "<unordered_map>"},<br>
+  Â  Â  Â  Â  {"bits/unordered_set.h$", "<unordered_set>"},<br>
+  Â  Â  Â  Â  {"bits/uses_allocator.h$", "<tuple>"},<br>
+  Â  Â  Â  Â  {"bits/valarray_after.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/valarray_array.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/valarray_array.tcc$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/valarray_before.h$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"bits/vector.tcc$", "<vector>"},<br>
+  Â  Â  Â  Â  {"bitset$", "<bitset>"},<br>
+  Â  Â  Â  Â  {"ccomplex$", "<ccomplex>"},<br>
+  Â  Â  Â  Â  {"cctype$", "<cctype>"},<br>
+  Â  Â  Â  Â  {"cerrno$", "<cerrno>"},<br>
+  Â  Â  Â  Â  {"cfenv$", "<cfenv>"},<br>
+  Â  Â  Â  Â  {"cfloat$", "<cfloat>"},<br>
+  Â  Â  Â  Â  {"chrono$", "<chrono>"},<br>
+  Â  Â  Â  Â  {"cinttypes$", "<cinttypes>"},<br>
+  Â  Â  Â  Â  {"climits$", "<climits>"},<br>
+  Â  Â  Â  Â  {"clocale$", "<clocale>"},<br>
+  Â  Â  Â  Â  {"cmath$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"complex$", "<complex>"},<br>
+  Â  Â  Â  Â  {"complex.h$", "<complex.h>"},<br>
+  Â  Â  Â  Â  {"condition_variable$", "<condition_variable>"},<br>
+  Â  Â  Â  Â  {"csetjmp$", "<csetjmp>"},<br>
+  Â  Â  Â  Â  {"csignal$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"cstdalign$", "<cstdalign>"},<br>
+  Â  Â  Â  Â  {"cstdarg$", "<cstdarg>"},<br>
+  Â  Â  Â  Â  {"cstdbool$", "<cstdbool>"},<br>
+  Â  Â  Â  Â  {"cstdint$", "<cstdint>"},<br>
+  Â  Â  Â  Â  {"cstdio$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"cstdlib$", "<cstdlib>"},<br>
+  Â  Â  Â  Â  {"cstring$", "<cstring>"},<br>
+  Â  Â  Â  Â  {"ctgmath$", "<ctgmath>"},<br>
+  Â  Â  Â  Â  {"ctime$", "<ctime>"},<br>
+  Â  Â  Â  Â  {"cwchar$", "<cwchar>"},<br>
+  Â  Â  Â  Â  {"cwctype$", "<cwctype>"},<br>
+  Â  Â  Â  Â  {"cxxabi.h$", "<cxxabi.h>"},<br>
+  Â  Â  Â  Â  {"debug/debug.h$", "<numeric>"},<br>
+  Â  Â  Â  Â  {"deque$", "<deque>"},<br>
+  Â  Â  Â  Â  {"exception$", "<exception>"},<br>
+  Â  Â  Â  Â  {"ext/alloc_traits.h$", "<deque>"},<br>
+  Â  Â  Â  Â  {"ext/atomicity.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"ext/concurrence.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"ext/new_allocator.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"ext/numeric_traits.h$", "<list>"},<br>
+  Â  Â  Â  Â  {"ext/string_conversions.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"ext/type_traits.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"fenv.h$", "<fenv.h>"},<br>
+  Â  Â  Â  Â  {"forward_list$", "<forward_list>"},<br>
+  Â  Â  Â  Â  {"fstream$", "<fstream>"},<br>
+  Â  Â  Â  Â  {"functional$", "<functional>"},<br>
+  Â  Â  Â  Â  {"future$", "<future>"},<br>
+  Â  Â  Â  Â  {"initializer_list$", "<initializer_list>"},<br>
+  Â  Â  Â  Â  {"iomanip$", "<iomanip>"},<br>
+  Â  Â  Â  Â  {"ios$", "<ios>"},<br>
+  Â  Â  Â  Â  {"iosfwd$", "<iosfwd>"},<br>
+  Â  Â  Â  Â  {"iostream$", "<iostream>"},<br>
+  Â  Â  Â  Â  {"istream$", "<istream>"},<br>
+  Â  Â  Â  Â  {"iterator$", "<iterator>"},<br>
+  Â  Â  Â  Â  {"limits$", "<limits>"},<br>
+  Â  Â  Â  Â  {"list$", "<list>"},<br>
+  Â  Â  Â  Â  {"locale$", "<locale>"},<br>
+  Â  Â  Â  Â  {"map$", "<map>"},<br>
+  Â  Â  Â  Â  {"memory$", "<memory>"},<br>
+  Â  Â  Â  Â  {"mutex$", "<mutex>"},<br>
+  Â  Â  Â  Â  {"new$", "<new>"},<br>
+  Â  Â  Â  Â  {"numeric$", "<numeric>"},<br>
+  Â  Â  Â  Â  {"ostream$", "<ostream>"},<br>
+  Â  Â  Â  Â  {"queue$", "<queue>"},<br>
+  Â  Â  Â  Â  {"random$", "<random>"},<br>
+  Â  Â  Â  Â  {"ratio$", "<ratio>"},<br>
+  Â  Â  Â  Â  {"regex$", "<regex>"},<br>
+  Â  Â  Â  Â  {"scoped_allocator$", "<scoped_allocator>"},<br>
+  Â  Â  Â  Â  {"set$", "<set>"},<br>
+  Â  Â  Â  Â  {"sstream$", "<sstream>"},<br>
+  Â  Â  Â  Â  {"stack$", "<stack>"},<br>
+  Â  Â  Â  Â  {"stdexcept$", "<stdexcept>"},<br>
+  Â  Â  Â  Â  {"streambuf$", "<streambuf>"},<br>
+  Â  Â  Â  Â  {"string$", "<string>"},<br>
+  Â  Â  Â  Â  {"system_error$", "<system_error>"},<br>
+  Â  Â  Â  Â  {"tgmath.h$", "<tgmath.h>"},<br>
+  Â  Â  Â  Â  {"thread$", "<thread>"},<br>
+  Â  Â  Â  Â  {"tuple$", "<tuple>"},<br>
+  Â  Â  Â  Â  {"type_traits$", "<type_traits>"},<br>
+  Â  Â  Â  Â  {"typeindex$", "<typeindex>"},<br>
+  Â  Â  Â  Â  {"typeinfo$", "<typeinfo>"},<br>
+  Â  Â  Â  Â  {"unordered_map$", "<unordered_map>"},<br>
+  Â  Â  Â  Â  {"unordered_set$", "<unordered_set>"},<br>
+  Â  Â  Â  Â  {"utility$", "<utility>"},<br>
+  Â  Â  Â  Â  {"valarray$", "<valarray>"},<br>
+  Â  Â  Â  Â  {"vector$", "<vector>"},<br>
+  Â  Â  Â  Â  {"include/complex.h$", "<complex.h>"},<br>
+  Â  Â  Â  Â  {"include/ctype.h$", "<cctype>"},<br>
+  Â  Â  Â  Â  {"include/errno.h$", "<cerrno>"},<br>
+  Â  Â  Â  Â  {"include/fenv.h$", "<fenv.h>"},<br>
+  Â  Â  Â  Â  {"include/inttypes.h$", "<cinttypes>"},<br>
+  Â  Â  Â  Â  {"include/libio.h$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"include/limits.h$", "<climits>"},<br>
+  Â  Â  Â  Â  {"include/locale.h$", "<clocale>"},<br>
+  Â  Â  Â  Â  {"include/math.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"include/setjmp.h$", "<csetjmp>"},<br>
+  Â  Â  Â  Â  {"include/signal.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"include/stdint.h$", "<cstdint>"},<br>
+  Â  Â  Â  Â  {"include/stdio.h$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"include/stdlib.h$", "<cstdlib>"},<br>
+  Â  Â  Â  Â  {"include/string.h$", "<cstring>"},<br>
+  Â  Â  Â  Â  {"include/time.h$", "<ctime>"},<br>
+  Â  Â  Â  Â  {"include/wchar.h$", "<cwchar>"},<br>
+  Â  Â  Â  Â  {"include/wctype.h$", "<cwctype>"},<br>
+  Â  Â  Â  Â  {"bits/cmathcalls.h$", "<complex.h>"},<br>
+  Â  Â  Â  Â  {"bits/errno.h$", "<cerrno>"},<br>
+  Â  Â  Â  Â  {"bits/fenv.h$", "<fenv.h>"},<br>
+  Â  Â  Â  Â  {"bits/huge_val.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/huge_valf.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/huge_vall.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/inf.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/local_lim.h$", "<climits>"},<br>
+  Â  Â  Â  Â  {"bits/locale.h$", "<clocale>"},<br>
+  Â  Â  Â  Â  {"bits/mathcalls.h$", "<math.h>"},<br>
+  Â  Â  Â  Â  {"bits/mathdef.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/nan.h$", "<cmath>"},<br>
+  Â  Â  Â  Â  {"bits/posix1_lim.h$", "<climits>"},<br>
+  Â  Â  Â  Â  {"bits/posix2_lim.h$", "<climits>"},<br>
+  Â  Â  Â  Â  {"bits/setjmp.h$", "<csetjmp>"},<br>
+  Â  Â  Â  Â  {"bits/sigaction.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"bits/sigcontext.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"bits/siginfo.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"bits/signum.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"bits/sigset.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"bits/sigstack.h$", "<csignal>"},<br>
+  Â  Â  Â  Â  {"bits/stdio_lim.h$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"bits/sys_errlist.h$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"bits/time.h$", "<ctime>"},<br>
+  Â  Â  Â  Â  {"bits/timex.h$", "<ctime>"},<br>
+  Â  Â  Â  Â  {"bits/typesizes.h$", "<cstdio>"},<br>
+  Â  Â  Â  Â  {"bits/wchar.h$", "<cwchar>"},<br>
+  Â  Â  Â  Â  {"bits/wordsize.h$", "<csetjmp>"},<br>
+  Â  Â  Â  Â  {"bits/xopen_lim.h$", "<climits>"},<br>
+  Â  Â  Â  Â  {"include/xlocale.h$", "<cstring>"},<br>
+  Â  Â  Â  Â  {"bits/atomic_word.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/basic_file.h$", "<fstream>"},<br>
+  Â  Â  Â  Â  {"bits/c\\+\\+allocator.h$", "<string>"},<br>
+  Â  Â  Â  Â  {"bits/c\\+\\+config.h$", "<iosfwd>"},<br>
+  Â  Â  Â  Â  {"bits/c\\+\\+io.h$", "<ios>"},<br>
+  Â  Â  Â  Â  {"bits/c\\+\\+locale.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/cpu_defines.h$", "<iosfwd>"},<br>
+  Â  Â  Â  Â  {"bits/ctype_base.h$", "<locale>"},<br>
+  Â  Â  Â  Â  {"bits/cxxabi_tweaks.h$", "<cxxabi.h>"},<br>
+  Â  Â  Â  Â  {"bits/error_constants.h$", "<system_error>"},<br>
+  Â  Â  Â  Â  {"bits/gthr-default.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/gthr.h$", "<memory>"},<br>
+  Â  Â  Â  Â  {"bits/opt_random.h$", "<random>"},<br>
+  Â  Â  Â  Â  {"bits/os_defines.h$", "<iosfwd>"},<br>
+  Â  Â  Â  Â  // GNU C headers<br>
+  Â  Â  Â  Â  {"include/aio.h$", "<aio.h>"},<br>
+  Â  Â  Â  Â  {"include/aliases.h$", "<aliases.h>"},<br>
+  Â  Â  Â  Â  {"include/alloca.h$", "<alloca.h>"},<br>
+  Â  Â  Â  Â  {"include/ar.h$", "<ar.h>"},<br>
+  Â  Â  Â  Â  {"include/argp.h$", "<argp.h>"},<br>
+  Â  Â  Â  Â  {"include/argz.h$", "<argz.h>"},<br>
+  Â  Â  Â  Â  {"include/arpa/nameser.h$", "<resolv.h>"},<br>
+  Â  Â  Â  Â  {"include/arpa/nameser_compat.h$", "<resolv.h>"},<br>
+  Â  Â  Â  Â  {"include/byteswap.h$", "<byteswap.h>"},<br>
+  Â  Â  Â  Â  {"include/cpio.h$", "<cpio.h>"},<br>
+  Â  Â  Â  Â  {"include/crypt.h$", "<crypt.h>"},<br>
+  Â  Â  Â  Â  {"include/dirent.h$", "<dirent.h>"},<br>
+  Â  Â  Â  Â  {"include/dlfcn.h$", "<dlfcn.h>"},<br>
+  Â  Â  Â  Â  {"include/elf.h$", "<elf.h>"},<br>
+  Â  Â  Â  Â  {"include/endian.h$", "<endian.h>"},<br>
+  Â  Â  Â  Â  {"include/envz.h$", "<envz.h>"},<br>
+  Â  Â  Â  Â  {"include/err.h$", "<err.h>"},<br>
+  Â  Â  Â  Â  {"include/error.h$", "<error.h>"},<br>
+  Â  Â  Â  Â  {"include/execinfo.h$", "<execinfo.h>"},<br>
+  Â  Â  Â  Â  {"include/fcntl.h$", "<fcntl.h>"},<br>
+  Â  Â  Â  Â  {"include/features.h$", "<features.h>"},<br>
+  Â  Â  Â  Â  {"include/fenv.h$", "<fenv.h>"},<br>
+  Â  Â  Â  Â  {"include/fmtmsg.h$", "<fmtmsg.h>"},<br>
+  Â  Â  Â  Â  {"include/fnmatch.h$", "<fnmatch.h>"},<br>
+  Â  Â  Â  Â  {"include/fstab.h$", "<fstab.h>"},<br>
+  Â  Â  Â  Â  {"include/fts.h$", "<fts.h>"},<br>
+  Â  Â  Â  Â  {"include/ftw.h$", "<ftw.h>"},<br>
+  Â  Â  Â  Â  {"include/gconv.h$", "<gconv.h>"},<br>
+  Â  Â  Â  Â  {"include/getopt.h$", "<getopt.h>"},<br>
+  Â  Â  Â  Â  {"include/glob.h$", "<glob.h>"},<br>
+  Â  Â  Â  Â  {"include/grp.h$", "<grp.h>"},<br>
+  Â  Â  Â  Â  {"include/gshadow.h$", "<gshadow.h>"},<br>
+  Â  Â  Â  Â  {"include/iconv.h$", "<iconv.h>"},<br>
+  Â  Â  Â  Â  {"include/ifaddrs.h$", "<ifaddrs.h>"},<br>
+  Â  Â  Â  Â  {"include/kdb.h$", "<kdb.h>"},<br>
+  Â  Â  Â  Â  {"include/langinfo.h$", "<langinfo.h>"},<br>
+  Â  Â  Â  Â  {"include/libgen.h$", "<libgen.h>"},<br>
+  Â  Â  Â  Â  {"include/libintl.h$", "<libintl.h>"},<br>
+  Â  Â  Â  Â  {"include/link.h$", "<link.h>"},<br>
+  Â  Â  Â  Â  {"include/malloc.h$", "<malloc.h>"},<br>
+  Â  Â  Â  Â  {"include/mcheck.h$", "<mcheck.h>"},<br>
+  Â  Â  Â  Â  {"include/memory.h$", "<memory.h>"},<br>
+  Â  Â  Â  Â  {"include/mntent.h$", "<mntent.h>"},<br>
+  Â  Â  Â  Â  {"include/monetary.h$", "<monetary.h>"},<br>
+  Â  Â  Â  Â  {"include/mqueue.h$", "<mqueue.h>"},<br>
+  Â  Â  Â  Â  {"include/netdb.h$", "<netdb.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/in.h$", "<netinet/in.h>"},<br>
+  Â  Â  Â  Â  {"include/nl_types.h$", "<nl_types.h>"},<br>
+  Â  Â  Â  Â  {"include/nss.h$", "<nss.h>"},<br>
+  Â  Â  Â  Â  {"include/obstack.h$", "<obstack.h>"},<br>
+  Â  Â  Â  Â  {"include/panel.h$", "<panel.h>"},<br>
+  Â  Â  Â  Â  {"include/paths.h$", "<paths.h>"},<br>
+  Â  Â  Â  Â  {"include/printf.h$", "<printf.h>"},<br>
+  Â  Â  Â  Â  {"include/profile.h$", "<profile.h>"},<br>
+  Â  Â  Â  Â  {"include/pthread.h$", "<pthread.h>"},<br>
+  Â  Â  Â  Â  {"include/pty.h$", "<pty.h>"},<br>
+  Â  Â  Â  Â  {"include/pwd.h$", "<pwd.h>"},<br>
+  Â  Â  Â  Â  {"include/re_comp.h$", "<re_comp.h>"},<br>
+  Â  Â  Â  Â  {"include/regex.h$", "<regex.h>"},<br>
+  Â  Â  Â  Â  {"include/regexp.h$", "<regexp.h>"},<br>
+  Â  Â  Â  Â  {"include/resolv.h$", "<resolv.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/netdb.h$", "<netdb.h>"},<br>
+  Â  Â  Â  Â  {"include/sched.h$", "<sched.h>"},<br>
+  Â  Â  Â  Â  {"include/search.h$", "<search.h>"},<br>
+  Â  Â  Â  Â  {"include/semaphore.h$", "<semaphore.h>"},<br>
+  Â  Â  Â  Â  {"include/sgtty.h$", "<sgtty.h>"},<br>
+  Â  Â  Â  Â  {"include/shadow.h$", "<shadow.h>"},<br>
+  Â  Â  Â  Â  {"include/spawn.h$", "<spawn.h>"},<br>
+  Â  Â  Â  Â  {"include/stab.h$", "<stab.h>"},<br>
+  Â  Â  Â  Â  {"include/stdc-predef.h$", "<stdc-predef.h>"},<br>
+  Â  Â  Â  Â  {"include/stdio_ext.h$", "<stdio_ext.h>"},<br>
+  Â  Â  Â  Â  {"include/strings.h$", "<strings.h>"},<br>
+  Â  Â  Â  Â  {"include/stropts.h$", "<stropts.h>"},<br>
+  Â  Â  Â  Â  {"include/sudo_plugin.h$", "<sudo_plugin.h>"},<br>
+  Â  Â  Â  Â  {"include/sysexits.h$", "<sysexits.h>"},<br>
+  Â  Â  Â  Â  {"include/tar.h$", "<tar.h>"},<br>
+  Â  Â  Â  Â  {"include/tcpd.h$", "<tcpd.h>"},<br>
+  Â  Â  Â  Â  {"include/term.h$", "<term.h>"},<br>
+  Â  Â  Â  Â  {"include/term_entry.h$", "<term_entry.h>"},<br>
+  Â  Â  Â  Â  {"include/termcap.h$", "<termcap.h>"},<br>
+  Â  Â  Â  Â  {"include/termios.h$", "<termios.h>"},<br>
+  Â  Â  Â  Â  {"include/thread_db.h$", "<thread_db.h>"},<br>
+  Â  Â  Â  Â  {"include/tic.h$", "<tic.h>"},<br>
+  Â  Â  Â  Â  {"include/ttyent.h$", "<ttyent.h>"},<br>
+  Â  Â  Â  Â  {"include/uchar.h$", "<uchar.h>"},<br>
+  Â  Â  Â  Â  {"include/ucontext.h$", "<ucontext.h>"},<br>
+  Â  Â  Â  Â  {"include/ulimit.h$", "<ulimit.h>"},<br>
+  Â  Â  Â  Â  {"include/unctrl.h$", "<unctrl.h>"},<br>
+  Â  Â  Â  Â  {"include/unistd.h$", "<unistd.h>"},<br>
+  Â  Â  Â  Â  {"include/utime.h$", "<utime.h>"},<br>
+  Â  Â  Â  Â  {"include/utmp.h$", "<utmp.h>"},<br>
+  Â  Â  Â  Â  {"include/utmpx.h$", "<utmpx.h>"},<br>
+  Â  Â  Â  Â  {"include/values.h$", "<values.h>"},<br>
+  Â  Â  Â  Â  {"include/wordexp.h$", "<wordexp.h>"},<br>
+  Â  Â  Â  Â  {"fpu_control.h$", "<fpu_control.h>"},<br>
+  Â  Â  Â  Â  {"ieee754.h$", "<ieee754.h>"},<br>
+  Â  Â  Â  Â  {"include/xlocale.h$", "<xlocale.h>"},<br>
+  Â  Â  Â  Â  {"gnu/lib-names.h$", "<gnu/lib-names.h>"},<br>
+  Â  Â  Â  Â  {"gnu/libc-version.h$", "<gnu/libc-version.h>"},<br>
+  Â  Â  Â  Â  {"gnu/option-groups.h$", "<gnu/option-groups.h>"},<br>
+  Â  Â  Â  Â  {"gnu/stubs-32.h$", "<gnu/stubs-32.h>"},<br>
+  Â  Â  Â  Â  {"gnu/stubs-64.h$", "<gnu/stubs-64.h>"},<br>
+  Â  Â  Â  Â  {"gnu/stubs-x32.h$", "<gnu/stubs-x32.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/auth_des.h$", "<rpc/auth_des.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/rpc_msg.h$", "<rpc/rpc_msg.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/pmap_clnt.h$", "<rpc/pmap_clnt.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/rpc.h$", "<rpc/rpc.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/types.h$", "<rpc/types.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/auth_unix.h$", "<rpc/auth_unix.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/key_prot.h$", "<rpc/key_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/pmap_prot.h$", "<rpc/pmap_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/auth.h$", "<rpc/auth.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/svc_auth.h$", "<rpc/svc_auth.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/xdr.h$", "<rpc/xdr.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/pmap_rmt.h$", "<rpc/pmap_rmt.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/des_crypt.h$", "<rpc/des_crypt.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/svc.h$", "<rpc/svc.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/rpc_des.h$", "<rpc/rpc_des.h>"},<br>
+  Â  Â  Â  Â  {"include/rpc/clnt.h$", "<rpc/clnt.h>"},<br>
+  Â  Â  Â  Â  {"include/scsi/scsi.h$", "<scsi/scsi.h>"},<br>
+  Â  Â  Â  Â  {"include/scsi/sg.h$", "<scsi/sg.h>"},<br>
+  Â  Â  Â  Â  {"include/scsi/scsi_ioctl.h$", "<scsi/scsi_ioctl>"},<br>
+  Â  Â  Â  Â  {"include/netrose/rose.h$", "<netrose/rose.h>"},<br>
+  Â  Â  Â  Â  {"include/nfs/nfs.h$", "<nfs/nfs.h>"},<br>
+  Â  Â  Â  Â  {"include/netatalk/at.h$", "<netatalk/at.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/ether.h$", "<netinet/ether.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/icmp6.h$", "<netinet/icmp6.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/if_ether.h$", "<netinet/if_ether.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/if_fddi.h$", "<netinet/if_fddi.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/if_tr.h$", "<netinet/if_tr.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/igmp.h$", "<netinet/igmp.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/in.h$", "<netinet/in.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/in_systm.h$", "<netinet/in_systm.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/ip.h$", "<netinet/ip.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/ip6.h$", "<netinet/ip6.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/ip_icmp.h$", "<netinet/ip_icmp.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/tcp.h$", "<netinet/tcp.h>"},<br>
+  Â  Â  Â  Â  {"include/netinet/udp.h$", "<netinet/udp.h>"},<br>
+  Â  Â  Â  Â  {"include/netrom/netrom.h$", "<netrom/netrom.h>"},<br>
+  Â  Â  Â  Â  {"include/protocols/routed.h$", "<protocols/routed.h>"},<br>
+  Â  Â  Â  Â  {"include/protocols/rwhod.h$", "<protocols/rwhod.h>"},<br>
+  Â  Â  Â  Â  {"include/protocols/talkd.h$", "<protocols/talkd.h>"},<br>
+  Â  Â  Â  Â  {"include/protocols/timed.h$", "<protocols/timed.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/klm_prot.x$", "<rpcsvc/klm_prot.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rstat.h$", "<rpcsvc/rstat.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/spray.x$", "<rpcsvc/spray.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nlm_prot.x$", "<rpcsvc/nlm_prot.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nis_callback.x$", "<rpcsvc/nis_callback.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/yp.h$", "<rpcsvc/yp.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/yp.x$", "<rpcsvc/yp.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nfs_prot.h$", "<rpcsvc/nfs_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rex.h$", "<rpcsvc/rex.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/yppasswd.h$", "<rpcsvc/yppasswd.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rex.x$", "<rpcsvc/rex.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nis_tags.h$", "<rpcsvc/nis_tags.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nis_callback.h$", "<rpcsvc/nis_callback.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nfs_prot.x$", "<rpcsvc/nfs_prot.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/bootparam_prot.x$", "<rpcsvc/bootparam_prot.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rusers.x$", "<rpcsvc/rusers.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rquota.x$", "<rpcsvc/rquota.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nis.h$", "<rpcsvc/nis.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nislib.h$", "<rpcsvc/nislib.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/ypupd.h$", "<rpcsvc/ypupd.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/bootparam.h$", "<rpcsvc/bootparam.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/spray.h$", "<rpcsvc/spray.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/key_prot.h$", "<rpcsvc/key_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/klm_prot.h$", "<rpcsvc/klm_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/sm_inter.h$", "<rpcsvc/sm_inter.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nlm_prot.h$", "<rpcsvc/nlm_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/yp_prot.h$", "<rpcsvc/yp_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/ypclnt.h$", "<rpcsvc/ypclnt.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rstat.x$", "<rpcsvc/rstat.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rusers.h$", "<rpcsvc/rusers.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/key_prot.x$", "<rpcsvc/key_prot.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/sm_inter.x$", "<rpcsvc/sm_inter.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/rquota.h$", "<rpcsvc/rquota.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nis.x$", "<rpcsvc/nis.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/bootparam_prot.h$", "<rpcsvc/bootparam_prot.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/mount.h$", "<rpcsvc/mount.h>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/mount.x$", "<rpcsvc/mount.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/nis_object.x$", "<rpcsvc/nis_object.x>"},<br>
+  Â  Â  Â  Â  {"include/rpcsvc/yppasswd.x$", "<rpcsvc/yppasswd.x>"},<br>
+  Â  Â  Â  Â  {"sys/acct.h$", "<sys/acct.h>"},<br>
+  Â  Â  Â  Â  {"sys/auxv.h$", "<sys/auxv.h>"},<br>
+  Â  Â  Â  Â  {"sys/cdefs.h$", "<sys/cdefs.h>"},<br>
+  Â  Â  Â  Â  {"sys/debugreg.h$", "<sys/debugreg.h>"},<br>
+  Â  Â  Â  Â  {"sys/dir.h$", "<sys/dir.h>"},<br>
+  Â  Â  Â  Â  {"sys/elf.h$", "<sys/elf.h>"},<br>
+  Â  Â  Â  Â  {"sys/epoll.h$", "<sys/epoll.h>"},<br>
+  Â  Â  Â  Â  {"sys/eventfd.h$", "<sys/eventfd.h>"},<br>
+  Â  Â  Â  Â  {"sys/fanotify.h$", "<sys/fanotify.h>"},<br>
+  Â  Â  Â  Â  {"sys/file.h$", "<sys/file.h>"},<br>
+  Â  Â  Â  Â  {"sys/fsuid.h$", "<sys/fsuid.h>"},<br>
+  Â  Â  Â  Â  {"sys/gmon.h$", "<sys/gmon.h>"},<br>
+  Â  Â  Â  Â  {"sys/gmon_out.h$", "<sys/gmon_out.h>"},<br>
+  Â  Â  Â  Â  {"sys/inotify.h$", "<sys/inotify.h>"},<br>
+  Â  Â  Â  Â  {"sys/io.h$", "<sys/io.h>"},<br>
+  Â  Â  Â  Â  {"sys/ioctl.h$", "<sys/ioctl.h>"},<br>
+  Â  Â  Â  Â  {"sys/ipc.h$", "<sys/ipc.h>"},<br>
+  Â  Â  Â  Â  {"sys/kd.h$", "<sys/kd.h>"},<br>
+  Â  Â  Â  Â  {"sys/kdaemon.h$", "<sys/kdaemon.h>"},<br>
+  Â  Â  Â  Â  {"sys/klog.h$", "<sys/klog.h>"},<br>
+  Â  Â  Â  Â  {"sys/mman.h$", "<sys/mman.h>"},<br>
+  Â  Â  Â  Â  {"sys/mount.h$", "<sys/mount.h>"},<br>
+  Â  Â  Â  Â  {"sys/msg.h$", "<sys/msg.h>"},<br>
+  Â  Â  Â  Â  {"sys/mtio.h$", "<sys/mtio.h>"},<br>
+  Â  Â  Â  Â  {"sys/param.h$", "<sys/param.h>"},<br>
+  Â  Â  Â  Â  {"sys/pci.h$", "<sys/pci.h>"},<br>
+  Â  Â  Â  Â  {"sys/perm.h$", "<sys/perm.h>"},<br>
+  Â  Â  Â  Â  {"sys/personality.h$", "<sys/personality.h>"},<br>
+  Â  Â  Â  Â  {"sys/poll.h$", "<sys/poll.h>"},<br>
+  Â  Â  Â  Â  {"sys/prctl.h$", "<sys/prctl.h>"},<br>
+  Â  Â  Â  Â  {"sys/procfs.h$", "<sys/procfs.h>"},<br>
+  Â  Â  Â  Â  {"sys/profil.h$", "<sys/profil.h>"},<br>
+  Â  Â  Â  Â  {"sys/ptrace.h$", "<sys/ptrace.h>"},<br>
+  Â  Â  Â  Â  {"sys/queue.h$", "<sys/queue.h>"},<br>
+  Â  Â  Â  Â  {"sys/quota.h$", "<sys/quota.h>"},<br>
+  Â  Â  Â  Â  {"sys/raw.h$", "<sys/raw.h>"},<br>
+  Â  Â  Â  Â  {"sys/reboot.h$", "<sys/reboot.h>"},<br>
+  Â  Â  Â  Â  {"sys/reg.h$", "<sys/reg.h>"},<br>
+  Â  Â  Â  Â  {"sys/resource.h$", "<sys/resource.h>"},<br>
+  Â  Â  Â  Â  {"sys/select.h$", "<sys/select.h>"},<br>
+  Â  Â  Â  Â  {"sys/sem.h$", "<sys/sem.h>"},<br>
+  Â  Â  Â  Â  {"sys/sendfile.h$", "<sys/sendfile.h>"},<br>
+  Â  Â  Â  Â  {"sys/shm.h$", "<sys/shm.h>"},<br>
+  Â  Â  Â  Â  {"sys/signalfd.h$", "<sys/signalfd.h>"},<br>
+  Â  Â  Â  Â  {"sys/socket.h$", "<sys/socket.h>"},<br>
+  Â  Â  Â  Â  {"sys/stat.h$", "<sys/stat.h>"},<br>
+  Â  Â  Â  Â  {"sys/statfs.h$", "<sys/statfs.h>"},<br>
+  Â  Â  Â  Â  {"sys/statvfs.h$", "<sys/statvfs.h>"},<br>
+  Â  Â  Â  Â  {"sys/swap.h$", "<sys/swap.h>"},<br>
+  Â  Â  Â  Â  {"sys/syscall.h$", "<sys/syscall.h>"},<br>
+  Â  Â  Â  Â  {"sys/sysctl.h$", "<sys/sysctl.h>"},<br>
+  Â  Â  Â  Â  {"sys/sysinfo.h$", "<sys/sysinfo.h>"},<br>
+  Â  Â  Â  Â  {"sys/syslog.h$", "<sys/syslog.h>"},<br>
+  Â  Â  Â  Â  {"sys/sysmacros.h$", "<sys/sysmacros.h>"},<br>
+  Â  Â  Â  Â  {"sys/termios.h$", "<sys/termios.h>"},<br>
+  Â  Â  Â  Â  {"sys/time.h$", "<sys/select.h>"},<br>
+  Â  Â  Â  Â  {"sys/timeb.h$", "<sys/timeb.h>"},<br>
+  Â  Â  Â  Â  {"sys/timerfd.h$", "<sys/timerfd.h>"},<br>
+  Â  Â  Â  Â  {"sys/times.h$", "<sys/times.h>"},<br>
+  Â  Â  Â  Â  {"sys/timex.h$", "<sys/timex.h>"},<br>
+  Â  Â  Â  Â  {"sys/ttychars.h$", "<sys/ttychars.h>"},<br>
+  Â  Â  Â  Â  {"sys/ttydefaults.h$", "<sys/ttydefaults.h>"},<br>
+  Â  Â  Â  Â  {"sys/types.h$", "<sys/types.h>"},<br>
+  Â  Â  Â  Â  {"sys/ucontext.h$", "<sys/ucontext.h>"},<br>
+  Â  Â  Â  Â  {"sys/uio.h$", "<sys/uio.h>"},<br>
+  Â  Â  Â  Â  {"sys/un.h$", "<sys/un.h>"},<br>
+  Â  Â  Â  Â  {"sys/user.h$", "<sys/user.h>"},<br>
+  Â  Â  Â  Â  {"sys/ustat.h$", "<sys/ustat.h>"},<br>
+  Â  Â  Â  Â  {"sys/utsname.h$", "<sys/utsname.h>"},<br>
+  Â  Â  Â  Â  {"sys/vlimit.h$", "<sys/vlimit.h>"},<br>
+  Â  Â  Â  Â  {"sys/vm86.h$", "<sys/vm86.h>"},<br>
+  Â  Â  Â  Â  {"sys/vtimes.h$", "<sys/vtimes.h>"},<br>
+  Â  Â  Â  Â  {"sys/wait.h$", "<sys/wait.h>"},<br>
+  Â  Â  Â  Â  {"sys/xattr.h$", "<sys/xattr.h>"},<br>
+  Â  Â  Â  Â  {"bits/epoll.h$", "<sys/epoll.h>"},<br>
+  Â  Â  Â  Â  {"bits/eventfd.h$", "<sys/eventfd.h>"},<br>
+  Â  Â  Â  Â  {"bits/inotify.h$", "<sys/inotify.h>"},<br>
+  Â  Â  Â  Â  {"bits/ipc.h$", "<sys/ipc.h>"},<br>
+  Â  Â  Â  Â  {"bits/ipctypes.h$", "<sys/ipc.h>"},<br>
+  Â  Â  Â  Â  {"bits/mman-linux.h$", "<sys/mman.h>"},<br>
+  Â  Â  Â  Â  {"bits/mman.h$", "<sys/mman.h>"},<br>
+  Â  Â  Â  Â  {"bits/msq.h$", "<sys/msg.h>"},<br>
+  Â  Â  Â  Â  {"bits/resource.h$", "<sys/resource.h>"},<br>
+  Â  Â  Â  Â  {"bits/sem.h$", "<sys/sem.h>"},<br>
+  Â  Â  Â  Â  {"bits/shm.h$", "<sys/shm.h>"},<br>
+  Â  Â  Â  Â  {"bits/signalfd.h$", "<sys/signalfd.h>"},<br>
+  Â  Â  Â  Â  {"bits/statfs.h$", "<sys/statfs.h>"},<br>
+  Â  Â  Â  Â  {"bits/statvfs.h$", "<sys/statvfs.h>"},<br>
+  Â  Â  Â  Â  {"bits/timerfd.h$", "<sys/timerfd.h>"},<br>
+  Â  Â  Â  Â  {"bits/utsname.h$", "<sys/utsname.h>"},<br>
+  Â  Â  Â  Â  {"bits/auxv.h$", "<sys/auxv.h>"},<br>
+  Â  Â  Â  Â  {"bits/byteswap-16.h$", "<byteswap.h>"},<br>
+  Â  Â  Â  Â  {"bits/byteswap.h$", "<byteswap.h>"},<br>
+  Â  Â  Â  Â  {"bits/confname.h$", "<unistd.h>"},<br>
+  Â  Â  Â  Â  {"bits/dirent.h$", "<dirent.h>"},<br>
+  Â  Â  Â  Â  {"bits/dlfcn.h$", "<dlfcn.h>"},<br>
+  Â  Â  Â  Â  {"bits/elfclass.h$", "<link.h>"},<br>
+  Â  Â  Â  Â  {"bits/endian.h$", "<endian.h>"},<br>
+  Â  Â  Â  Â  {"bits/environments.h$", "<unistd.h>"},<br>
+  Â  Â  Â  Â  {"bits/fcntl-linux.h$", "<fcntl.h>"},<br>
+  Â  Â  Â  Â  {"bits/fcntl.h$", "<fcntl.h>"},<br>
+  Â  Â  Â  Â  {"bits/in.h$", "<netinet/in.h>"},<br>
+  Â  Â  Â  Â  {"bits/ioctl-types.h$", "<sys/ioctl.h>"},<br>
+  Â  Â  Â  Â  {"bits/ioctls.h$", "<sys/ioctl.h>"},<br>
+  Â  Â  Â  Â  {"bits/link.h$", "<link.h>"},<br>
+  Â  Â  Â  Â  {"bits/mqueue.h$", "<mqueue.h>"},<br>
+  Â  Â  Â  Â  {"bits/netdb.h$", "<netdb.h>"},<br>
+  Â  Â  Â  Â  {"bits/param.h$", "<sys/param.h>"},<br>
+  Â  Â  Â  Â  {"bits/poll.h$", "<sys/poll.h>"},<br>
+  Â  Â  Â  Â  {"bits/posix_opt.h$", "<bits/posix_opt.h>"},<br>
+  Â  Â  Â  Â  {"bits/pthreadtypes.h$", "<pthread.h>"},<br>
+  Â  Â  Â  Â  {"bits/sched.h$", "<sched.h>"},<br>
+  Â  Â  Â  Â  {"bits/select.h$", "<sys/select.h>"},<br>
+  Â  Â  Â  Â  {"bits/semaphore.h$", "<semaphore.h>"},<br>
+  Â  Â  Â  Â  {"bits/sigthread.h$", "<pthread.h>"},<br>
+  Â  Â  Â  Â  {"bits/sockaddr.h$", "<sys/socket.h>"},<br>
+  Â  Â  Â  Â  {"bits/socket.h$", "<sys/socket.h>"},<br>
+  Â  Â  Â  Â  {"bits/socket_type.h$", "<sys/socket.h>"},<br>
+  Â  Â  Â  Â  {"bits/stab.def$", "<stab.h>"},<br>
+  Â  Â  Â  Â  {"bits/stat.h$", "<sys/stat.h>"},<br>
+  Â  Â  Â  Â  {"bits/stropts.h$", "<stropts.h>"},<br>
+  Â  Â  Â  Â  {"bits/syscall.h$", "<sys/syscall.h>"},<br>
+  Â  Â  Â  Â  {"bits/syslog-path.h$", "<sys/syslog.h>"},<br>
+  Â  Â  Â  Â  {"bits/termios.h$", "<termios.h>"},<br>
+  Â  Â  Â  Â  {"bits/types.h$", "<sys/types.h>"},<br>
+  Â  Â  Â  Â  {"bits/typesizes.h$", "<sys/types.h>"},<br>
+  Â  Â  Â  Â  {"bits/uio.h$", "<sys/uio.h>"},<br>
+  Â  Â  Â  Â  {"bits/ustat.h$", "<sys/ustat.h>"},<br>
+  Â  Â  Â  Â  {"bits/utmp.h$", "<utmp.h>"},<br>
+  Â  Â  Â  Â  {"bits/utmpx.h$", "<utmpx.h>"},<br>
+  Â  Â  Â  Â  {"bits/waitflags.h$", "<sys/wait.h>"},<br>
+  Â  Â  Â  Â  {"bits/waitstatus.h$", "<sys/wait.h>"},<br>
+  Â  Â  Â  Â  {"bits/xtitypes.h$", "<stropts.h>"},<br>
+  Â  Â  };<br>
+  for (const auto &Pair : SystemHeaderMap)<br>
+  Â  Includes->addRegexMapping(Pair.first, Pair.second);<br>
+}<br>
+<br>
+} // namespace clangd<br>
+} // namespace clang<br>
<br>
Added: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h?rev=325343&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h?rev=325343&view=auto</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h (added)<br>
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h Fri Feb 16 06:15:55 2018<br>
@@ -0,0 +1,79 @@<br>
+//===-- CanonicalIncludes.h - remap #include header -------------*- C++ -*-===//<br>
+//<br>
+//  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// At indexing time, we decide which file to #included for a symbol.<br>
+// Usually this is the file with the canonical decl, but there are exceptions:<br>
+// - private headers may have pragmas pointing to the matching public header.<br>
+//  Â (These are "IWYU" pragmas, named after the include-what-you-use tool).<br>
+// - the standard library is implemented in many files, without any pragmas.<br>
+//  Â We have a lookup table for common standard library implementations.<br>
+//  Â libstdc++ puts char_traits in bits/char_traits.h, but we #include <string>.<br>
+//<br>
+//===---------------------------------------------------------------------===//<br>
+<br>
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_CANONICALINCLUDES_H<br>
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_CANONICALINCLUDES_H<br>
+<br>
+#include "clang/Lex/Preprocessor.h"<br>
+#include "llvm/ADT/StringMap.h"<br>
+#include "llvm/Support/Regex.h"<br>
+#include <string><br>
+#include <vector><br>
+<br>
+namespace clang {<br>
+namespace clangd {<br>
+<br>
+/// Maps a definition location onto an #include file, based on a set of filename<br>
+/// rules.<br>
+class CanonicalIncludes {<br>
+public:<br>
+  CanonicalIncludes() = default;<br>
+<br>
+  /// Adds a string-to-string mapping from \p Path to \p CanonicalPath.<br>
+  void addMapping(llvm::StringRef Path, llvm::StringRef CanonicalPath);<br>
+<br>
+  /// Maps all files matching \p RE to \p CanonicalPath<br>
+  void addRegexMapping(llvm::StringRef RE, llvm::StringRef CanonicalPath);<br>
+<br>
+  /// \return \p Header itself if there is no mapping for it; otherwise, return<br>
+  /// a canonical header name.<br>
+  llvm::StringRef mapHeader(llvm::StringRef Header) const;<br>
+<br>
+private:<br>
+  // A map from header patterns to header names. This needs to be mutable so<br>
+  // that we can match again a Regex in a const function member.<br>
+  // FIXME(ioeric): All the regexes we have so far are suffix matches. The<br>
+  // performance could be improved by allowing only suffix matches instead of<br>
+  // arbitrary regexes.<br>
+  mutable std::vector<std::pair<llvm::Regex, std::string>><br>
+  Â  Â  RegexHeaderMappingTable;<br>
+};<br>
+<br>
+/// Returns a CommentHandler that parses pragma comment on include files to<br>
+/// determine when we should include a different header from the header that<br>
+/// directly defines a symbol. Mappinps are registered with \p Includes.<br>
+///<br>
+/// Currently it only supports IWYU private pragma:<br></blockquote></div></div></blockquote></div></div></blockquote></div></blockquote></div></blockquote></div></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+/// <a href="<a href="https://github.com/include-what-you-use/include-wh" target="_blank">https://github.com/include-what-you-use/include-wh</a></blockquote></div></div></blockquote></div></div></blockquote></div></blockquote></div></blockquote></div></div></div></blockquote></div></div></div>