diff --git a/clang-tools-extra/clangd/index/CanonicalIncludes.h b/clang-tools-extra/clangd/index/CanonicalIncludes.h --- a/clang-tools-extra/clangd/index/CanonicalIncludes.h +++ b/clang-tools-extra/clangd/index/CanonicalIncludes.h @@ -57,9 +57,6 @@ private: /// A map from full include path to a canonical path. llvm::StringMap FullPathMapping; - /// A map from a suffix (one or components of a path) to a canonical path. - /// Used only for mapping standard headers. - const llvm::StringMap *StdSuffixHeaderMapping = nullptr; /// A map from fully qualified symbol names to header names. /// Used only for mapping standard symbols. const llvm::StringMap *StdSymbolMapping = nullptr; diff --git a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp --- a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp +++ b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp @@ -24,10 +24,6 @@ FullPathMapping[Path] = std::string(CanonicalPath); } -/// The maximum number of path components in a key from StdSuffixHeaderMapping. -/// Used to minimize the number of lookups in suffix path mappings. -constexpr int MaxSuffixComponents = 3; - llvm::StringRef CanonicalIncludes::mapHeader(llvm::StringRef Header, llvm::StringRef QualifiedName) const { @@ -41,21 +37,6 @@ auto MapIt = FullPathMapping.find(Header); if (MapIt != FullPathMapping.end()) return MapIt->second; - - if (!StdSuffixHeaderMapping) - return Header; - - int Components = 1; - - // FIXME: check that this works on Windows and add tests. - for (auto It = llvm::sys::path::rbegin(Header), - End = llvm::sys::path::rend(Header); - It != End && Components <= MaxSuffixComponents; ++It, ++Components) { - auto SubPath = Header.substr(It->data() - Header.begin()); - auto MappingIt = StdSuffixHeaderMapping->find(SubPath); - if (MappingIt != StdSuffixHeaderMapping->end()) - return MappingIt->second; - } return Header; } @@ -101,681 +82,6 @@ }); StdSymbolMapping = CSymbols; } - - // FIXME: remove the std header mapping once we support ambiguous symbols, now - // it serves as a fallback to disambiguate: - // - symbols with multiple headers (e.g. std::move) - static const auto *SystemHeaderMap = new llvm::StringMap({ - {"include/__stddef_max_align_t.h", ""}, - {"include/__wmmintrin_aes.h", ""}, - {"include/__wmmintrin_pclmul.h", ""}, - {"include/adxintrin.h", ""}, - {"include/ammintrin.h", ""}, - {"include/avx2intrin.h", ""}, - {"include/avx512bwintrin.h", ""}, - {"include/avx512cdintrin.h", ""}, - {"include/avx512dqintrin.h", ""}, - {"include/avx512erintrin.h", ""}, - {"include/avx512fintrin.h", ""}, - {"include/avx512ifmaintrin.h", ""}, - {"include/avx512ifmavlintrin.h", ""}, - {"include/avx512pfintrin.h", ""}, - {"include/avx512vbmiintrin.h", ""}, - {"include/avx512vbmivlintrin.h", ""}, - {"include/avx512vlbwintrin.h", ""}, - {"include/avx512vlcdintrin.h", ""}, - {"include/avx512vldqintrin.h", ""}, - {"include/avx512vlintrin.h", ""}, - {"include/avxintrin.h", ""}, - {"include/bmi2intrin.h", ""}, - {"include/bmiintrin.h", ""}, - {"include/emmintrin.h", ""}, - {"include/f16cintrin.h", ""}, - {"include/float.h", ""}, - {"include/fma4intrin.h", ""}, - {"include/fmaintrin.h", ""}, - {"include/fxsrintrin.h", ""}, - {"include/ia32intrin.h", ""}, - {"include/immintrin.h", ""}, - {"include/inttypes.h", ""}, - {"include/limits.h", ""}, - {"include/lzcntintrin.h", ""}, - {"include/mm3dnow.h", ""}, - {"include/mm_malloc.h", ""}, - {"include/mmintrin.h", ""}, - {"include/mwaitxintrin.h", ""}, - {"include/pkuintrin.h", ""}, - {"include/pmmintrin.h", ""}, - {"include/popcntintrin.h", ""}, - {"include/prfchwintrin.h", ""}, - {"include/rdseedintrin.h", ""}, - {"include/rtmintrin.h", ""}, - {"include/shaintrin.h", ""}, - {"include/smmintrin.h", ""}, - {"include/stdalign.h", ""}, - {"include/stdarg.h", ""}, - {"include/stdbool.h", ""}, - {"include/stddef.h", ""}, - {"include/stdint.h", ""}, - {"include/tbmintrin.h", ""}, - {"include/tmmintrin.h", ""}, - {"include/wmmintrin.h", ""}, - {"include/x86intrin.h", ""}, - {"include/xmmintrin.h", ""}, - {"include/xopintrin.h", ""}, - {"include/xsavecintrin.h", ""}, - {"include/xsaveintrin.h", ""}, - {"include/xsaveoptintrin.h", ""}, - {"include/xsavesintrin.h", ""}, - {"include/xtestintrin.h", ""}, - {"include/_G_config.h", ""}, - {"include/assert.h", ""}, - {"algorithm", ""}, - {"valarray", ""}, - {"array", ""}, - {"atomic", ""}, - {"backward/auto_ptr.h", ""}, - {"backward/binders.h", ""}, - {"bits/algorithmfwd.h", ""}, - {"bits/alloc_traits.h", ""}, - {"bits/allocated_ptr.h", ""}, - {"bits/allocator.h", ""}, - {"bits/atomic_base.h", ""}, - {"bits/atomic_lockfree_defines.h", ""}, - {"bits/atomic_futex.h", ""}, - {"bits/basic_ios.h", ""}, - {"bits/basic_ios.tcc", ""}, - {"bits/basic_string.h", ""}, - {"bits/basic_string.tcc", ""}, - {"bits/char_traits.h", ""}, - {"bits/codecvt.h", ""}, - {"bits/concept_check.h", ""}, - {"bits/cpp_type_traits.h", ""}, - {"bits/cxxabi_forced.h", ""}, - {"bits/deque.tcc", ""}, - {"bits/exception.h", ""}, - {"bits/exception_defines.h", ""}, - {"bits/exception_ptr.h", ""}, - {"bits/forward_list.h", ""}, - {"bits/forward_list.tcc", ""}, - {"bits/fstream.tcc", ""}, - {"bits/functexcept.h", ""}, - {"bits/functional_hash.h", ""}, - {"bits/gslice.h", ""}, - {"bits/gslice_array.h", ""}, - {"bits/hash_bytes.h", ""}, - {"bits/hashtable.h", ""}, - {"bits/hashtable_policy.h", ""}, - {"bits/indirect_array.h", ""}, - {"bits/invoke.h", ""}, - {"bits/ios_base.h", ""}, - {"bits/istream.tcc", ""}, - {"bits/list.tcc", ""}, - {"bits/locale_classes.h", ""}, - {"bits/locale_classes.tcc", ""}, - {"bits/locale_conv.h", ""}, - {"bits/locale_facets.h", ""}, - {"bits/locale_facets.tcc", ""}, - {"bits/locale_facets_nonio.h", ""}, - {"bits/locale_facets_nonio.tcc", ""}, - {"bits/localefwd.h", ""}, - {"bits/mask_array.h", ""}, - {"bits/memoryfwd.h", ""}, - {"bits/move.h", ""}, - {"bits/nested_exception.h", ""}, - {"bits/ostream.tcc", ""}, - {"bits/ostream_insert.h", ""}, - {"bits/parse_numbers.h", ""}, - {"bits/postypes.h", ""}, - {"bits/predefined_ops.h", ""}, - {"bits/ptr_traits.h", ""}, - {"bits/quoted_string.h", ""}, - {"bits/random.h", ""}, - {"bits/random.tcc", ""}, - {"bits/range_access.h", ""}, - {"bits/refwrap.h", ""}, - {"bits/regex.h", ""}, - {"bits/regex_automaton.h", ""}, - {"bits/regex_compiler.h", ""}, - {"bits/regex_constants.h", ""}, - {"bits/regex_cursor.h", ""}, - {"bits/regex_error.h", ""}, - {"bits/regex_executor.h", ""}, - {"bits/regex_grep_matcher.h", ""}, - {"bits/regex_grep_matcher.tcc", ""}, - {"bits/regex_nfa.h", ""}, - {"bits/regex_scanner.h", ""}, - {"bits/shared_ptr.h", ""}, - {"bits/shared_ptr_base.h", ""}, - {"bits/shared_ptr_atomic.h", ""}, - {"bits/slice_array.h", ""}, - {"bits/sstream.tcc", ""}, - {"bits/std_abs.h", ""}, - {"bits/std_function.h", ""}, - {"bits/std_mutex.h", ""}, - {"bits/stl_algo.h", ""}, - {"bits/stl_algobase.h", ""}, - {"bits/stl_bvector.h", ""}, - {"bits/stl_construct.h", ""}, - {"bits/stl_deque.h", ""}, - {"bits/stl_function.h", ""}, - {"bits/stl_heap.h", ""}, - {"bits/stl_iterator.h", ""}, - {"bits/stl_iterator_base_funcs.h", ""}, - {"bits/stl_iterator_base_types.h", ""}, - {"bits/stl_list.h", ""}, - {"bits/stl_map.h", ""}, - {"bits/stl_multimap.h", ""}, - {"bits/stl_multiset.h", ""}, - {"bits/stl_numeric.h", ""}, - {"bits/stl_pair.h", ""}, - {"bits/stl_queue.h", ""}, - {"bits/stl_raw_storage_iter.h", ""}, - {"bits/stl_relops.h", ""}, - {"bits/stl_set.h", ""}, - {"bits/stl_stack.h", ""}, - {"bits/stl_tempbuf.h", ""}, - {"bits/stl_tree.h", ""}, - {"bits/stl_uninitialized.h", ""}, - {"bits/stl_vector.h", ""}, - {"bits/stream_iterator.h", ""}, - {"bits/streambuf.tcc", ""}, - {"bits/streambuf_iterator.h", ""}, - {"bits/stringfwd.h", ""}, - {"bits/uniform_int_dist.h", ""}, - {"bits/unique_ptr.h", ""}, - {"bits/unordered_map.h", ""}, - {"bits/unordered_set.h", ""}, - {"bits/uses_allocator.h", ""}, - {"bits/valarray_after.h", ""}, - {"bits/valarray_array.h", ""}, - {"bits/valarray_array.tcc", ""}, - {"bits/valarray_before.h", ""}, - {"bits/vector.tcc", ""}, - {"bitset", ""}, - {"ccomplex", ""}, - {"cctype", ""}, - {"cerrno", ""}, - {"cfenv", ""}, - {"cfloat", ""}, - {"chrono", ""}, - {"cinttypes", ""}, - {"climits", ""}, - {"clocale", ""}, - {"cmath", ""}, - {"complex", ""}, - {"complex.h", ""}, - {"condition_variable", ""}, - {"csetjmp", ""}, - {"csignal", ""}, - {"cstdalign", ""}, - {"cstdarg", ""}, - {"cstdbool", ""}, - {"cstdint", ""}, - {"cstdio", ""}, - {"cstdlib", ""}, - {"cstring", ""}, - {"ctgmath", ""}, - {"ctime", ""}, - {"cwchar", ""}, - {"cwctype", ""}, - {"cxxabi.h", ""}, - {"debug/debug.h", ""}, - {"debug/map.h", ""}, - {"debug/multimap.h", ""}, - {"debug/multiset.h", ""}, - {"debug/set.h", ""}, - {"deque", ""}, - {"exception", ""}, - {"ext/alloc_traits.h", ""}, - {"ext/atomicity.h", ""}, - {"ext/concurrence.h", ""}, - {"ext/new_allocator.h", ""}, - {"ext/numeric_traits.h", ""}, - {"ext/string_conversions.h", ""}, - {"ext/type_traits.h", ""}, - {"fenv.h", ""}, - {"forward_list", ""}, - {"fstream", ""}, - {"functional", ""}, - {"future", ""}, - {"initializer_list", ""}, - {"iomanip", ""}, - {"ios", ""}, - {"iosfwd", ""}, - {"iostream", ""}, - {"istream", ""}, - {"iterator", ""}, - {"limits", ""}, - {"list", ""}, - {"locale", ""}, - {"map", ""}, - {"memory", ""}, - {"shared_mutex", ""}, - {"mutex", ""}, - {"new", ""}, - {"numeric", ""}, - {"ostream", ""}, - {"queue", ""}, - {"random", ""}, - {"ratio", ""}, - {"regex", ""}, - {"scoped_allocator", ""}, - {"set", ""}, - {"sstream", ""}, - {"stack", ""}, - {"stdexcept", ""}, - {"streambuf", ""}, - {"string", ""}, - {"system_error", ""}, - {"tgmath.h", ""}, - {"thread", ""}, - {"tuple", ""}, - {"type_traits", ""}, - {"typeindex", ""}, - {"typeinfo", ""}, - {"unordered_map", ""}, - {"unordered_set", ""}, - {"utility", ""}, - {"valarray", ""}, - {"vector", ""}, - {"include/complex.h", ""}, - {"include/ctype.h", ""}, - {"include/errno.h", ""}, - {"include/fenv.h", ""}, - {"include/inttypes.h", ""}, - {"include/libio.h", ""}, - {"include/limits.h", ""}, - {"include/locale.h", ""}, - {"include/math.h", ""}, - {"include/setjmp.h", ""}, - {"include/signal.h", ""}, - {"include/stdint.h", ""}, - {"include/stdio.h", ""}, - {"include/stdlib.h", ""}, - {"include/string.h", ""}, - {"include/time.h", ""}, - {"include/wchar.h", ""}, - {"include/wctype.h", ""}, - {"bits/cmathcalls.h", ""}, - {"bits/errno.h", ""}, - {"bits/fenv.h", ""}, - {"bits/huge_val.h", ""}, - {"bits/huge_valf.h", ""}, - {"bits/huge_vall.h", ""}, - {"bits/inf.h", ""}, - {"bits/local_lim.h", ""}, - {"bits/locale.h", ""}, - {"bits/mathcalls.h", ""}, - {"bits/mathdef.h", ""}, - {"bits/nan.h", ""}, - {"bits/posix1_lim.h", ""}, - {"bits/posix2_lim.h", ""}, - {"bits/setjmp.h", ""}, - {"bits/sigaction.h", ""}, - {"bits/sigcontext.h", ""}, - {"bits/siginfo.h", ""}, - {"bits/signum.h", ""}, - {"bits/sigset.h", ""}, - {"bits/sigstack.h", ""}, - {"bits/stdio_lim.h", ""}, - {"bits/sys_errlist.h", ""}, - {"bits/time.h", ""}, - {"bits/timex.h", ""}, - {"bits/typesizes.h", ""}, - {"bits/wchar.h", ""}, - {"bits/wordsize.h", ""}, - {"bits/xopen_lim.h", ""}, - {"include/xlocale.h", ""}, - {"bits/atomic_word.h", ""}, - {"bits/basic_file.h", ""}, - {"bits/c\\+\\+allocator.h", ""}, - {"bits/c\\+\\+config.h", ""}, - {"bits/c\\+\\+io.h", ""}, - {"bits/c\\+\\+locale.h", ""}, - {"bits/cpu_defines.h", ""}, - {"bits/ctype_base.h", ""}, - {"bits/cxxabi_tweaks.h", ""}, - {"bits/error_constants.h", ""}, - {"bits/gthr-default.h", ""}, - {"bits/gthr.h", ""}, - {"bits/opt_random.h", ""}, - {"bits/os_defines.h", ""}, - // GNU C headers - {"include/aio.h", ""}, - {"include/aliases.h", ""}, - {"include/alloca.h", ""}, - {"include/ar.h", ""}, - {"include/argp.h", ""}, - {"include/argz.h", ""}, - {"include/arpa/nameser.h", ""}, - {"include/arpa/nameser_compat.h", ""}, - {"include/byteswap.h", ""}, - {"include/cpio.h", ""}, - {"include/crypt.h", ""}, - {"include/dirent.h", ""}, - {"include/dlfcn.h", ""}, - {"include/elf.h", ""}, - {"include/endian.h", ""}, - {"include/envz.h", ""}, - {"include/err.h", ""}, - {"include/error.h", ""}, - {"include/execinfo.h", ""}, - {"include/fcntl.h", ""}, - {"include/features.h", ""}, - {"include/fenv.h", ""}, - {"include/fmtmsg.h", ""}, - {"include/fnmatch.h", ""}, - {"include/fstab.h", ""}, - {"include/fts.h", ""}, - {"include/ftw.h", ""}, - {"include/gconv.h", ""}, - {"include/getopt.h", ""}, - {"include/glob.h", ""}, - {"include/grp.h", ""}, - {"include/gshadow.h", ""}, - {"include/iconv.h", ""}, - {"include/ifaddrs.h", ""}, - {"include/kdb.h", ""}, - {"include/langinfo.h", ""}, - {"include/libgen.h", ""}, - {"include/libintl.h", ""}, - {"include/link.h", ""}, - {"include/malloc.h", ""}, - {"include/mcheck.h", ""}, - {"include/memory.h", ""}, - {"include/mntent.h", ""}, - {"include/monetary.h", ""}, - {"include/mqueue.h", ""}, - {"include/netdb.h", ""}, - {"include/netinet/in.h", ""}, - {"include/nl_types.h", ""}, - {"include/nss.h", ""}, - {"include/obstack.h", ""}, - {"include/panel.h", ""}, - {"include/paths.h", ""}, - {"include/printf.h", ""}, - {"include/profile.h", ""}, - {"include/pthread.h", ""}, - {"include/pty.h", ""}, - {"include/pwd.h", ""}, - {"include/re_comp.h", ""}, - {"include/regex.h", ""}, - {"include/regexp.h", ""}, - {"include/resolv.h", ""}, - {"include/rpc/netdb.h", ""}, - {"include/sched.h", ""}, - {"include/search.h", ""}, - {"include/semaphore.h", ""}, - {"include/sgtty.h", ""}, - {"include/shadow.h", ""}, - {"include/spawn.h", ""}, - {"include/stab.h", ""}, - {"include/stdc-predef.h", ""}, - {"include/stdio_ext.h", ""}, - {"include/strings.h", ""}, - {"include/stropts.h", ""}, - {"include/sudo_plugin.h", ""}, - {"include/sysexits.h", ""}, - {"include/tar.h", ""}, - {"include/tcpd.h", ""}, - {"include/term.h", ""}, - {"include/term_entry.h", ""}, - {"include/termcap.h", ""}, - {"include/termios.h", ""}, - {"include/thread_db.h", ""}, - {"include/tic.h", ""}, - {"include/ttyent.h", ""}, - {"include/uchar.h", ""}, - {"include/ucontext.h", ""}, - {"include/ulimit.h", ""}, - {"include/unctrl.h", ""}, - {"include/unistd.h", ""}, - {"include/utime.h", ""}, - {"include/utmp.h", ""}, - {"include/utmpx.h", ""}, - {"include/values.h", ""}, - {"include/wordexp.h", ""}, - {"fpu_control.h", ""}, - {"ieee754.h", ""}, - {"include/xlocale.h", ""}, - {"gnu/lib-names.h", ""}, - {"gnu/libc-version.h", ""}, - {"gnu/option-groups.h", ""}, - {"gnu/stubs-32.h", ""}, - {"gnu/stubs-64.h", ""}, - {"gnu/stubs-x32.h", ""}, - {"include/rpc/auth_des.h", ""}, - {"include/rpc/rpc_msg.h", ""}, - {"include/rpc/pmap_clnt.h", ""}, - {"include/rpc/rpc.h", ""}, - {"include/rpc/types.h", ""}, - {"include/rpc/auth_unix.h", ""}, - {"include/rpc/key_prot.h", ""}, - {"include/rpc/pmap_prot.h", ""}, - {"include/rpc/auth.h", ""}, - {"include/rpc/svc_auth.h", ""}, - {"include/rpc/xdr.h", ""}, - {"include/rpc/pmap_rmt.h", ""}, - {"include/rpc/des_crypt.h", ""}, - {"include/rpc/svc.h", ""}, - {"include/rpc/rpc_des.h", ""}, - {"include/rpc/clnt.h", ""}, - {"include/scsi/scsi.h", ""}, - {"include/scsi/sg.h", ""}, - {"include/scsi/scsi_ioctl.h", ""}, - {"include/netrose/rose.h", ""}, - {"include/nfs/nfs.h", ""}, - {"include/netatalk/at.h", ""}, - {"include/netinet/ether.h", ""}, - {"include/netinet/icmp6.h", ""}, - {"include/netinet/if_ether.h", ""}, - {"include/netinet/if_fddi.h", ""}, - {"include/netinet/if_tr.h", ""}, - {"include/netinet/igmp.h", ""}, - {"include/netinet/in.h", ""}, - {"include/netinet/in_systm.h", ""}, - {"include/netinet/ip.h", ""}, - {"include/netinet/ip6.h", ""}, - {"include/netinet/ip_icmp.h", ""}, - {"include/netinet/tcp.h", ""}, - {"include/netinet/udp.h", ""}, - {"include/netrom/netrom.h", ""}, - {"include/protocols/routed.h", ""}, - {"include/protocols/rwhod.h", ""}, - {"include/protocols/talkd.h", ""}, - {"include/protocols/timed.h", ""}, - {"include/rpcsvc/klm_prot.x", ""}, - {"include/rpcsvc/rstat.h", ""}, - {"include/rpcsvc/spray.x", ""}, - {"include/rpcsvc/nlm_prot.x", ""}, - {"include/rpcsvc/nis_callback.x", ""}, - {"include/rpcsvc/yp.h", ""}, - {"include/rpcsvc/yp.x", ""}, - {"include/rpcsvc/nfs_prot.h", ""}, - {"include/rpcsvc/rex.h", ""}, - {"include/rpcsvc/yppasswd.h", ""}, - {"include/rpcsvc/rex.x", ""}, - {"include/rpcsvc/nis_tags.h", ""}, - {"include/rpcsvc/nis_callback.h", ""}, - {"include/rpcsvc/nfs_prot.x", ""}, - {"include/rpcsvc/bootparam_prot.x", ""}, - {"include/rpcsvc/rusers.x", ""}, - {"include/rpcsvc/rquota.x", ""}, - {"include/rpcsvc/nis.h", ""}, - {"include/rpcsvc/nislib.h", ""}, - {"include/rpcsvc/ypupd.h", ""}, - {"include/rpcsvc/bootparam.h", ""}, - {"include/rpcsvc/spray.h", ""}, - {"include/rpcsvc/key_prot.h", ""}, - {"include/rpcsvc/klm_prot.h", ""}, - {"include/rpcsvc/sm_inter.h", ""}, - {"include/rpcsvc/nlm_prot.h", ""}, - {"include/rpcsvc/yp_prot.h", ""}, - {"include/rpcsvc/ypclnt.h", ""}, - {"include/rpcsvc/rstat.x", ""}, - {"include/rpcsvc/rusers.h", ""}, - {"include/rpcsvc/key_prot.x", ""}, - {"include/rpcsvc/sm_inter.x", ""}, - {"include/rpcsvc/rquota.h", ""}, - {"include/rpcsvc/nis.x", ""}, - {"include/rpcsvc/bootparam_prot.h", ""}, - {"include/rpcsvc/mount.h", ""}, - {"include/rpcsvc/mount.x", ""}, - {"include/rpcsvc/nis_object.x", ""}, - {"include/rpcsvc/yppasswd.x", ""}, - {"sys/acct.h", ""}, - {"sys/auxv.h", ""}, - {"sys/cdefs.h", ""}, - {"sys/debugreg.h", ""}, - {"sys/dir.h", ""}, - {"sys/elf.h", ""}, - {"sys/epoll.h", ""}, - {"sys/eventfd.h", ""}, - {"sys/fanotify.h", ""}, - {"sys/file.h", ""}, - {"sys/fsuid.h", ""}, - {"sys/gmon.h", ""}, - {"sys/gmon_out.h", ""}, - {"sys/inotify.h", ""}, - {"sys/io.h", ""}, - {"sys/ioctl.h", ""}, - {"sys/ipc.h", ""}, - {"sys/kd.h", ""}, - {"sys/kdaemon.h", ""}, - {"sys/klog.h", ""}, - {"sys/mman.h", ""}, - {"sys/mount.h", ""}, - {"sys/msg.h", ""}, - {"sys/mtio.h", ""}, - {"sys/param.h", ""}, - {"sys/pci.h", ""}, - {"sys/perm.h", ""}, - {"sys/personality.h", ""}, - {"sys/poll.h", ""}, - {"sys/prctl.h", ""}, - {"sys/procfs.h", ""}, - {"sys/profil.h", ""}, - {"sys/ptrace.h", ""}, - {"sys/queue.h", ""}, - {"sys/quota.h", ""}, - {"sys/raw.h", ""}, - {"sys/reboot.h", ""}, - {"sys/reg.h", ""}, - {"sys/resource.h", ""}, - {"sys/select.h", ""}, - {"sys/sem.h", ""}, - {"sys/sendfile.h", ""}, - {"sys/shm.h", ""}, - {"sys/signalfd.h", ""}, - {"sys/socket.h", ""}, - {"sys/stat.h", ""}, - {"sys/statfs.h", ""}, - {"sys/statvfs.h", ""}, - {"sys/swap.h", ""}, - {"sys/syscall.h", ""}, - {"sys/sysctl.h", ""}, - {"sys/sysinfo.h", ""}, - {"sys/syslog.h", ""}, - {"sys/sysmacros.h", ""}, - {"sys/termios.h", ""}, - {"sys/time.h", ""}, - {"sys/timeb.h", ""}, - {"sys/timerfd.h", ""}, - {"sys/times.h", ""}, - {"sys/timex.h", ""}, - {"sys/ttychars.h", ""}, - {"sys/ttydefaults.h", ""}, - {"sys/types.h", ""}, - {"sys/ucontext.h", ""}, - {"sys/uio.h", ""}, - {"sys/un.h", ""}, - {"sys/user.h", ""}, - {"sys/ustat.h", ""}, - {"sys/utsname.h", ""}, - {"sys/vlimit.h", ""}, - {"sys/vm86.h", ""}, - {"sys/vtimes.h", ""}, - {"sys/wait.h", ""}, - {"sys/xattr.h", ""}, - {"bits/epoll.h", ""}, - {"bits/eventfd.h", ""}, - {"bits/inotify.h", ""}, - {"bits/ipc.h", ""}, - {"bits/ipctypes.h", ""}, - {"bits/mman-linux.h", ""}, - {"bits/mman.h", ""}, - {"bits/msq.h", ""}, - {"bits/resource.h", ""}, - {"bits/sem.h", ""}, - {"bits/shm.h", ""}, - {"bits/signalfd.h", ""}, - {"bits/statfs.h", ""}, - {"bits/statvfs.h", ""}, - {"bits/timerfd.h", ""}, - {"bits/utsname.h", ""}, - {"bits/auxv.h", ""}, - {"bits/byteswap-16.h", ""}, - {"bits/byteswap.h", ""}, - {"bits/confname.h", ""}, - {"bits/dirent.h", ""}, - {"bits/dlfcn.h", ""}, - {"bits/elfclass.h", ""}, - {"bits/endian.h", ""}, - {"bits/environments.h", ""}, - {"bits/fcntl-linux.h", ""}, - {"bits/fcntl.h", ""}, - {"bits/in.h", ""}, - {"bits/ioctl-types.h", ""}, - {"bits/ioctls.h", ""}, - {"bits/link.h", ""}, - {"bits/mqueue.h", ""}, - {"bits/netdb.h", ""}, - {"bits/param.h", ""}, - {"bits/poll.h", ""}, - {"bits/posix_opt.h", ""}, - {"bits/pthreadtypes.h", ""}, - {"bits/sched.h", ""}, - {"bits/select.h", ""}, - {"bits/semaphore.h", ""}, - {"bits/sigthread.h", ""}, - {"bits/sockaddr.h", ""}, - {"bits/socket.h", ""}, - {"bits/socket_type.h", ""}, - {"bits/stab.def", ""}, - {"bits/stat.h", ""}, - {"bits/stropts.h", ""}, - {"bits/syscall.h", ""}, - {"bits/syslog-path.h", ""}, - {"bits/termios.h", ""}, - {"bits/types.h", ""}, - {"bits/typesizes.h", ""}, - {"bits/uio.h", ""}, - {"bits/ustat.h", ""}, - {"bits/utmp.h", ""}, - {"bits/utmpx.h", ""}, - {"bits/waitflags.h", ""}, - {"bits/waitstatus.h", ""}, - {"bits/xtitypes.h", ""}, - }); - // Check MaxSuffixComponents constant is correct. - assert(llvm::all_of(SystemHeaderMap->keys(), [](llvm::StringRef Path) { - return std::distance( - llvm::sys::path::begin(Path, llvm::sys::path::Style::posix), - llvm::sys::path::end(Path)) <= MaxSuffixComponents; - })); - // ... and precise. - assert(llvm::find_if(SystemHeaderMap->keys(), [](llvm::StringRef Path) { - return std::distance(llvm::sys::path::begin( - Path, llvm::sys::path::Style::posix), - llvm::sys::path::end(Path)) == - MaxSuffixComponents; - }) != SystemHeaderMap->keys().end()); - - // FIXME: Suffix mapping contains invalid entries for C, so only enable it for - // CPP. - if (Language.CPlusPlus) - StdSuffixHeaderMapping = SystemHeaderMap; } } // namespace clangd diff --git a/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp b/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp --- a/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp +++ b/clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp @@ -21,10 +21,6 @@ CI.addSystemHeadersMapping(Language); // Usual standard library symbols are mapped correctly. EXPECT_EQ("", CI.mapHeader("path/stdio.h", "printf")); - // Suffix mapping isn't available for C, instead of mapping to ` we - // just leave the header as-is. - EXPECT_EQ("include/stdio.h", - CI.mapHeader("include/stdio.h", "unknown_symbol")); } TEST(CanonicalIncludesTest, CXXStandardLibrary) { @@ -37,14 +33,13 @@ EXPECT_EQ("", CI.mapHeader("path/vector.h", "std::vector")); EXPECT_EQ("", CI.mapHeader("path/stdio.h", "std::printf")); // std::move is ambiguous, currently mapped only based on path - EXPECT_EQ("", CI.mapHeader("libstdc++/bits/move.h", "std::move")); + EXPECT_EQ("libstdc++/bits/move.h", + CI.mapHeader("libstdc++/bits/move.h", "std::move")); EXPECT_EQ("path/utility.h", CI.mapHeader("path/utility.h", "std::move")); // Unknown std symbols aren't mapped. EXPECT_EQ("foo/bar.h", CI.mapHeader("foo/bar.h", "std::notathing")); // iosfwd declares some symbols it doesn't own. EXPECT_EQ("", CI.mapHeader("iosfwd", "std::ostream")); - // And (for now) we assume it owns the others. - EXPECT_EQ("", CI.mapHeader("iosfwd", "std::notwathing")); } TEST(CanonicalIncludesTest, PathMapping) { @@ -77,8 +72,6 @@ // We added a mapping from some/path to . ASSERT_EQ("", CI.mapHeader("some/path", "")); - // We should have a path from 'bits/stl_vector.h' to ''. - ASSERT_EQ("", CI.mapHeader("bits/stl_vector.h", "")); // We should also have a symbol mapping from 'std::map' to ''. ASSERT_EQ("", CI.mapHeader("some/header.h", "std::map")); diff --git a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp --- a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -226,10 +226,11 @@ TEST(FileIndexTest, HasSystemHeaderMappingsInPreamble) { TestTU TU; - TU.HeaderCode = "class Foo{};"; - TU.HeaderFilename = "algorithm"; + // std::max is mapped back to + TU.HeaderCode = "namespace std { void max(); }"; + TU.HeaderFilename = "ignored_header_name.h"; - auto Symbols = runFuzzyFind(*TU.index(), ""); + auto Symbols = runFuzzyFind(*TU.index(), "max"); EXPECT_THAT(Symbols, ElementsAre(_)); EXPECT_THAT(Symbols.begin()->IncludeHeaders.front().IncludeHeader, "");