<div dir="ltr">Attempt a fix with r326365<div><br><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><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><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><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>
+/// <a href="https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private" rel="noreferrer" target="_blank">https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-private</a><br>
+std::unique_ptr<CommentHandler><br>
+collectIWYUHeaderMaps(CanonicalIncludes *Includes);<br>
+<br>
+/// Adds mapping for system headers. Approximately, the following system headers<br>
+/// are handled:<br>
+/// - C++ standard library e.g. bits/basic_string.h$ -> <string><br>
+/// - Posix libr</blockquote></div></div></blockquote></div></div></blockquote></div></blockquote></div></blockquote></div></div></div>