753 lines · cpp
1//===-- CanonicalIncludes.h - remap #include headers-------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "CanonicalIncludes.h"10#include "clang/Basic/FileEntry.h"11#include "clang/Basic/LangOptions.h"12#include "llvm/ADT/StringRef.h"13#include "llvm/Support/Path.h"14 15namespace clang {16namespace clangd {17namespace {18const std::pair<llvm::StringRef, llvm::StringRef> IncludeMappings[] = {19 {"include/__float_float.h", "<cfloat>"},20 {"include/__float_header_macro.h", "<cfloat>"},21 {"include/__float_infinity_nan.h", "<cfloat>"},22 {"include/__stdarg___gnuc_va_list.h", "<cstdarg>"},23 {"include/__stdarg___va_copy.h", "<cstdarg>"},24 {"include/__stdarg_header_macro.h", "<cstdarg>"},25 {"include/__stdarg_va_arg.h", "<cstdarg>"},26 {"include/__stdarg_va_copy.h", "<cstdarg>"},27 {"include/__stdarg_va_list.h", "<cstdarg>"},28 {"include/__stddef_header_macro.h", "<cstddef>"},29 {"include/__stddef_max_align_t.h", "<cstddef>"},30 {"include/__stddef_null.h", "<cstddef>"},31 {"include/__stddef_nullptr_t.h", "<cstddef>"},32 {"include/__stddef_offsetof.h", "<cstddef>"},33 {"include/__stddef_ptrdiff_t.h", "<cstddef>"},34 {"include/__stddef_rsize_t.h", "<cstddef>"},35 {"include/__stddef_size_t.h", "<cstddef>"},36 {"include/__stddef_unreachable.h", "<cstddef>"},37 {"include/__stddef_wchar_t.h", "<cstddef>"},38 {"include/__stddef_wint_t.h", "<cstddef>"},39 {"include/__wmmintrin_aes.h", "<wmmintrin.h>"},40 {"include/__wmmintrin_pclmul.h", "<wmmintrin.h>"},41 {"include/adxintrin.h", "<immintrin.h>"},42 {"include/ammintrin.h", "<ammintrin.h>"},43 {"include/avx2intrin.h", "<immintrin.h>"},44 {"include/avx512bwintrin.h", "<immintrin.h>"},45 {"include/avx512cdintrin.h", "<immintrin.h>"},46 {"include/avx512dqintrin.h", "<immintrin.h>"},47 {"include/avx512erintrin.h", "<immintrin.h>"},48 {"include/avx512fintrin.h", "<immintrin.h>"},49 {"include/avx512ifmaintrin.h", "<immintrin.h>"},50 {"include/avx512ifmavlintrin.h", "<immintrin.h>"},51 {"include/avx512pfintrin.h", "<immintrin.h>"},52 {"include/avx512vbmiintrin.h", "<immintrin.h>"},53 {"include/avx512vbmivlintrin.h", "<immintrin.h>"},54 {"include/avx512vlbwintrin.h", "<immintrin.h>"},55 {"include/avx512vlcdintrin.h", "<immintrin.h>"},56 {"include/avx512vldqintrin.h", "<immintrin.h>"},57 {"include/avx512vlintrin.h", "<immintrin.h>"},58 {"include/avxintrin.h", "<immintrin.h>"},59 {"include/bmi2intrin.h", "<x86intrin.h>"},60 {"include/bmiintrin.h", "<x86intrin.h>"},61 {"include/emmintrin.h", "<emmintrin.h>"},62 {"include/f16cintrin.h", "<emmintrin.h>"},63 {"include/float.h", "<cfloat>"},64 {"include/fma4intrin.h", "<x86intrin.h>"},65 {"include/fmaintrin.h", "<immintrin.h>"},66 {"include/fxsrintrin.h", "<immintrin.h>"},67 {"include/ia32intrin.h", "<x86intrin.h>"},68 {"include/immintrin.h", "<immintrin.h>"},69 {"include/inttypes.h", "<cinttypes>"},70 {"include/limits.h", "<climits>"},71 {"include/lzcntintrin.h", "<x86intrin.h>"},72 {"include/mm3dnow.h", "<mm3dnow.h>"},73 {"include/mm_malloc.h", "<mm_malloc.h>"},74 {"include/mmintrin.h", "<mmintrin>"},75 {"include/mwaitxintrin.h", "<x86intrin.h>"},76 {"include/pkuintrin.h", "<immintrin.h>"},77 {"include/pmmintrin.h", "<pmmintrin.h>"},78 {"include/popcntintrin.h", "<popcntintrin.h>"},79 {"include/prfchwintrin.h", "<x86intrin.h>"},80 {"include/rdseedintrin.h", "<x86intrin.h>"},81 {"include/rtmintrin.h", "<immintrin.h>"},82 {"include/shaintrin.h", "<immintrin.h>"},83 {"include/smmintrin.h", "<smmintrin.h>"},84 {"include/stdalign.h", "<cstdalign>"},85 {"include/stdarg.h", "<cstdarg>"},86 {"include/stdbool.h", "<cstdbool>"},87 {"include/stddef.h", "<cstddef>"},88 {"include/stdint.h", "<cstdint>"},89 {"include/tbmintrin.h", "<x86intrin.h>"},90 {"include/tmmintrin.h", "<tmmintrin.h>"},91 {"include/wmmintrin.h", "<wmmintrin.h>"},92 {"include/x86intrin.h", "<x86intrin.h>"},93 {"include/xmmintrin.h", "<xmmintrin.h>"},94 {"include/xopintrin.h", "<x86intrin.h>"},95 {"include/xsavecintrin.h", "<immintrin.h>"},96 {"include/xsaveintrin.h", "<immintrin.h>"},97 {"include/xsaveoptintrin.h", "<immintrin.h>"},98 {"include/xsavesintrin.h", "<immintrin.h>"},99 {"include/xtestintrin.h", "<immintrin.h>"},100 {"include/_G_config.h", "<cstdio>"},101 {"include/assert.h", "<cassert>"},102 {"algorithm", "<algorithm>"},103 {"valarray", "<valarray>"},104 {"array", "<array>"},105 {"atomic", "<atomic>"},106 {"backward/auto_ptr.h", "<memory>"},107 {"backward/binders.h", "<string>"},108 {"bits/algorithmfwd.h", "<algorithm>"},109 {"bits/alloc_traits.h", "<memory>"},110 {"bits/allocated_ptr.h", "<memory>"},111 {"bits/allocator.h", "<allocator>"},112 {"bits/atomic_base.h", "<atomic>"},113 {"bits/atomic_lockfree_defines.h", "<exception>"},114 {"bits/atomic_futex.h", "<atomic>"},115 {"bits/basic_ios.h", "<ios>"},116 {"bits/basic_ios.tcc", "<ios>"},117 {"bits/basic_string.h", "<string>"},118 {"bits/basic_string.tcc", "<string>"},119 {"bits/char_traits.h", "<string>"},120 {"bits/codecvt.h", "<locale>"},121 {"bits/concept_check.h", "<numeric>"},122 {"bits/cpp_type_traits.h", "<cmath>"},123 {"bits/cxxabi_forced.h", "<cxxabi.h>"},124 {"bits/deque.tcc", "<deque>"},125 {"bits/exception.h", "<exception>"},126 {"bits/exception_defines.h", "<exception>"},127 {"bits/exception_ptr.h", "<exception>"},128 {"bits/forward_list.h", "<forward_list>"},129 {"bits/forward_list.tcc", "<forward_list>"},130 {"bits/fstream.tcc", "<fstream>"},131 {"bits/functexcept.h", "<list>"},132 {"bits/functional_hash.h", "<functional>"},133 {"bits/gslice.h", "<valarray>"},134 {"bits/gslice_array.h", "<valarray>"},135 {"bits/hash_bytes.h", "<typeinfo>"},136 {"bits/hashtable.h", "<unordered_set>"},137 {"bits/hashtable_policy.h", "<unordered_set>"},138 {"bits/indirect_array.h", "<valarray>"},139 {"bits/invoke.h", "<functional>"},140 {"bits/ios_base.h", "<ios>"},141 {"bits/istream.tcc", "<istream>"},142 {"bits/list.tcc", "<list>"},143 {"bits/locale_classes.h", "<locale>"},144 {"bits/locale_classes.tcc", "<locale>"},145 {"bits/locale_conv.h", "<locale>"},146 {"bits/locale_facets.h", "<locale>"},147 {"bits/locale_facets.tcc", "<locale>"},148 {"bits/locale_facets_nonio.h", "<locale>"},149 {"bits/locale_facets_nonio.tcc", "<locale>"},150 {"bits/localefwd.h", "<locale>"},151 {"bits/mask_array.h", "<valarray>"},152 {"bits/memoryfwd.h", "<memory>"},153 {"bits/move.h", "<utility>"},154 {"bits/nested_exception.h", "<exception>"},155 {"bits/ostream.tcc", "<ostream>"},156 {"bits/ostream_insert.h", "<ostream>"},157 {"bits/parse_numbers.h", "<chrono>"},158 {"bits/postypes.h", "<ios>"},159 {"bits/predefined_ops.h", "<algorithm>"},160 {"bits/ptr_traits.h", "<memory>"},161 {"bits/quoted_string.h", "<iomanip>"},162 {"bits/random.h", "<random>"},163 {"bits/random.tcc", "<random>"},164 {"bits/range_access.h", "<iterator>"},165 {"bits/refwrap.h", "<functional>"},166 {"bits/regex.h", "<regex>"},167 {"bits/regex_automaton.h", "<regex>"},168 {"bits/regex_compiler.h", "<regex>"},169 {"bits/regex_constants.h", "<regex>"},170 {"bits/regex_cursor.h", "<regex>"},171 {"bits/regex_error.h", "<regex>"},172 {"bits/regex_executor.h", "<regex>"},173 {"bits/regex_grep_matcher.h", "<regex>"},174 {"bits/regex_grep_matcher.tcc", "<regex>"},175 {"bits/regex_nfa.h", "<regex>"},176 {"bits/regex_scanner.h", "<regex>"},177 {"bits/shared_ptr.h", "<memory>"},178 {"bits/shared_ptr_base.h", "<memory>"},179 {"bits/shared_ptr_atomic.h", "<atomic>"},180 {"bits/slice_array.h", "<valarray>"},181 {"bits/sstream.tcc", "<sstream>"},182 {"bits/std_abs.h", "<cmath>"},183 {"bits/std_function.h", "<functional>"},184 {"bits/std_mutex.h", "<mutex>"},185 {"bits/stl_algo.h", "<algorithm>"},186 {"bits/stl_algobase.h", "<algorithm>"},187 {"bits/stl_bvector.h", "<vector>"},188 {"bits/stl_construct.h", "<deque>"},189 {"bits/stl_deque.h", "<deque>"},190 {"bits/stl_function.h", "<functional>"},191 {"bits/stl_heap.h", "<heap>"},192 {"bits/stl_iterator.h", "<iterator>"},193 {"bits/stl_iterator_base_funcs.h", "<iterator>"},194 {"bits/stl_iterator_base_types.h", "<iterator>"},195 {"bits/stl_list.h", "<list>"},196 {"bits/stl_map.h", "<map>"},197 {"bits/stl_multimap.h", "<map>"},198 {"bits/stl_multiset.h", "<set>"},199 {"bits/stl_numeric.h", "<numeric>"},200 {"bits/stl_pair.h", "<utility>"},201 {"bits/stl_queue.h", "<queue>"},202 {"bits/stl_raw_storage_iter.h", "<memory>"},203 {"bits/stl_relops.h", "<utility>"},204 {"bits/stl_set.h", "<set>"},205 {"bits/stl_stack.h", "<stack>"},206 {"bits/stl_tempbuf.h", "<memory>"},207 {"bits/stl_tree.h", "<map>"},208 {"bits/stl_uninitialized.h", "<memory>"},209 {"bits/stl_vector.h", "<vector>"},210 {"bits/stream_iterator.h", "<iterator>"},211 {"bits/streambuf.tcc", "<streambuf>"},212 {"bits/streambuf_iterator.h", "<iterator>"},213 {"bits/stringfwd.h", "<string>"},214 {"bits/uniform_int_dist.h", "<random>"},215 {"bits/unique_ptr.h", "<memory>"},216 {"bits/unordered_map.h", "<unordered_map>"},217 {"bits/unordered_set.h", "<unordered_set>"},218 {"bits/uses_allocator.h", "<memory>"},219 {"bits/valarray_after.h", "<valarray>"},220 {"bits/valarray_array.h", "<valarray>"},221 {"bits/valarray_array.tcc", "<valarray>"},222 {"bits/valarray_before.h", "<valarray>"},223 {"bits/vector.tcc", "<vector>"},224 {"bitset", "<bitset>"},225 {"ccomplex", "<ccomplex>"},226 {"cctype", "<cctype>"},227 {"cerrno", "<cerrno>"},228 {"cfenv", "<cfenv>"},229 {"cfloat", "<cfloat>"},230 {"chrono", "<chrono>"},231 {"cinttypes", "<cinttypes>"},232 {"climits", "<climits>"},233 {"clocale", "<clocale>"},234 {"cmath", "<cmath>"},235 {"complex", "<complex>"},236 {"complex.h", "<complex.h>"},237 {"condition_variable", "<condition_variable>"},238 {"csetjmp", "<csetjmp>"},239 {"csignal", "<csignal>"},240 {"cstdalign", "<cstdalign>"},241 {"cstdarg", "<cstdarg>"},242 {"cstdbool", "<cstdbool>"},243 {"cstdint", "<cstdint>"},244 {"cstdio", "<cstdio>"},245 {"cstdlib", "<cstdlib>"},246 {"cstring", "<cstring>"},247 {"ctgmath", "<ctgmath>"},248 {"ctime", "<ctime>"},249 {"cwchar", "<cwchar>"},250 {"cwctype", "<cwctype>"},251 {"cxxabi.h", "<cxxabi.h>"},252 {"debug/debug.h", "<numeric>"},253 {"debug/map.h", "<map>"},254 {"debug/multimap.h", "<multimap>"},255 {"debug/multiset.h", "<multiset>"},256 {"debug/set.h", "<set>"},257 {"deque", "<deque>"},258 {"exception", "<exception>"},259 {"ext/alloc_traits.h", "<deque>"},260 {"ext/atomicity.h", "<memory>"},261 {"ext/concurrence.h", "<memory>"},262 {"ext/new_allocator.h", "<string>"},263 {"ext/numeric_traits.h", "<list>"},264 {"ext/string_conversions.h", "<string>"},265 {"ext/type_traits.h", "<cmath>"},266 {"fenv.h", "<fenv.h>"},267 {"forward_list", "<forward_list>"},268 {"fstream", "<fstream>"},269 {"functional", "<functional>"},270 {"future", "<future>"},271 {"initializer_list", "<initializer_list>"},272 {"iomanip", "<iomanip>"},273 {"ios", "<ios>"},274 {"iosfwd", "<iosfwd>"},275 {"iostream", "<iostream>"},276 {"istream", "<istream>"},277 {"iterator", "<iterator>"},278 {"limits", "<limits>"},279 {"list", "<list>"},280 {"locale", "<locale>"},281 {"map", "<map>"},282 {"memory", "<memory>"},283 {"shared_mutex", "<shared_mutex>"},284 {"mutex", "<mutex>"},285 {"new", "<new>"},286 {"numeric", "<numeric>"},287 {"ostream", "<ostream>"},288 {"queue", "<queue>"},289 {"random", "<random>"},290 {"ratio", "<ratio>"},291 {"regex", "<regex>"},292 {"scoped_allocator", "<scoped_allocator>"},293 {"set", "<set>"},294 {"sstream", "<sstream>"},295 {"stack", "<stack>"},296 {"stdexcept", "<stdexcept>"},297 {"streambuf", "<streambuf>"},298 {"string", "<string>"},299 {"system_error", "<system_error>"},300 {"tgmath.h", "<tgmath.h>"},301 {"thread", "<thread>"},302 {"tuple", "<tuple>"},303 {"type_traits", "<type_traits>"},304 {"typeindex", "<typeindex>"},305 {"typeinfo", "<typeinfo>"},306 {"unordered_map", "<unordered_map>"},307 {"unordered_set", "<unordered_set>"},308 {"utility", "<utility>"},309 {"vector", "<vector>"},310 {"include/complex.h", "<complex.h>"},311 {"include/ctype.h", "<cctype>"},312 {"include/errno.h", "<cerrno>"},313 {"include/fenv.h", "<fenv.h>"},314 {"include/libio.h", "<cstdio>"},315 {"include/locale.h", "<clocale>"},316 {"include/math.h", "<cmath>"},317 {"include/setjmp.h", "<csetjmp>"},318 {"include/signal.h", "<csignal>"},319 {"include/stdio.h", "<cstdio>"},320 {"include/stdlib.h", "<cstdlib>"},321 {"include/string.h", "<cstring>"},322 {"include/time.h", "<ctime>"},323 {"include/wchar.h", "<cwchar>"},324 {"include/wctype.h", "<cwctype>"},325 {"bits/cmathcalls.h", "<complex.h>"},326 {"bits/errno.h", "<cerrno>"},327 {"bits/fenv.h", "<fenv.h>"},328 {"bits/huge_val.h", "<cmath>"},329 {"bits/huge_valf.h", "<cmath>"},330 {"bits/huge_vall.h", "<cmath>"},331 {"bits/inf.h", "<cmath>"},332 {"bits/local_lim.h", "<climits>"},333 {"bits/locale.h", "<clocale>"},334 {"bits/mathcalls.h", "<math.h>"},335 {"bits/mathdef.h", "<cmath>"},336 {"bits/nan.h", "<cmath>"},337 {"bits/posix1_lim.h", "<climits>"},338 {"bits/posix2_lim.h", "<climits>"},339 {"bits/setjmp.h", "<csetjmp>"},340 {"bits/sigaction.h", "<csignal>"},341 {"bits/sigcontext.h", "<csignal>"},342 {"bits/siginfo.h", "<csignal>"},343 {"bits/signum.h", "<csignal>"},344 {"bits/sigset.h", "<csignal>"},345 {"bits/sigstack.h", "<csignal>"},346 {"bits/stdint-intn.h", "<cstdint>"},347 {"bits/stdint-uintn.h", "<cstdint>"},348 {"bits/stdio_lim.h", "<cstdio>"},349 {"bits/sys_errlist.h", "<cstdio>"},350 {"bits/time.h", "<ctime>"},351 {"bits/timex.h", "<ctime>"},352 {"bits/typesizes.h", "<cstdio>"},353 {"bits/wchar.h", "<cwchar>"},354 {"bits/wordsize.h", "<csetjmp>"},355 {"bits/xopen_lim.h", "<climits>"},356 {"include/xlocale.h", "<cstring>"},357 {"bits/atomic_word.h", "<memory>"},358 {"bits/basic_file.h", "<fstream>"},359 {"bits/c\\+\\+allocator.h", "<string>"},360 {"bits/c\\+\\+config.h", "<cstddef>"},361 {"bits/c\\+\\+io.h", "<ios>"},362 {"bits/c\\+\\+locale.h", "<locale>"},363 {"bits/cpu_defines.h", "<iosfwd>"},364 {"bits/ctype_base.h", "<locale>"},365 {"bits/cxxabi_tweaks.h", "<cxxabi.h>"},366 {"bits/error_constants.h", "<system_error>"},367 {"bits/gthr-default.h", "<memory>"},368 {"bits/gthr.h", "<memory>"},369 {"bits/opt_random.h", "<random>"},370 {"bits/os_defines.h", "<iosfwd>"},371 // GNU C headers372 {"include/aio.h", "<aio.h>"},373 {"include/aliases.h", "<aliases.h>"},374 {"include/alloca.h", "<alloca.h>"},375 {"include/ar.h", "<ar.h>"},376 {"include/argp.h", "<argp.h>"},377 {"include/argz.h", "<argz.h>"},378 {"include/arpa/nameser.h", "<resolv.h>"},379 {"include/arpa/nameser_compat.h", "<resolv.h>"},380 {"include/byteswap.h", "<byteswap.h>"},381 {"include/cpio.h", "<cpio.h>"},382 {"include/crypt.h", "<crypt.h>"},383 {"include/dirent.h", "<dirent.h>"},384 {"include/dlfcn.h", "<dlfcn.h>"},385 {"include/elf.h", "<elf.h>"},386 {"include/endian.h", "<endian.h>"},387 {"include/envz.h", "<envz.h>"},388 {"include/err.h", "<err.h>"},389 {"include/error.h", "<error.h>"},390 {"include/execinfo.h", "<execinfo.h>"},391 {"include/fcntl.h", "<fcntl.h>"},392 {"include/features.h", "<features.h>"},393 {"include/fmtmsg.h", "<fmtmsg.h>"},394 {"include/fnmatch.h", "<fnmatch.h>"},395 {"include/fstab.h", "<fstab.h>"},396 {"include/fts.h", "<fts.h>"},397 {"include/ftw.h", "<ftw.h>"},398 {"include/gconv.h", "<gconv.h>"},399 {"include/getopt.h", "<getopt.h>"},400 {"include/glob.h", "<glob.h>"},401 {"include/grp.h", "<grp.h>"},402 {"include/gshadow.h", "<gshadow.h>"},403 {"include/iconv.h", "<iconv.h>"},404 {"include/ifaddrs.h", "<ifaddrs.h>"},405 {"include/kdb.h", "<kdb.h>"},406 {"include/langinfo.h", "<langinfo.h>"},407 {"include/libgen.h", "<libgen.h>"},408 {"include/libintl.h", "<libintl.h>"},409 {"include/link.h", "<link.h>"},410 {"include/malloc.h", "<malloc.h>"},411 {"include/mcheck.h", "<mcheck.h>"},412 {"include/memory.h", "<memory.h>"},413 {"include/mntent.h", "<mntent.h>"},414 {"include/monetary.h", "<monetary.h>"},415 {"include/mqueue.h", "<mqueue.h>"},416 {"include/netdb.h", "<netdb.h>"},417 {"include/netinet/in.h", "<netinet/in.h>"},418 {"include/nl_types.h", "<nl_types.h>"},419 {"include/nss.h", "<nss.h>"},420 {"include/obstack.h", "<obstack.h>"},421 {"include/panel.h", "<panel.h>"},422 {"include/paths.h", "<paths.h>"},423 {"include/printf.h", "<printf.h>"},424 {"include/profile.h", "<profile.h>"},425 {"include/pthread.h", "<pthread.h>"},426 {"include/pty.h", "<pty.h>"},427 {"include/pwd.h", "<pwd.h>"},428 {"include/re_comp.h", "<re_comp.h>"},429 {"include/regex.h", "<regex.h>"},430 {"include/regexp.h", "<regexp.h>"},431 {"include/resolv.h", "<resolv.h>"},432 {"include/rpc/netdb.h", "<netdb.h>"},433 {"include/sched.h", "<sched.h>"},434 {"include/search.h", "<search.h>"},435 {"include/semaphore.h", "<semaphore.h>"},436 {"include/sgtty.h", "<sgtty.h>"},437 {"include/shadow.h", "<shadow.h>"},438 {"include/spawn.h", "<spawn.h>"},439 {"include/stab.h", "<stab.h>"},440 {"include/stdc-predef.h", "<stdc-predef.h>"},441 {"include/stdio_ext.h", "<stdio_ext.h>"},442 {"include/strings.h", "<strings.h>"},443 {"include/stropts.h", "<stropts.h>"},444 {"include/sudo_plugin.h", "<sudo_plugin.h>"},445 {"include/sysexits.h", "<sysexits.h>"},446 {"include/tar.h", "<tar.h>"},447 {"include/tcpd.h", "<tcpd.h>"},448 {"include/term.h", "<term.h>"},449 {"include/term_entry.h", "<term_entry.h>"},450 {"include/termcap.h", "<termcap.h>"},451 {"include/termios.h", "<termios.h>"},452 {"include/thread_db.h", "<thread_db.h>"},453 {"include/tic.h", "<tic.h>"},454 {"include/ttyent.h", "<ttyent.h>"},455 {"include/uchar.h", "<uchar.h>"},456 {"include/ucontext.h", "<ucontext.h>"},457 {"include/ulimit.h", "<ulimit.h>"},458 {"include/unctrl.h", "<unctrl.h>"},459 {"include/unistd.h", "<unistd.h>"},460 {"include/utime.h", "<utime.h>"},461 {"include/utmp.h", "<utmp.h>"},462 {"include/utmpx.h", "<utmpx.h>"},463 {"include/values.h", "<values.h>"},464 {"include/wordexp.h", "<wordexp.h>"},465 {"fpu_control.h", "<fpu_control.h>"},466 {"ieee754.h", "<ieee754.h>"},467 {"gnu/lib-names.h", "<gnu/lib-names.h>"},468 {"gnu/libc-version.h", "<gnu/libc-version.h>"},469 {"gnu/option-groups.h", "<gnu/option-groups.h>"},470 {"gnu/stubs-32.h", "<gnu/stubs-32.h>"},471 {"gnu/stubs-64.h", "<gnu/stubs-64.h>"},472 {"gnu/stubs-x32.h", "<gnu/stubs-x32.h>"},473 {"include/rpc/auth_des.h", "<rpc/auth_des.h>"},474 {"include/rpc/rpc_msg.h", "<rpc/rpc_msg.h>"},475 {"include/rpc/pmap_clnt.h", "<rpc/pmap_clnt.h>"},476 {"include/rpc/rpc.h", "<rpc/rpc.h>"},477 {"include/rpc/types.h", "<rpc/types.h>"},478 {"include/rpc/auth_unix.h", "<rpc/auth_unix.h>"},479 {"include/rpc/key_prot.h", "<rpc/key_prot.h>"},480 {"include/rpc/pmap_prot.h", "<rpc/pmap_prot.h>"},481 {"include/rpc/auth.h", "<rpc/auth.h>"},482 {"include/rpc/svc_auth.h", "<rpc/svc_auth.h>"},483 {"include/rpc/xdr.h", "<rpc/xdr.h>"},484 {"include/rpc/pmap_rmt.h", "<rpc/pmap_rmt.h>"},485 {"include/rpc/des_crypt.h", "<rpc/des_crypt.h>"},486 {"include/rpc/svc.h", "<rpc/svc.h>"},487 {"include/rpc/rpc_des.h", "<rpc/rpc_des.h>"},488 {"include/rpc/clnt.h", "<rpc/clnt.h>"},489 {"include/scsi/scsi.h", "<scsi/scsi.h>"},490 {"include/scsi/sg.h", "<scsi/sg.h>"},491 {"include/scsi/scsi_ioctl.h", "<scsi/scsi_ioctl>"},492 {"include/netrose/rose.h", "<netrose/rose.h>"},493 {"include/nfs/nfs.h", "<nfs/nfs.h>"},494 {"include/netatalk/at.h", "<netatalk/at.h>"},495 {"include/netinet/ether.h", "<netinet/ether.h>"},496 {"include/netinet/icmp6.h", "<netinet/icmp6.h>"},497 {"include/netinet/if_ether.h", "<netinet/if_ether.h>"},498 {"include/netinet/if_fddi.h", "<netinet/if_fddi.h>"},499 {"include/netinet/if_tr.h", "<netinet/if_tr.h>"},500 {"include/netinet/igmp.h", "<netinet/igmp.h>"},501 {"include/netinet/in_systm.h", "<netinet/in_systm.h>"},502 {"include/netinet/ip.h", "<netinet/ip.h>"},503 {"include/netinet/ip6.h", "<netinet/ip6.h>"},504 {"include/netinet/ip_icmp.h", "<netinet/ip_icmp.h>"},505 {"include/netinet/tcp.h", "<netinet/tcp.h>"},506 {"include/netinet/udp.h", "<netinet/udp.h>"},507 {"include/netrom/netrom.h", "<netrom/netrom.h>"},508 {"include/protocols/routed.h", "<protocols/routed.h>"},509 {"include/protocols/rwhod.h", "<protocols/rwhod.h>"},510 {"include/protocols/talkd.h", "<protocols/talkd.h>"},511 {"include/protocols/timed.h", "<protocols/timed.h>"},512 {"include/rpcsvc/klm_prot.x", "<rpcsvc/klm_prot.x>"},513 {"include/rpcsvc/rstat.h", "<rpcsvc/rstat.h>"},514 {"include/rpcsvc/spray.x", "<rpcsvc/spray.x>"},515 {"include/rpcsvc/nlm_prot.x", "<rpcsvc/nlm_prot.x>"},516 {"include/rpcsvc/nis_callback.x", "<rpcsvc/nis_callback.x>"},517 {"include/rpcsvc/yp.h", "<rpcsvc/yp.h>"},518 {"include/rpcsvc/yp.x", "<rpcsvc/yp.x>"},519 {"include/rpcsvc/nfs_prot.h", "<rpcsvc/nfs_prot.h>"},520 {"include/rpcsvc/rex.h", "<rpcsvc/rex.h>"},521 {"include/rpcsvc/yppasswd.h", "<rpcsvc/yppasswd.h>"},522 {"include/rpcsvc/rex.x", "<rpcsvc/rex.x>"},523 {"include/rpcsvc/nis_tags.h", "<rpcsvc/nis_tags.h>"},524 {"include/rpcsvc/nis_callback.h", "<rpcsvc/nis_callback.h>"},525 {"include/rpcsvc/nfs_prot.x", "<rpcsvc/nfs_prot.x>"},526 {"include/rpcsvc/bootparam_prot.x", "<rpcsvc/bootparam_prot.x>"},527 {"include/rpcsvc/rusers.x", "<rpcsvc/rusers.x>"},528 {"include/rpcsvc/rquota.x", "<rpcsvc/rquota.x>"},529 {"include/rpcsvc/nis.h", "<rpcsvc/nis.h>"},530 {"include/rpcsvc/nislib.h", "<rpcsvc/nislib.h>"},531 {"include/rpcsvc/ypupd.h", "<rpcsvc/ypupd.h>"},532 {"include/rpcsvc/bootparam.h", "<rpcsvc/bootparam.h>"},533 {"include/rpcsvc/spray.h", "<rpcsvc/spray.h>"},534 {"include/rpcsvc/key_prot.h", "<rpcsvc/key_prot.h>"},535 {"include/rpcsvc/klm_prot.h", "<rpcsvc/klm_prot.h>"},536 {"include/rpcsvc/sm_inter.h", "<rpcsvc/sm_inter.h>"},537 {"include/rpcsvc/nlm_prot.h", "<rpcsvc/nlm_prot.h>"},538 {"include/rpcsvc/yp_prot.h", "<rpcsvc/yp_prot.h>"},539 {"include/rpcsvc/ypclnt.h", "<rpcsvc/ypclnt.h>"},540 {"include/rpcsvc/rstat.x", "<rpcsvc/rstat.x>"},541 {"include/rpcsvc/rusers.h", "<rpcsvc/rusers.h>"},542 {"include/rpcsvc/key_prot.x", "<rpcsvc/key_prot.x>"},543 {"include/rpcsvc/sm_inter.x", "<rpcsvc/sm_inter.x>"},544 {"include/rpcsvc/rquota.h", "<rpcsvc/rquota.h>"},545 {"include/rpcsvc/nis.x", "<rpcsvc/nis.x>"},546 {"include/rpcsvc/bootparam_prot.h", "<rpcsvc/bootparam_prot.h>"},547 {"include/rpcsvc/mount.h", "<rpcsvc/mount.h>"},548 {"include/rpcsvc/mount.x", "<rpcsvc/mount.x>"},549 {"include/rpcsvc/nis_object.x", "<rpcsvc/nis_object.x>"},550 {"include/rpcsvc/yppasswd.x", "<rpcsvc/yppasswd.x>"},551 {"sys/acct.h", "<sys/acct.h>"},552 {"sys/auxv.h", "<sys/auxv.h>"},553 {"sys/cdefs.h", "<sys/cdefs.h>"},554 {"sys/debugreg.h", "<sys/debugreg.h>"},555 {"sys/dir.h", "<sys/dir.h>"},556 {"sys/elf.h", "<sys/elf.h>"},557 {"sys/epoll.h", "<sys/epoll.h>"},558 {"sys/eventfd.h", "<sys/eventfd.h>"},559 {"sys/fanotify.h", "<sys/fanotify.h>"},560 {"sys/file.h", "<sys/file.h>"},561 {"sys/fsuid.h", "<sys/fsuid.h>"},562 {"sys/gmon.h", "<sys/gmon.h>"},563 {"sys/gmon_out.h", "<sys/gmon_out.h>"},564 {"sys/inotify.h", "<sys/inotify.h>"},565 {"sys/io.h", "<sys/io.h>"},566 {"sys/ioctl.h", "<sys/ioctl.h>"},567 {"sys/ipc.h", "<sys/ipc.h>"},568 {"sys/kd.h", "<sys/kd.h>"},569 {"sys/kdaemon.h", "<sys/kdaemon.h>"},570 {"sys/klog.h", "<sys/klog.h>"},571 {"sys/mman.h", "<sys/mman.h>"},572 {"sys/mount.h", "<sys/mount.h>"},573 {"sys/msg.h", "<sys/msg.h>"},574 {"sys/mtio.h", "<sys/mtio.h>"},575 {"sys/param.h", "<sys/param.h>"},576 {"sys/pci.h", "<sys/pci.h>"},577 {"sys/perm.h", "<sys/perm.h>"},578 {"sys/personality.h", "<sys/personality.h>"},579 {"sys/poll.h", "<sys/poll.h>"},580 {"sys/prctl.h", "<sys/prctl.h>"},581 {"sys/procfs.h", "<sys/procfs.h>"},582 {"sys/profil.h", "<sys/profil.h>"},583 {"sys/ptrace.h", "<sys/ptrace.h>"},584 {"sys/queue.h", "<sys/queue.h>"},585 {"sys/quota.h", "<sys/quota.h>"},586 {"sys/raw.h", "<sys/raw.h>"},587 {"sys/reboot.h", "<sys/reboot.h>"},588 {"sys/reg.h", "<sys/reg.h>"},589 {"sys/resource.h", "<sys/resource.h>"},590 {"sys/select.h", "<sys/select.h>"},591 {"sys/sem.h", "<sys/sem.h>"},592 {"sys/sendfile.h", "<sys/sendfile.h>"},593 {"sys/shm.h", "<sys/shm.h>"},594 {"sys/signalfd.h", "<sys/signalfd.h>"},595 {"sys/socket.h", "<sys/socket.h>"},596 {"sys/stat.h", "<sys/stat.h>"},597 {"sys/statfs.h", "<sys/statfs.h>"},598 {"sys/statvfs.h", "<sys/statvfs.h>"},599 {"sys/swap.h", "<sys/swap.h>"},600 {"sys/syscall.h", "<sys/syscall.h>"},601 {"sys/sysctl.h", "<sys/sysctl.h>"},602 {"sys/sysinfo.h", "<sys/sysinfo.h>"},603 {"sys/syslog.h", "<sys/syslog.h>"},604 {"sys/sysmacros.h", "<sys/sysmacros.h>"},605 {"sys/termios.h", "<sys/termios.h>"},606 {"sys/time.h", "<sys/select.h>"},607 {"sys/timeb.h", "<sys/timeb.h>"},608 {"sys/timerfd.h", "<sys/timerfd.h>"},609 {"sys/times.h", "<sys/times.h>"},610 {"sys/timex.h", "<sys/timex.h>"},611 {"sys/ttychars.h", "<sys/ttychars.h>"},612 {"sys/ttydefaults.h", "<sys/ttydefaults.h>"},613 {"sys/types.h", "<sys/types.h>"},614 {"sys/ucontext.h", "<sys/ucontext.h>"},615 {"sys/uio.h", "<sys/uio.h>"},616 {"sys/un.h", "<sys/un.h>"},617 {"sys/user.h", "<sys/user.h>"},618 {"sys/ustat.h", "<sys/ustat.h>"},619 {"sys/utsname.h", "<sys/utsname.h>"},620 {"sys/vlimit.h", "<sys/vlimit.h>"},621 {"sys/vm86.h", "<sys/vm86.h>"},622 {"sys/vtimes.h", "<sys/vtimes.h>"},623 {"sys/wait.h", "<sys/wait.h>"},624 {"sys/xattr.h", "<sys/xattr.h>"},625 {"bits/epoll.h", "<sys/epoll.h>"},626 {"bits/eventfd.h", "<sys/eventfd.h>"},627 {"bits/getopt_core.h", "<getopt.h>"},628 {"bits/getopt_ext.h", "<getopt.h>"},629 {"bits/getopt_posix.h", "<getopt.h>"},630 {"bits/inotify.h", "<sys/inotify.h>"},631 {"bits/ipc.h", "<sys/ipc.h>"},632 {"bits/ipctypes.h", "<sys/ipc.h>"},633 {"bits/mman-linux.h", "<sys/mman.h>"},634 {"bits/mman.h", "<sys/mman.h>"},635 {"bits/msq.h", "<sys/msg.h>"},636 {"bits/resource.h", "<sys/resource.h>"},637 {"bits/sem.h", "<sys/sem.h>"},638 {"bits/shm.h", "<sys/shm.h>"},639 {"bits/signalfd.h", "<sys/signalfd.h>"},640 {"bits/statfs.h", "<sys/statfs.h>"},641 {"bits/statvfs.h", "<sys/statvfs.h>"},642 {"bits/timerfd.h", "<sys/timerfd.h>"},643 {"bits/utsname.h", "<sys/utsname.h>"},644 {"bits/auxv.h", "<sys/auxv.h>"},645 {"bits/byteswap-16.h", "<byteswap.h>"},646 {"bits/byteswap.h", "<byteswap.h>"},647 {"bits/confname.h", "<unistd.h>"},648 {"bits/dirent.h", "<dirent.h>"},649 {"bits/dlfcn.h", "<dlfcn.h>"},650 {"bits/elfclass.h", "<link.h>"},651 {"bits/endian.h", "<endian.h>"},652 {"bits/environments.h", "<unistd.h>"},653 {"bits/fcntl-linux.h", "<fcntl.h>"},654 {"bits/fcntl.h", "<fcntl.h>"},655 {"bits/in.h", "<netinet/in.h>"},656 {"bits/ioctl-types.h", "<sys/ioctl.h>"},657 {"bits/ioctls.h", "<sys/ioctl.h>"},658 {"bits/link.h", "<link.h>"},659 {"bits/mqueue.h", "<mqueue.h>"},660 {"bits/netdb.h", "<netdb.h>"},661 {"bits/param.h", "<sys/param.h>"},662 {"bits/poll.h", "<sys/poll.h>"},663 {"bits/posix_opt.h", "<bits/posix_opt.h>"},664 {"bits/pthreadtypes.h", "<pthread.h>"},665 {"bits/sched.h", "<sched.h>"},666 {"bits/select.h", "<sys/select.h>"},667 {"bits/semaphore.h", "<semaphore.h>"},668 {"bits/sigthread.h", "<pthread.h>"},669 {"bits/sockaddr.h", "<sys/socket.h>"},670 {"bits/socket.h", "<sys/socket.h>"},671 {"bits/socket_type.h", "<sys/socket.h>"},672 {"bits/stab.def", "<stab.h>"},673 {"bits/stat.h", "<sys/stat.h>"},674 {"bits/stropts.h", "<stropts.h>"},675 {"bits/syscall.h", "<sys/syscall.h>"},676 {"bits/syslog-path.h", "<sys/syslog.h>"},677 {"bits/termios.h", "<termios.h>"},678 {"bits/types.h", "<sys/types.h>"},679 {"bits/types/siginfo_t.h", "<sys/siginfo.h>"},680 {"bits/types/struct_iovec.h", "<sys/uio.h>"},681 {"bits/types/struct_itimerspec.h", "<sys/time.h>"},682 {"bits/types/struct_rusage.h", "<sys/resource.h>"},683 {"bits/uio.h", "<sys/uio.h>"},684 {"bits/ustat.h", "<sys/ustat.h>"},685 {"bits/utmp.h", "<utmp.h>"},686 {"bits/utmpx.h", "<utmpx.h>"},687 {"bits/waitflags.h", "<sys/wait.h>"},688 {"bits/waitstatus.h", "<sys/wait.h>"},689 {"bits/xtitypes.h", "<stropts.h>"},690};691 692} // namespace693 694/// The maximum number of path components in a key from StdSuffixHeaderMapping.695/// Used to minimize the number of lookups in suffix path mappings.696constexpr int MaxSuffixComponents = 3;697 698llvm::StringRef CanonicalIncludes::mapHeader(llvm::StringRef HeaderPath) const {699 if (!StdSuffixHeaderMapping)700 return "";701 702 int Components = 1;703 704 // FIXME: check that this works on Windows and add tests.705 for (auto It = llvm::sys::path::rbegin(HeaderPath),706 End = llvm::sys::path::rend(HeaderPath);707 It != End && Components <= MaxSuffixComponents; ++It, ++Components) {708 auto SubPath = HeaderPath.substr(It->data() - HeaderPath.begin());709 auto MappingIt = StdSuffixHeaderMapping->find(SubPath);710 if (MappingIt != StdSuffixHeaderMapping->end())711 return MappingIt->second;712 }713 return "";714}715 716void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {717 // FIXME: remove the std header mapping once we support ambiguous symbols, now718 // it serves as a fallback to disambiguate:719 // - symbols with multiple headers (e.g. std::move)720 static const auto *SystemHeaderMap = [] {721 const size_t Size = sizeof(IncludeMappings) / sizeof(IncludeMappings[0]);722 auto *HeaderMap = new llvm::StringMap<llvm::StringRef>(Size);723 for (size_t I = 0; I < Size; I++) {724 auto Result = HeaderMap->insert(IncludeMappings[I]);725 (void)Result;726 727 assert(Result.second && "Duplicate in include mappings");728 }729 return HeaderMap;730 }();731 732 // Check MaxSuffixComponents constant is correct.733 assert(llvm::all_of(SystemHeaderMap->keys(), [](llvm::StringRef Path) {734 return std::distance(735 llvm::sys::path::begin(Path, llvm::sys::path::Style::posix),736 llvm::sys::path::end(Path)) <= MaxSuffixComponents;737 }));738 // ... and precise.739 assert(llvm::any_of(SystemHeaderMap->keys(), [](llvm::StringRef Path) {740 return std::distance(741 llvm::sys::path::begin(Path, llvm::sys::path::Style::posix),742 llvm::sys::path::end(Path)) == MaxSuffixComponents;743 }));744 745 // FIXME: Suffix mapping contains invalid entries for C, so only enable it for746 // CPP.747 if (Language.CPlusPlus)748 StdSuffixHeaderMapping = SystemHeaderMap;749}750 751} // namespace clangd752} // namespace clang753