Index: clang-tools-extra/trunk/clangd/CSymbolMap.inc =================================================================== --- clang-tools-extra/trunk/clangd/CSymbolMap.inc +++ clang-tools-extra/trunk/clangd/CSymbolMap.inc @@ -0,0 +1,944 @@ +//===-- gen_std.py generated file -------------------------------*- C++ -*-===// +// +// Used to build a lookup table (qualified names => include headers) for C +// Standard Library symbols. +// +// Automatically generated file, DO NOT EDIT! +// +// Generated from cppreference offline HTML book (modified on 2018-10-28). +//===----------------------------------------------------------------------===// + +SYMBOL(ATOMIC_BOOL_LOCK_FREE, None, ) +SYMBOL(ATOMIC_CHAR16_T_LOCK_FREE, None, ) +SYMBOL(ATOMIC_CHAR32_T_LOCK_FREE, None, ) +SYMBOL(ATOMIC_CHAR_LOCK_FREE, None, ) +SYMBOL(ATOMIC_FLAG_INIT, None, ) +SYMBOL(ATOMIC_INT_LOCK_FREE, None, ) +SYMBOL(ATOMIC_LLONG_LOCK_FREE, None, ) +SYMBOL(ATOMIC_LONG_LOGK_FREE, None, ) +SYMBOL(ATOMIC_POINTER_LOCK_FREE, None, ) +SYMBOL(ATOMIC_SHORT_LOCK_FREE, None, ) +SYMBOL(ATOMIC_VAR_INIT, None, ) +SYMBOL(ATOMIC_WCHAR_T_LOCK_FREE, None, ) +SYMBOL(BUFSIZ, None, ) +SYMBOL(CHAR_BIT, None, ) +SYMBOL(CHAR_MAX, None, ) +SYMBOL(CHAR_MIN, None, ) +SYMBOL(CLOCKS_PER_SEC, None, ) +SYMBOL(CMPLX, None, ) +SYMBOL(CMPLXF, None, ) +SYMBOL(CMPLXL, None, ) +SYMBOL(DBL_DECIMAL_DIG, None, ) +SYMBOL(DBL_DIG, None, ) +SYMBOL(DBL_EPSILON, None, ) +SYMBOL(DBL_HAS_SUBNORM, None, ) +SYMBOL(DBL_MANT_DIG, None, ) +SYMBOL(DBL_MAX, None, ) +SYMBOL(DBL_MAX_10_EXP, None, ) +SYMBOL(DBL_MAX_EXP, None, ) +SYMBOL(DBL_MIN, None, ) +SYMBOL(DBL_MIN_10_EXP, None, ) +SYMBOL(DBL_MIN_EXP, None, ) +SYMBOL(DBL_TRUE_MIN, None, ) +SYMBOL(DECIMAL_DIG, None, ) +SYMBOL(EDOM, None, ) +SYMBOL(EILSEQ, None, ) +SYMBOL(EOF, None, ) +SYMBOL(ERANGE, None, ) +SYMBOL(EXIT_FAILURE, None, ) +SYMBOL(EXIT_SUCCESS, None, ) +SYMBOL(FE_ALL_EXCEPT, None, ) +SYMBOL(FE_DFL_ENV, None, ) +SYMBOL(FE_DIVBYZERO, None, ) +SYMBOL(FE_DOWNWARD, None, ) +SYMBOL(FE_INEXACT, None, ) +SYMBOL(FE_INVALID, None, ) +SYMBOL(FE_OVERFLOW, None, ) +SYMBOL(FE_TONEAREST, None, ) +SYMBOL(FE_TOWARDZERO, None, ) +SYMBOL(FE_UNDERFLOW, None, ) +SYMBOL(FE_UPWARD, None, ) +SYMBOL(FILE, None, ) +SYMBOL(FILENAME_MAX, None, ) +SYMBOL(FLT_DECIMAL_DIG, None, ) +SYMBOL(FLT_DIG, None, ) +SYMBOL(FLT_EPSILON, None, ) +SYMBOL(FLT_EVAL_METHOD, None, ) +SYMBOL(FLT_HAS_SUBNORM, None, ) +SYMBOL(FLT_MANT_DIG, None, ) +SYMBOL(FLT_MAX, None, ) +SYMBOL(FLT_MAX_10_EXP, None, ) +SYMBOL(FLT_MAX_EXP, None, ) +SYMBOL(FLT_MIN, None, ) +SYMBOL(FLT_MIN_10_EXP, None, ) +SYMBOL(FLT_MIN_EXP, None, ) +SYMBOL(FLT_RADIX, None, ) +SYMBOL(FLT_ROUNDS, None, ) +SYMBOL(FLT_TRUE_MIN, None, ) +SYMBOL(FOPEN_MAX, None, ) +SYMBOL(FP_INFINITE, None, ) +SYMBOL(FP_NAN, None, ) +SYMBOL(FP_NORNAL, None, ) +SYMBOL(FP_SUBNORMAL, None, ) +SYMBOL(FP_ZERO, None, ) +SYMBOL(HUGE_VAL, None, ) +SYMBOL(HUGE_VALF, None, ) +SYMBOL(HUGE_VALL, None, ) +SYMBOL(I, None, ) +SYMBOL(INFINITY, None, ) +SYMBOL(INT16_MAX, None, ) +SYMBOL(INT16_MIN, None, ) +SYMBOL(INT32_MAX, None, ) +SYMBOL(INT32_MIN, None, ) +SYMBOL(INT64_MAX, None, ) +SYMBOL(INT64_MIN, None, ) +SYMBOL(INT8_MAX, None, ) +SYMBOL(INT8_MIN, None, ) +SYMBOL(INTMAX_MAX, None, ) +SYMBOL(INTMAX_MIN, None, ) +SYMBOL(INTPTR_MAX, None, ) +SYMBOL(INTPTR_MIN, None, ) +SYMBOL(INT_FAST16_MAX, None, ) +SYMBOL(INT_FAST16_MIN, None, ) +SYMBOL(INT_FAST32_MAX, None, ) +SYMBOL(INT_FAST32_MIN, None, ) +SYMBOL(INT_FAST64_MAX, None, ) +SYMBOL(INT_FAST64_MIN, None, ) +SYMBOL(INT_FAST8_MAX, None, ) +SYMBOL(INT_FAST8_MIN, None, ) +SYMBOL(INT_LEAST16_MAX, None, ) +SYMBOL(INT_LEAST16_MIN, None, ) +SYMBOL(INT_LEAST32_MAX, None, ) +SYMBOL(INT_LEAST32_MIN, None, ) +SYMBOL(INT_LEAST64_MAX, None, ) +SYMBOL(INT_LEAST64_MIN, None, ) +SYMBOL(INT_LEAST8_MAX, None, ) +SYMBOL(INT_LEAST8_MIN, None, ) +SYMBOL(INT_MAX, None, ) +SYMBOL(INT_MIN, None, ) +SYMBOL(LC_ALL, None, ) +SYMBOL(LC_COLLATE, None, ) +SYMBOL(LC_CTYPE, None, ) +SYMBOL(LC_MONETARY, None, ) +SYMBOL(LC_NUMERIC, None, ) +SYMBOL(LC_TIME, None, ) +SYMBOL(LDBL_DECIMAL_DIG, None, ) +SYMBOL(LDBL_DIG, None, ) +SYMBOL(LDBL_EPSILON, None, ) +SYMBOL(LDBL_HAS_SUBNORM, None, ) +SYMBOL(LDBL_MANT_DIG, None, ) +SYMBOL(LDBL_MAX, None, ) +SYMBOL(LDBL_MAX_10_EXP, None, ) +SYMBOL(LDBL_MAX_EXP, None, ) +SYMBOL(LDBL_MIN, None, ) +SYMBOL(LDBL_MIN_10_EXP, None, ) +SYMBOL(LDBL_MIN_EXP, None, ) +SYMBOL(LDBL_TRUE_MIN, None, ) +SYMBOL(LLONG_MAX, None, ) +SYMBOL(LLONG_MIN, None, ) +SYMBOL(LONG_MAX, None, ) +SYMBOL(LONG_MIN, None, ) +SYMBOL(L_tmpnam, None, ) +SYMBOL(L_tmpnam_s, None, ) +SYMBOL(MATH_ERREXCEPT, None, ) +SYMBOL(MATH_ERRNO, None, ) +SYMBOL(MB_CUR_MAX, None, ) +SYMBOL(MB_LEN_MAX, None, ) +SYMBOL(NAN, None, ) +SYMBOL(ONCE_FLAG_INIT, None, ) +SYMBOL(PTRDIFF_MAX, None, ) +SYMBOL(PTRDIFF_MIN, None, ) +SYMBOL(RAND_MAX, None, ) +SYMBOL(RSIZE_MAX, None, ) +SYMBOL(SCHAR_MAX, None, ) +SYMBOL(SCHAR_MIN, None, ) +SYMBOL(SEEK_CUR, None, ) +SYMBOL(SEEK_END, None, ) +SYMBOL(SEEK_SET, None, ) +SYMBOL(SHRT_MAX, None, ) +SYMBOL(SHRT_MIN, None, ) +SYMBOL(SIGABRT, None, ) +SYMBOL(SIGFPE, None, ) +SYMBOL(SIGILL, None, ) +SYMBOL(SIGINT, None, ) +SYMBOL(SIGSEGV, None, ) +SYMBOL(SIGTERM, None, ) +SYMBOL(SIG_ATOMIC_MAX, None, ) +SYMBOL(SIG_ATOMIC_MIN, None, ) +SYMBOL(SIG_DFL, None, ) +SYMBOL(SIG_ERR, None, ) +SYMBOL(SIG_IGN, None, ) +SYMBOL(SIZE_MAX, None, ) +SYMBOL(TIME_UTC, None, ) +SYMBOL(TMP_MAX, None, ) +SYMBOL(TMP_MAX_S, None, ) +SYMBOL(TSS_DTOR_ITERATIONS, None, ) +SYMBOL(UCHAR_MAX, None, ) +SYMBOL(UINT16_MAX, None, ) +SYMBOL(UINT32_MAX, None, ) +SYMBOL(UINT64_MAX, None, ) +SYMBOL(UINT8_MAX, None, ) +SYMBOL(UINTMAX_MAX, None, ) +SYMBOL(UINTPTR_MAX, None, ) +SYMBOL(UINT_FAST16_MAX, None, ) +SYMBOL(UINT_FAST32_MAX, None, ) +SYMBOL(UINT_FAST64_MAX, None, ) +SYMBOL(UINT_FAST8_MAX, None, ) +SYMBOL(UINT_LEAST16_MAX, None, ) +SYMBOL(UINT_LEAST32_MAX, None, ) +SYMBOL(UINT_LEAST64_MAX, None, ) +SYMBOL(UINT_LEAST8_MAX, None, ) +SYMBOL(UINT_MAX, None, ) +SYMBOL(ULLONG_MAX, None, ) +SYMBOL(ULONG_MAX, None, ) +SYMBOL(USHRT_MAX, None, ) +SYMBOL(WCHAR_MAX, None, ) +SYMBOL(WCHAR_MIN, None, ) +SYMBOL(WEOF, None, ) +SYMBOL(WINT_MAX, None, ) +SYMBOL(WINT_MIN, None, ) +SYMBOL(_Complex_I, None, ) +SYMBOL(_IOFBF, None, ) +SYMBOL(_IOLBF, None, ) +SYMBOL(_IONBF, None, ) +SYMBOL(_Imaginary_I, None, ) +SYMBOL(__alignas_is_defined, None, ) +SYMBOL(__alignof_is_defined, None, ) +SYMBOL(abort_handler_s, None, ) +SYMBOL(abs, None, ) +SYMBOL(acos, None, ) +SYMBOL(acosf, None, ) +SYMBOL(acosh, None, ) +SYMBOL(acoshf, None, ) +SYMBOL(acoshl, None, ) +SYMBOL(acosl, None, ) +SYMBOL(alignas, None, ) +SYMBOL(aligned_alloc, None, ) +SYMBOL(alignof, None, ) +SYMBOL(and, None, ) +SYMBOL(and_eq, None, ) +SYMBOL(asctime, None, ) +SYMBOL(asctime_s, None, ) +SYMBOL(asin, None, ) +SYMBOL(asinf, None, ) +SYMBOL(asinh, None, ) +SYMBOL(asinhf, None, ) +SYMBOL(asinhl, None, ) +SYMBOL(asinl, None, ) +SYMBOL(assert, None, ) +SYMBOL(at_quick_exit, None, ) +SYMBOL(atan, None, ) +SYMBOL(atan2, None, ) +SYMBOL(atan2f, None, ) +SYMBOL(atan2l, None, ) +SYMBOL(atanf, None, ) +SYMBOL(atanh, None, ) +SYMBOL(atanhf, None, ) +SYMBOL(atanhl, None, ) +SYMBOL(atanl, None, ) +SYMBOL(atexit, None, ) +SYMBOL(atof, None, ) +SYMBOL(atoi, None, ) +SYMBOL(atol, None, ) +SYMBOL(atoll, None, ) +SYMBOL(atomic_bool, None, ) +SYMBOL(atomic_char, None, ) +SYMBOL(atomic_char16_t, None, ) +SYMBOL(atomic_char32_t, None, ) +SYMBOL(atomic_compare_exchange_strong, None, ) +SYMBOL(atomic_compare_exchange_strong_explicit, None, ) +SYMBOL(atomic_compare_exchange_weak, None, ) +SYMBOL(atomic_compare_exchange_weak_explicit, None, ) +SYMBOL(atomic_exchange, None, ) +SYMBOL(atomic_exchange_explicit, None, ) +SYMBOL(atomic_fetch_add, None, ) +SYMBOL(atomic_fetch_add_explicit, None, ) +SYMBOL(atomic_fetch_and, None, ) +SYMBOL(atomic_fetch_and_explicit, None, ) +SYMBOL(atomic_fetch_or, None, ) +SYMBOL(atomic_fetch_or_explicit, None, ) +SYMBOL(atomic_fetch_sub, None, ) +SYMBOL(atomic_fetch_sub_explicit, None, ) +SYMBOL(atomic_fetch_xor, None, ) +SYMBOL(atomic_fetch_xor_explicit, None, ) +SYMBOL(atomic_flag, None, ) +SYMBOL(atomic_flag_clear, None, ) +SYMBOL(atomic_flag_clear_explicit, None, ) +SYMBOL(atomic_flag_test_and_set, None, ) +SYMBOL(atomic_flag_test_and_set_explicit, None, ) +SYMBOL(atomic_init, None, ) +SYMBOL(atomic_int, None, ) +SYMBOL(atomic_int_fast16_t, None, ) +SYMBOL(atomic_int_fast32_t, None, ) +SYMBOL(atomic_int_fast64_t, None, ) +SYMBOL(atomic_int_fast8_t, None, ) +SYMBOL(atomic_int_least16_t, None, ) +SYMBOL(atomic_int_least32_t, None, ) +SYMBOL(atomic_int_least64_t, None, ) +SYMBOL(atomic_int_least8_t, None, ) +SYMBOL(atomic_intmax_t, None, ) +SYMBOL(atomic_intptr_t, None, ) +SYMBOL(atomic_is_lock_free, None, ) +SYMBOL(atomic_llong, None, ) +SYMBOL(atomic_load, None, ) +SYMBOL(atomic_load_explicit, None, ) +SYMBOL(atomic_long, None, ) +SYMBOL(atomic_ptrdiff_t, None, ) +SYMBOL(atomic_schar, None, ) +SYMBOL(atomic_short, None, ) +SYMBOL(atomic_signal_fence, None, ) +SYMBOL(atomic_size_t, None, ) +SYMBOL(atomic_store, None, ) +SYMBOL(atomic_store_explicit, None, ) +SYMBOL(atomic_thread_fence, None, ) +SYMBOL(atomic_uchar, None, ) +SYMBOL(atomic_uint, None, ) +SYMBOL(atomic_uint_fast16_t, None, ) +SYMBOL(atomic_uint_fast32_t, None, ) +SYMBOL(atomic_uint_fast64_t, None, ) +SYMBOL(atomic_uint_fast8_t, None, ) +SYMBOL(atomic_uint_least16_t, None, ) +SYMBOL(atomic_uint_least32_t, None, ) +SYMBOL(atomic_uint_least64_t, None, ) +SYMBOL(atomic_uint_least8_t, None, ) +SYMBOL(atomic_uintmax_t, None, ) +SYMBOL(atomic_uintptr_t, None, ) +SYMBOL(atomic_ullong, None, ) +SYMBOL(atomic_ulong, None, ) +SYMBOL(atomic_ushort, None, ) +SYMBOL(atomic_wchar_t, None, ) +SYMBOL(bitand, None, ) +SYMBOL(bitor, None, ) +SYMBOL(bsearch, None, ) +SYMBOL(bsearch_s, None, ) +SYMBOL(btowc, None, ) +SYMBOL(c16rtomb, None, ) +SYMBOL(c32rtomb, None, ) +SYMBOL(cabs, None, ) +SYMBOL(cabsf, None, ) +SYMBOL(cabsl, None, ) +SYMBOL(cacos, None, ) +SYMBOL(cacosf, None, ) +SYMBOL(cacosh, None, ) +SYMBOL(cacoshf, None, ) +SYMBOL(cacoshl, None, ) +SYMBOL(cacosl, None, ) +SYMBOL(call_once, None, ) +SYMBOL(calloc, None, ) +SYMBOL(carg, None, ) +SYMBOL(cargf, None, ) +SYMBOL(cargl, None, ) +SYMBOL(casin, None, ) +SYMBOL(casinf, None, ) +SYMBOL(casinh, None, ) +SYMBOL(casinhf, None, ) +SYMBOL(casinhl, None, ) +SYMBOL(casinl, None, ) +SYMBOL(catan, None, ) +SYMBOL(catanf, None, ) +SYMBOL(catanh, None, ) +SYMBOL(catanhf, None, ) +SYMBOL(catanhl, None, ) +SYMBOL(catanl, None, ) +SYMBOL(cbrt, None, ) +SYMBOL(cbrtf, None, ) +SYMBOL(cbrtl, None, ) +SYMBOL(ccos, None, ) +SYMBOL(ccosf, None, ) +SYMBOL(ccosh, None, ) +SYMBOL(ccoshf, None, ) +SYMBOL(ccoshl, None, ) +SYMBOL(ccosl, None, ) +SYMBOL(ceil, None, ) +SYMBOL(ceilf, None, ) +SYMBOL(ceill, None, ) +SYMBOL(cexp, None, ) +SYMBOL(cexpf, None, ) +SYMBOL(cexpl, None, ) +SYMBOL(char16_t, None, ) +SYMBOL(char32_t, None, ) +SYMBOL(cimag, None, ) +SYMBOL(cimagf, None, ) +SYMBOL(cimagl, None, ) +SYMBOL(clearerr, None, ) +SYMBOL(clock, None, ) +SYMBOL(clock_t, None, ) +SYMBOL(clog, None, ) +SYMBOL(clogf, None, ) +SYMBOL(clogl, None, ) +SYMBOL(cnd_broadcast, None, ) +SYMBOL(cnd_destroy, None, ) +SYMBOL(cnd_init, None, ) +SYMBOL(cnd_signal, None, ) +SYMBOL(cnd_t, None, ) +SYMBOL(cnd_timedwait, None, ) +SYMBOL(cnd_wait, None, ) +SYMBOL(compl, None, ) +SYMBOL(complex, None, ) +SYMBOL(conj, None, ) +SYMBOL(conjf, None, ) +SYMBOL(conjl, None, ) +SYMBOL(constraint_handler_t, None, ) +SYMBOL(copysign, None, ) +SYMBOL(copysignf, None, ) +SYMBOL(copysignl, None, ) +SYMBOL(cos, None, ) +SYMBOL(cosf, None, ) +SYMBOL(cosh, None, ) +SYMBOL(coshf, None, ) +SYMBOL(coshl, None, ) +SYMBOL(cosl, None, ) +SYMBOL(cpow, None, ) +SYMBOL(cpowf, None, ) +SYMBOL(cpowl, None, ) +SYMBOL(cproj, None, ) +SYMBOL(cprojf, None, ) +SYMBOL(cprojl, None, ) +SYMBOL(creal, None, ) +SYMBOL(crealf, None, ) +SYMBOL(creall, None, ) +SYMBOL(csin, None, ) +SYMBOL(csinf, None, ) +SYMBOL(csinh, None, ) +SYMBOL(csinhf, None, ) +SYMBOL(csinhl, None, ) +SYMBOL(csinl, None, ) +SYMBOL(csqrt, None, ) +SYMBOL(csqrtf, None, ) +SYMBOL(csqrtl, None, ) +SYMBOL(ctan, None, ) +SYMBOL(ctanf, None, ) +SYMBOL(ctanh, None, ) +SYMBOL(ctanhf, None, ) +SYMBOL(ctanhl, None, ) +SYMBOL(ctanl, None, ) +SYMBOL(ctime, None, ) +SYMBOL(ctime_s, None, ) +SYMBOL(difftime, None, ) +SYMBOL(double_t, None, ) +SYMBOL(erf, None, ) +SYMBOL(erfc, None, ) +SYMBOL(erfcf, None, ) +SYMBOL(erfcl, None, ) +SYMBOL(erff, None, ) +SYMBOL(erfl, None, ) +SYMBOL(errno, None, ) +SYMBOL(exit, None, ) +SYMBOL(exp, None, ) +SYMBOL(exp2, None, ) +SYMBOL(exp2f, None, ) +SYMBOL(exp2l, None, ) +SYMBOL(expf, None, ) +SYMBOL(expl, None, ) +SYMBOL(expm1, None, ) +SYMBOL(expm1f, None, ) +SYMBOL(expm1l, None, ) +SYMBOL(fabs, None, ) +SYMBOL(fabsf, None, ) +SYMBOL(fabsl, None, ) +SYMBOL(fclose, None, ) +SYMBOL(fdim, None, ) +SYMBOL(fdimf, None, ) +SYMBOL(fdiml, None, ) +SYMBOL(feclearexcept, None, ) +SYMBOL(fegetenv, None, ) +SYMBOL(fegetexceptflag, None, ) +SYMBOL(fegetround, None, ) +SYMBOL(feholdexcept, None, ) +SYMBOL(fenv_t, None, ) +SYMBOL(feof, None, ) +SYMBOL(feraiseexcept, None, ) +SYMBOL(ferror, None, ) +SYMBOL(fesetenv, None, ) +SYMBOL(fesetexceptflag, None, ) +SYMBOL(fesetround, None, ) +SYMBOL(fetestexcept, None, ) +SYMBOL(feupdateenv, None, ) +SYMBOL(fexcept_t, None, ) +SYMBOL(fflush, None, ) +SYMBOL(fgetc, None, ) +SYMBOL(fgetpos, None, ) +SYMBOL(fgets, None, ) +SYMBOL(fgetwc, None, ) +SYMBOL(fgetws, None, ) +SYMBOL(float_t, None, ) +SYMBOL(floor, None, ) +SYMBOL(floorf, None, ) +SYMBOL(floorl, None, ) +SYMBOL(fma, None, ) +SYMBOL(fmaf, None, ) +SYMBOL(fmal, None, ) +SYMBOL(fmax, None, ) +SYMBOL(fmaxf, None, ) +SYMBOL(fmaxl, None, ) +SYMBOL(fmin, None, ) +SYMBOL(fminf, None, ) +SYMBOL(fminl, None, ) +SYMBOL(fmod, None, ) +SYMBOL(fmodf, None, ) +SYMBOL(fmodl, None, ) +SYMBOL(fopen, None, ) +SYMBOL(fopen_s, None, ) +SYMBOL(fpclassify, None, ) +SYMBOL(fpos_t, None, ) +SYMBOL(fprintf, None, ) +SYMBOL(fprintf_s, None, ) +SYMBOL(fputc, None, ) +SYMBOL(fputs, None, ) +SYMBOL(fputwc, None, ) +SYMBOL(fputws, None, ) +SYMBOL(fread, None, ) +SYMBOL(free, None, ) +SYMBOL(freopen, None, ) +SYMBOL(freopen_s, None, ) +SYMBOL(frexp, None, ) +SYMBOL(frexpf, None, ) +SYMBOL(frexpl, None, ) +SYMBOL(fscanf, None, ) +SYMBOL(fscanf_s, None, ) +SYMBOL(fseek, None, ) +SYMBOL(fsetpos, None, ) +SYMBOL(ftell, None, ) +SYMBOL(fwide, None, ) +SYMBOL(fwprintf, None, ) +SYMBOL(fwprintf_s, None, ) +SYMBOL(fwrite, None, ) +SYMBOL(fwscanf, None, ) +SYMBOL(fwscanf_s, None, ) +SYMBOL(getc, None, ) +SYMBOL(getchar, None, ) +SYMBOL(getenv, None, ) +SYMBOL(getenv_s, None, ) +SYMBOL(gets, None, ) +SYMBOL(gets_s, None, ) +SYMBOL(getwc, None, ) +SYMBOL(getwchar, None, ) +SYMBOL(gmtime, None, ) +SYMBOL(gmtime_s, None, ) +SYMBOL(hypot, None, ) +SYMBOL(hypotf, None, ) +SYMBOL(hypotl, None, ) +SYMBOL(ignore_handler_s, None, ) +SYMBOL(ilogb, None, ) +SYMBOL(ilogbf, None, ) +SYMBOL(ilogbl, None, ) +SYMBOL(imaginary, None, ) +SYMBOL(imaxabs, None, ) +SYMBOL(int16_t, None, ) +SYMBOL(int32_t, None, ) +SYMBOL(int64_t, None, ) +SYMBOL(int8_t, None, ) +SYMBOL(int_fast16_t, None, ) +SYMBOL(int_fast32_t, None, ) +SYMBOL(int_fast64_t, None, ) +SYMBOL(int_fast8_t, None, ) +SYMBOL(int_least16_t, None, ) +SYMBOL(int_least32_t, None, ) +SYMBOL(int_least64_t, None, ) +SYMBOL(int_least8_t, None, ) +SYMBOL(intmax_t, None, ) +SYMBOL(intptr_t, None, ) +SYMBOL(isalnum, None, ) +SYMBOL(isalpha, None, ) +SYMBOL(isblank, None, ) +SYMBOL(iscntrl, None, ) +SYMBOL(isdigit, None, ) +SYMBOL(isfinite, None, ) +SYMBOL(isgraph, None, ) +SYMBOL(isgreater, None, ) +SYMBOL(isgreaterequal, None, ) +SYMBOL(isinf, None, ) +SYMBOL(isless, None, ) +SYMBOL(islessequal, None, ) +SYMBOL(islessgreater, None, ) +SYMBOL(islower, None, ) +SYMBOL(isnan, None, ) +SYMBOL(isnormal, None, ) +SYMBOL(isprint, None, ) +SYMBOL(ispunct, None, ) +SYMBOL(isspace, None, ) +SYMBOL(isunordered, None, ) +SYMBOL(isupper, None, ) +SYMBOL(iswalnum, None, ) +SYMBOL(iswalpha, None, ) +SYMBOL(iswblank, None, ) +SYMBOL(iswcntrl, None, ) +SYMBOL(iswctype, None, ) +SYMBOL(iswdigit, None, ) +SYMBOL(iswgraph, None, ) +SYMBOL(iswlower, None, ) +SYMBOL(iswprint, None, ) +SYMBOL(iswpunct, None, ) +SYMBOL(iswspace, None, ) +SYMBOL(iswupper, None, ) +SYMBOL(iswxdigit, None, ) +SYMBOL(isxdigit, None, ) +SYMBOL(jmp_buf, None, ) +SYMBOL(kill_dependency, None, ) +SYMBOL(labs, None, ) +SYMBOL(lconv, None, ) +SYMBOL(ldexp, None, ) +SYMBOL(ldexpf, None, ) +SYMBOL(ldexpl, None, ) +SYMBOL(lgamma, None, ) +SYMBOL(lgammaf, None, ) +SYMBOL(lgammal, None, ) +SYMBOL(llabs, None, ) +SYMBOL(llrint, None, ) +SYMBOL(llrintf, None, ) +SYMBOL(llrintl, None, ) +SYMBOL(llround, None, ) +SYMBOL(llroundf, None, ) +SYMBOL(llroundl, None, ) +SYMBOL(localeconv, None, ) +SYMBOL(localtime, None, ) +SYMBOL(localtime_s, None, ) +SYMBOL(log, None, ) +SYMBOL(log10, None, ) +SYMBOL(log10f, None, ) +SYMBOL(log10l, None, ) +SYMBOL(log1p, None, ) +SYMBOL(log1pf, None, ) +SYMBOL(log1pl, None, ) +SYMBOL(log2, None, ) +SYMBOL(log2f, None, ) +SYMBOL(log2l, None, ) +SYMBOL(logb, None, ) +SYMBOL(logbf, None, ) +SYMBOL(logbl, None, ) +SYMBOL(logf, None, ) +SYMBOL(logl, None, ) +SYMBOL(longjmp, None, ) +SYMBOL(lrint, None, ) +SYMBOL(lrintf, None, ) +SYMBOL(lrintl, None, ) +SYMBOL(lround, None, ) +SYMBOL(lroundf, None, ) +SYMBOL(lroundl, None, ) +SYMBOL(malloc, None, ) +SYMBOL(math_errhandling, None, ) +SYMBOL(max_align_t, None, ) +SYMBOL(mblen, None, ) +SYMBOL(mbrlen, None, ) +SYMBOL(mbrtoc16, None, ) +SYMBOL(mbrtoc32, None, ) +SYMBOL(mbrtowc, None, ) +SYMBOL(mbsinit, None, ) +SYMBOL(mbsrtowcs, None, ) +SYMBOL(mbsrtowcs_s, None, ) +SYMBOL(mbstowcs, None, ) +SYMBOL(mbstowcs_s, None, ) +SYMBOL(mbtowc, None, ) +SYMBOL(memchr, None, ) +SYMBOL(memcmp, None, ) +SYMBOL(memcpy, None, ) +SYMBOL(memcpy_s, None, ) +SYMBOL(memmove, None, ) +SYMBOL(memmove_s, None, ) +SYMBOL(memory_order, None, ) +SYMBOL(memory_order_acq_rel, None, ) +SYMBOL(memory_order_acquire, None, ) +SYMBOL(memory_order_consume, None, ) +SYMBOL(memory_order_relaxed, None, ) +SYMBOL(memory_order_release, None, ) +SYMBOL(memory_order_seq_cst, None, ) +SYMBOL(memset, None, ) +SYMBOL(memset_s, None, ) +SYMBOL(mktime, None, ) +SYMBOL(modf, None, ) +SYMBOL(modff, None, ) +SYMBOL(modfl, None, ) +SYMBOL(mtx_destroy, None, ) +SYMBOL(mtx_init, None, ) +SYMBOL(mtx_lock, None, ) +SYMBOL(mtx_plain, None, ) +SYMBOL(mtx_recursive, None, ) +SYMBOL(mtx_t, None, ) +SYMBOL(mtx_timed, None, ) +SYMBOL(mtx_timedlock, None, ) +SYMBOL(mtx_trylock, None, ) +SYMBOL(mtx_unlock, None, ) +SYMBOL(nan, None, ) +SYMBOL(nanf, None, ) +SYMBOL(nanl, None, ) +SYMBOL(nearbyint, None, ) +SYMBOL(nearbyintf, None, ) +SYMBOL(nearbyintl, None, ) +SYMBOL(nextafter, None, ) +SYMBOL(nextafterf, None, ) +SYMBOL(nextafterl, None, ) +SYMBOL(nexttoward, None, ) +SYMBOL(nexttowardf, None, ) +SYMBOL(nexttowardl, None, ) +SYMBOL(noreturn, None, ) +SYMBOL(not, None, ) +SYMBOL(not_eq, None, ) +SYMBOL(offsetof, None, ) +SYMBOL(once_flag, None, ) +SYMBOL(or, None, ) +SYMBOL(or_eq, None, ) +SYMBOL(perror, None, ) +SYMBOL(pow, None, ) +SYMBOL(powf, None, ) +SYMBOL(powl, None, ) +SYMBOL(printf, None, ) +SYMBOL(printf_s, None, ) +SYMBOL(ptrdiff_t, None, ) +SYMBOL(putc, None, ) +SYMBOL(putchar, None, ) +SYMBOL(puts, None, ) +SYMBOL(putwc, None, ) +SYMBOL(putwchar, None, ) +SYMBOL(qsort, None, ) +SYMBOL(qsort_s, None, ) +SYMBOL(quick_exit, None, ) +SYMBOL(raise, None, ) +SYMBOL(rand, None, ) +SYMBOL(realloc, None, ) +SYMBOL(remainder, None, ) +SYMBOL(remainderf, None, ) +SYMBOL(remainderl, None, ) +SYMBOL(remove, None, ) +SYMBOL(remquo, None, ) +SYMBOL(remquof, None, ) +SYMBOL(remquol, None, ) +SYMBOL(rename, None, ) +SYMBOL(rewind, None, ) +SYMBOL(rint, None, ) +SYMBOL(rintf, None, ) +SYMBOL(rintl, None, ) +SYMBOL(round, None, ) +SYMBOL(roundf, None, ) +SYMBOL(roundl, None, ) +SYMBOL(rsize_t, None, ) +SYMBOL(scalbln, None, ) +SYMBOL(scalblnf, None, ) +SYMBOL(scalblnl, None, ) +SYMBOL(scalbn, None, ) +SYMBOL(scalbnf, None, ) +SYMBOL(scalbnl, None, ) +SYMBOL(scanf, None, ) +SYMBOL(scanf_s, None, ) +SYMBOL(set_constraint_handler_s, None, ) +SYMBOL(setbuf, None, ) +SYMBOL(setjmp, None, ) +SYMBOL(setlocale, None, ) +SYMBOL(setvbuf, None, ) +SYMBOL(sig_atomic_t, None, ) +SYMBOL(signal, None, ) +SYMBOL(signbit, None, ) +SYMBOL(sin, None, ) +SYMBOL(sinf, None, ) +SYMBOL(sinh, None, ) +SYMBOL(sinhf, None, ) +SYMBOL(sinhl, None, ) +SYMBOL(sinl, None, ) +SYMBOL(snprintf, None, ) +SYMBOL(snprintf_s, None, ) +SYMBOL(snwprintf_s, None, ) +SYMBOL(sprintf, None, ) +SYMBOL(sprintf_s, None, ) +SYMBOL(sqrt, None, ) +SYMBOL(sqrtf, None, ) +SYMBOL(sqrtl, None, ) +SYMBOL(srand, None, ) +SYMBOL(sscanf, None, ) +SYMBOL(sscanf_s, None, ) +SYMBOL(static_assert, None, ) +SYMBOL(stderr, None, ) +SYMBOL(stdin, None, ) +SYMBOL(stdout, None, ) +SYMBOL(strcat, None, ) +SYMBOL(strcat_s, None, ) +SYMBOL(strchr, None, ) +SYMBOL(strcmp, None, ) +SYMBOL(strcoll, None, ) +SYMBOL(strcpy, None, ) +SYMBOL(strcpy_s, None, ) +SYMBOL(strcspn, None, ) +SYMBOL(strerror, None, ) +SYMBOL(strerror_s, None, ) +SYMBOL(strerrorlen_s, None, ) +SYMBOL(strftime, None, ) +SYMBOL(strlen, None, ) +SYMBOL(strncat, None, ) +SYMBOL(strncat_s, None, ) +SYMBOL(strncmp, None, ) +SYMBOL(strncpy, None, ) +SYMBOL(strncpy_s, None, ) +SYMBOL(strnlen_s, None, ) +SYMBOL(strpbrk, None, ) +SYMBOL(strrchr, None, ) +SYMBOL(strspn, None, ) +SYMBOL(strstr, None, ) +SYMBOL(strtod, None, ) +SYMBOL(strtof, None, ) +SYMBOL(strtoimax, None, ) +SYMBOL(strtok, None, ) +SYMBOL(strtok_s, None, ) +SYMBOL(strtol, None, ) +SYMBOL(strtold, None, ) +SYMBOL(strtoll, None, ) +SYMBOL(strtoul, None, ) +SYMBOL(strtoull, None, ) +SYMBOL(strtoumax, None, ) +SYMBOL(strxfrm, None, ) +SYMBOL(swprintf, None, ) +SYMBOL(swprintf_s, None, ) +SYMBOL(swscanf, None, ) +SYMBOL(swscanf_s, None, ) +SYMBOL(system, None, ) +SYMBOL(tan, None, ) +SYMBOL(tanf, None, ) +SYMBOL(tanh, None, ) +SYMBOL(tanhf, None, ) +SYMBOL(tanhl, None, ) +SYMBOL(tanl, None, ) +SYMBOL(tgamma, None, ) +SYMBOL(tgammaf, None, ) +SYMBOL(tgammal, None, ) +SYMBOL(thrd_busy, None, ) +SYMBOL(thrd_create, None, ) +SYMBOL(thrd_current, None, ) +SYMBOL(thrd_detach, None, ) +SYMBOL(thrd_equal, None, ) +SYMBOL(thrd_error, None, ) +SYMBOL(thrd_join, None, ) +SYMBOL(thrd_nomem, None, ) +SYMBOL(thrd_sleep, None, ) +SYMBOL(thrd_start_t, None, ) +SYMBOL(thrd_success, None, ) +SYMBOL(thrd_t, None, ) +SYMBOL(thrd_timedout, None, ) +SYMBOL(thrd_yield, None, ) +SYMBOL(thread_local, None, ) +SYMBOL(time, None, ) +SYMBOL(time_t, None, ) +SYMBOL(timespec, None, ) +SYMBOL(timespec_get, None, ) +SYMBOL(tm, None, ) +SYMBOL(tmpfile, None, ) +SYMBOL(tmpfile_s, None, ) +SYMBOL(tmpnam, None, ) +SYMBOL(tmpnam_s, None, ) +SYMBOL(tolower, None, ) +SYMBOL(toupper, None, ) +SYMBOL(towctrans, None, ) +SYMBOL(towlower, None, ) +SYMBOL(towupper, None, ) +SYMBOL(trunc, None, ) +SYMBOL(truncf, None, ) +SYMBOL(truncl, None, ) +SYMBOL(tss_create, None, ) +SYMBOL(tss_delete, None, ) +SYMBOL(tss_dtor_t, None, ) +SYMBOL(tss_get, None, ) +SYMBOL(tss_set, None, ) +SYMBOL(tss_t, None, ) +SYMBOL(uint16_t, None, ) +SYMBOL(uint32_t, None, ) +SYMBOL(uint64_t, None, ) +SYMBOL(uint8_t, None, ) +SYMBOL(uint_fast16_t, None, ) +SYMBOL(uint_fast32_t, None, ) +SYMBOL(uint_fast64_t, None, ) +SYMBOL(uint_fast8_t, None, ) +SYMBOL(uint_least16_t, None, ) +SYMBOL(uint_least32_t, None, ) +SYMBOL(uint_least64_t, None, ) +SYMBOL(uint_least8_t, None, ) +SYMBOL(uintmax_t, None, ) +SYMBOL(uintptr_t, None, ) +SYMBOL(ungetc, None, ) +SYMBOL(ungetwc, None, ) +SYMBOL(va_arg, None, ) +SYMBOL(va_copy, None, ) +SYMBOL(va_end, None, ) +SYMBOL(va_start, None, ) +SYMBOL(vfprintf, None, ) +SYMBOL(vfprintf_s, None, ) +SYMBOL(vfscanf, None, ) +SYMBOL(vfscanf_s, None, ) +SYMBOL(vfwprintf, None, ) +SYMBOL(vfwprintf_s, None, ) +SYMBOL(vfwscanf, None, ) +SYMBOL(vfwscanf_s, None, ) +SYMBOL(vprintf, None, ) +SYMBOL(vprintf_s, None, ) +SYMBOL(vscanf, None, ) +SYMBOL(vscanf_s, None, ) +SYMBOL(vsnprintf, None, ) +SYMBOL(vsnprintf_s, None, ) +SYMBOL(vsnwprintf_s, None, ) +SYMBOL(vsprintf, None, ) +SYMBOL(vsprintf_s, None, ) +SYMBOL(vsscanf, None, ) +SYMBOL(vsscanf_s, None, ) +SYMBOL(vswprintf, None, ) +SYMBOL(vswprintf_s, None, ) +SYMBOL(vswscanf, None, ) +SYMBOL(vswscanf_s, None, ) +SYMBOL(vwprintf, None, ) +SYMBOL(vwprintf_s, None, ) +SYMBOL(vwscanf, None, ) +SYMBOL(vwscanf_s, None, ) +SYMBOL(wchar_t, None, ) +SYMBOL(wcrtomb, None, ) +SYMBOL(wcrtomb_s, None, ) +SYMBOL(wcscat, None, ) +SYMBOL(wcscat_s, None, ) +SYMBOL(wcschr, None, ) +SYMBOL(wcscmp, None, ) +SYMBOL(wcscoll, None, ) +SYMBOL(wcscpy, None, ) +SYMBOL(wcscpy_s, None, ) +SYMBOL(wcscspn, None, ) +SYMBOL(wcsftime, None, ) +SYMBOL(wcslen, None, ) +SYMBOL(wcsncat, None, ) +SYMBOL(wcsncat_s, None, ) +SYMBOL(wcsncmp, None, ) +SYMBOL(wcsncpy, None, ) +SYMBOL(wcsncpy_s, None, ) +SYMBOL(wcsnlen_s, None, ) +SYMBOL(wcspbrk, None, ) +SYMBOL(wcsrchr, None, ) +SYMBOL(wcsrtombs, None, ) +SYMBOL(wcsrtombs_s, None, ) +SYMBOL(wcsspn, None, ) +SYMBOL(wcsstr, None, ) +SYMBOL(wcstod, None, ) +SYMBOL(wcstof, None, ) +SYMBOL(wcstoimax, None, ) +SYMBOL(wcstok, None, ) +SYMBOL(wcstok_s, None, ) +SYMBOL(wcstol, None, ) +SYMBOL(wcstold, None, ) +SYMBOL(wcstoll, None, ) +SYMBOL(wcstombs, None, ) +SYMBOL(wcstombs_s, None, ) +SYMBOL(wcstoul, None, ) +SYMBOL(wcstoull, None, ) +SYMBOL(wcstoumax, None, ) +SYMBOL(wcsxfrm, None, ) +SYMBOL(wctob, None, ) +SYMBOL(wctomb, None, ) +SYMBOL(wctomb_s, None, ) +SYMBOL(wctrans, None, ) +SYMBOL(wctrans_t, None, ) +SYMBOL(wctype, None, ) +SYMBOL(wctype_t, None, ) +SYMBOL(wint_t, None, ) +SYMBOL(wmemchr, None, ) +SYMBOL(wmemcmp, None, ) +SYMBOL(wmemcpy, None, ) +SYMBOL(wmemcpy_s, None, ) +SYMBOL(wmemmove, None, ) +SYMBOL(wmemmove_s, None, ) +SYMBOL(wmemset, None, ) +SYMBOL(wprintf, None, ) +SYMBOL(wprintf_s, None, ) +SYMBOL(wscanf, None, ) +SYMBOL(wscanf_s, None, ) +SYMBOL(xor, None, ) +SYMBOL(xor_eq, None, ) Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -130,7 +130,6 @@ public: CppFilePreambleCallbacks(PathRef File, PreambleParsedCallback ParsedCallback) : File(File), ParsedCallback(ParsedCallback) { - addSystemHeadersMapping(&CanonIncludes); } IncludeStructure takeIncludes() { return std::move(Includes); } @@ -149,6 +148,7 @@ } void BeforeExecute(CompilerInstance &CI) override { + addSystemHeadersMapping(&CanonIncludes, CI.getLangOpts()); SourceMgr = &CI.getSourceManager(); } @@ -414,7 +414,7 @@ if (Preamble) CanonIncludes = Preamble->CanonIncludes; else - addSystemHeadersMapping(&CanonIncludes); + addSystemHeadersMapping(&CanonIncludes, Clang->getLangOpts()); std::unique_ptr IWYUHandler = collectIWYUHeaderMaps(&CanonIncludes); Clang->getPreprocessor().addCommentHandler(IWYUHandler.get()); Index: clang-tools-extra/trunk/clangd/StdSymbolMap.inc =================================================================== --- clang-tools-extra/trunk/clangd/StdSymbolMap.inc +++ clang-tools-extra/trunk/clangd/StdSymbolMap.inc @@ -1,6 +1,6 @@ //===-- gen_std.py generated file -------------------------------*- C++ -*-===// // -// Used to build a lookup table (qualified names => include headers) for C++ +// Used to build a lookup table (qualified names => include headers) for CPP // Standard Library symbols. // // Automatically generated file, DO NOT EDIT! Index: clang-tools-extra/trunk/clangd/include-mapping/cppreference_parser.py =================================================================== --- clang-tools-extra/trunk/clangd/include-mapping/cppreference_parser.py +++ clang-tools-extra/trunk/clangd/include-mapping/cppreference_parser.py @@ -0,0 +1,172 @@ +#!/usr/bin/env python +#===- cppreference_parser.py - ------------------------------*- python -*--===# +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#===------------------------------------------------------------------------===# + +from bs4 import BeautifulSoup, NavigableString + +import collections +import multiprocessing +import os +import re +import signal +import sys + + +class Symbol: + + def __init__(self, name, namespace, headers): + # unqualifed symbol name, e.g. "move" + self.name = name + # namespace of the symbol (with trailing "::"), e.g. "std::", "" (global scope) + # None for C symbols. + self.namespace = namespace + # a list of corresponding headers + self.headers = headers + + +def _HasClass(tag, *classes): + for c in tag.get('class', []): + if c in classes: + return True + return False + + +def _ParseSymbolPage(symbol_page_html, symbol_name): + """Parse symbol page and retrieve the include header defined in this page. + The symbol page provides header for the symbol, specifically in + "Defined in header
" section. An example: + + +
Defined in header <ratio>
+ + + Returns a list of headers. + """ + headers = set() + all_headers = set() + + soup = BeautifulSoup(symbol_page_html, "html.parser") + # Rows in table are like: + # Defined in header .t-dsc-header + # Defined in header .t-dsc-header + # decl1 .t-dcl + # Defined in header .t-dsc-header + # decl2 .t-dcl + for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'): + current_headers = [] + was_decl = False + for row in table.select('tr'): + if _HasClass(row, 't-dcl', 't-dsc'): + was_decl = True + # Symbols are in the first cell. + found_symbols = row.find('td').stripped_strings + if not symbol_name in found_symbols: + continue + headers.update(current_headers) + elif _HasClass(row, 't-dsc-header'): + # If we saw a decl since the last header, this is a new block of headers + # for a new block of decls. + if was_decl: + current_headers = [] + was_decl = False + # There are also .t-dsc-header for "defined in namespace". + if not "Defined in header " in row.text: + continue + # The interesting header content (e.g. ) is wrapped in . + for header_code in row.find_all("code"): + current_headers.append(header_code.text) + all_headers.add(header_code.text) + # If the symbol was never named, consider all named headers. + return headers or all_headers + + +def _ParseIndexPage(index_page_html): + """Parse index page. + The index page lists all std symbols and hrefs to their detailed pages + (which contain the defined header). An example: + + abs() (int)
+ acos()
+ + Returns a list of tuple (symbol_name, relative_path_to_symbol_page, variant). + """ + symbols = [] + soup = BeautifulSoup(index_page_html, "html.parser") + for symbol_href in soup.select("a[title]"): + # Ignore annotated symbols like "acos<>() (std::complex)". + # These tend to be overloads, and we the primary is more useful. + # This accidentally accepts begin/end despite the (iterator) caption: the + # (since C++11) note is first. They are good symbols, so the bug is unfixed. + caption = symbol_href.next_sibling + variant = isinstance(caption, NavigableString) and "(" in caption + symbol_tt = symbol_href.find("tt") + if symbol_tt: + symbols.append((symbol_tt.text.rstrip("<>()"), # strip any trailing <>() + symbol_href["href"], variant)) + return symbols + + +def _ReadSymbolPage(path, name): + with open(path) as f: + return _ParseSymbolPage(f.read(), name) + + +def _GetSymbols(pool, root_dir, index_page_name, namespace): + """Get all symbols listed in the index page. All symbols should be in the + given namespace. + + Returns a list of Symbols. + """ + + # Workflow steps: + # 1. Parse index page which lists all symbols to get symbol + # name (unqualified name) and its href link to the symbol page which + # contains the defined header. + # 2. Parse the symbol page to get the defined header. + index_page_path = os.path.join(root_dir, index_page_name) + with open(index_page_path, "r") as f: + # Read each symbol page in parallel. + results = [] # (symbol_name, promise of [header...]) + for symbol_name, symbol_page_path, variant in _ParseIndexPage(f.read()): + # Variant symbols (e.g. the std::locale version of isalpha) add ambiguity. + # FIXME: use these as a fallback rather than ignoring entirely. + if variant: + continue + path = os.path.join(root_dir, symbol_page_path) + results.append((symbol_name, + pool.apply_async(_ReadSymbolPage, (path, symbol_name)))) + + # Build map from symbol name to a set of headers. + symbol_headers = collections.defaultdict(set) + for symbol_name, lazy_headers in results: + symbol_headers[symbol_name].update(lazy_headers.get()) + + symbols = [] + for name, headers in sorted(symbol_headers.items(), key=lambda t : t[0]): + symbols.append(Symbol(name, namespace, list(headers))) + return symbols + + +def GetSymbols(parse_pages): + """Get all symbols by parsing the given pages. + + Args: + parse_pages: a list of tuples (page_root_dir, index_page_name, namespace) + """ + symbols = [] + # Run many workers to process individual symbol pages under the symbol index. + # Don't allow workers to capture Ctrl-C. + pool = multiprocessing.Pool( + initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)) + try: + for root_dir, page_name, namespace in parse_pages: + symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace)) + finally: + pool.terminate() + pool.join() + return symbols Index: clang-tools-extra/trunk/clangd/include-mapping/gen_std.py =================================================================== --- clang-tools-extra/trunk/clangd/include-mapping/gen_std.py +++ clang-tools-extra/trunk/clangd/include-mapping/gen_std.py @@ -8,7 +8,7 @@ #===------------------------------------------------------------------------===# """gen_std.py is a tool to generate a lookup table (from qualified names to -include headers) for C++ Standard Library symbols by parsing archieved HTML +include headers) for C/C++ Standard Library symbols by parsing archieved HTML files from cppreference. Caveats and FIXMEs: @@ -25,24 +25,23 @@ 3. Unzip the zip file from step 2 to directory , you should get a "reference" directory in 4. Run the command: - gen_std.py -cppreference > StdSymbolMap.inc + // Generate C++ symbols + gen_std.py -cppreference -language=cpp > StdSymbolMap.inc + // Generate C symbols + gen_std.py -cppreference -language=c > CSymbolMap.inc """ -from bs4 import BeautifulSoup, NavigableString +import cppreference_parser import argparse -import collections import datetime -import multiprocessing import os -import re -import signal import sys -STDGEN_CODE_PREFIX = """\ +CODE_PREFIX = """\ //===-- gen_std.py generated file -------------------------------*- C++ -*-===// // -// Used to build a lookup table (qualified names => include headers) for C++ +// Used to build a lookup table (qualified names => include headers) for %s // Standard Library symbols. // // Automatically generated file, DO NOT EDIT! @@ -51,189 +50,56 @@ //===----------------------------------------------------------------------===// """ -def HasClass(tag, *classes): - for c in tag.get('class', []): - if c in classes: - return True - return False - -def ParseSymbolPage(symbol_page_html, symbol_name): - """Parse symbol page and retrieve the include header defined in this page. - The symbol page provides header for the symbol, specifically in - "Defined in header
" section. An example: - - -
Defined in header <ratio>
- - - Returns a list of headers. - """ - headers = set() - all_headers = set() - - soup = BeautifulSoup(symbol_page_html, "html.parser") - # Rows in table are like: - # Defined in header .t-dsc-header - # Defined in header .t-dsc-header - # decl1 .t-dcl - # Defined in header .t-dsc-header - # decl2 .t-dcl - for table in soup.select('table.t-dcl-begin, table.t-dsc-begin'): - current_headers = [] - was_decl = False - for row in table.select('tr'): - if HasClass(row, 't-dcl', 't-dsc'): - was_decl = True - # Symbols are in the first cell. - found_symbols = row.find('td').stripped_strings - if not symbol_name in found_symbols: - continue - headers.update(current_headers) - elif HasClass(row, 't-dsc-header'): - # If we saw a decl since the last header, this is a new block of headers - # for a new block of decls. - if was_decl: - current_headers = [] - was_decl = False - # There are also .t-dsc-header for "defined in namespace". - if not "Defined in header " in row.text: - continue - # The interesting header content (e.g. ) is wrapped in . - for header_code in row.find_all("code"): - current_headers.append(header_code.text) - all_headers.add(header_code.text) - # If the symbol was never named, consider all named headers. - return headers or all_headers - - -def ParseIndexPage(index_page_html): - """Parse index page. - The index page lists all std symbols and hrefs to their detailed pages - (which contain the defined header). An example: - - abs() (int)
- acos()
- - Returns a list of tuple (symbol_name, relative_path_to_symbol_page, variant). - """ - symbols = [] - soup = BeautifulSoup(index_page_html, "html.parser") - for symbol_href in soup.select("a[title]"): - # Ignore annotated symbols like "acos<>() (std::complex)". - # These tend to be overloads, and we the primary is more useful. - # This accidentally accepts begin/end despite the (iterator) caption: the - # (since C++11) note is first. They are good symbols, so the bug is unfixed. - caption = symbol_href.next_sibling - variant = isinstance(caption, NavigableString) and "(" in caption - symbol_tt = symbol_href.find("tt") - if symbol_tt: - symbols.append((symbol_tt.text.rstrip("<>()"), # strip any trailing <>() - symbol_href["href"], variant)) - return symbols - -class Symbol: - - def __init__(self, name, namespace, headers): - # unqualifed symbol name, e.g. "move" - self.name = name - # namespace of the symbol (with trailing "::"), e.g. "std::" - self.namespace = namespace - # a list of corresponding headers - self.headers = headers - - -def ReadSymbolPage(path, name): - with open(path) as f: - return ParseSymbolPage(f.read(), name) - - -def GetSymbols(pool, root_dir, index_page_name, namespace): - """Get all symbols listed in the index page. All symbols should be in the - given namespace. - - Returns a list of Symbols. - """ - - # Workflow steps: - # 1. Parse index page which lists all symbols to get symbol - # name (unqualified name) and its href link to the symbol page which - # contains the defined header. - # 2. Parse the symbol page to get the defined header. - index_page_path = os.path.join(root_dir, index_page_name) - with open(index_page_path, "r") as f: - # Read each symbol page in parallel. - results = [] # (symbol_name, promise of [header...]) - for symbol_name, symbol_page_path, variant in ParseIndexPage(f.read()): - # Variant symbols (e.g. the std::locale version of isalpha) add ambiguity. - # FIXME: use these as a fallback rather than ignoring entirely. - if variant: - continue - path = os.path.join(root_dir, symbol_page_path) - results.append((symbol_name, - pool.apply_async(ReadSymbolPage, (path, symbol_name)))) - - # Build map from symbol name to a set of headers. - symbol_headers = collections.defaultdict(set) - for symbol_name, lazy_headers in results: - symbol_headers[symbol_name].update(lazy_headers.get()) - - symbols = [] - for name, headers in sorted(symbol_headers.items(), key=lambda t : t[0]): - symbols.append(Symbol(name, namespace, list(headers))) - return symbols - - def ParseArg(): parser = argparse.ArgumentParser(description='Generate StdGen file') parser.add_argument('-cppreference', metavar='PATH', default='', help='path to the cppreference offline HTML directory', required=True - ) + ) + parser.add_argument('-language', + default='cpp', + help='Generate c or cpp symbols', + required=True) return parser.parse_args() def main(): args = ParseArg() - cpp_root = os.path.join(args.cppreference, "en", "cpp") - symbol_index_root = os.path.join(cpp_root, "symbol_index") + if args.language == 'cpp': + page_root = os.path.join(args.cppreference, "en", "cpp") + symbol_index_root = os.path.join(page_root, "symbol_index") + parse_pages = [ + (page_root, "symbol_index.html", "std::"), + # std sub-namespace symbols have separated pages. + # We don't index std literal operators (e.g. + # std::literals::chrono_literals::operator""d), these symbols can't be + # accessed by std::. + # FIXME: index std::placeholders symbols, placeholders.html page is + # different (which contains one entry for _1, _2, ..., _N), we need special + # handling. + (symbol_index_root, "chrono.html", "std::chrono::"), + (symbol_index_root, "filesystem.html", "std::filesystem::"), + (symbol_index_root, "pmr.html", "std::pmr::"), + (symbol_index_root, "regex_constants.html", "std::regex_constants::"), + (symbol_index_root, "this_thread.html", "std::this_thread::"), + ] + elif args.language == 'c': + page_root = os.path.join(args.cppreference, "en", "c") + symbol_index_root = page_root + parse_pages = [(page_root, "index.html", None)] + if not os.path.exists(symbol_index_root): exit("Path %s doesn't exist!" % symbol_index_root) - parse_pages = [ - (cpp_root, "symbol_index.html", "std::"), - # std sub-namespace symbols have separated pages. - # We don't index std literal operators (e.g. - # std::literals::chrono_literals::operator""d), these symbols can't be - # accessed by std::. - # FIXME: index std::placeholders symbols, placeholders.html page is - # different (which contains one entry for _1, _2, ..., _N), we need special - # handling. - (symbol_index_root, "chrono.html", "std::chrono::"), - (symbol_index_root, "filesystem.html", "std::filesystem::"), - (symbol_index_root, "pmr.html", "std::pmr::"), - (symbol_index_root, "regex_constants.html", "std::regex_constants::"), - (symbol_index_root, "this_thread.html", "std::this_thread::"), - ] - - symbols = [] - # Run many workers to process individual symbol pages under the symbol index. - # Don't allow workers to capture Ctrl-C. - pool = multiprocessing.Pool( - initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)) - try: - for root_dir, page_name, namespace in parse_pages: - symbols.extend(GetSymbols(pool, root_dir, page_name, namespace)) - finally: - pool.terminate() - pool.join() + symbols = cppreference_parser.GetSymbols(parse_pages) # We don't have version information from the unzipped offline HTML files. # so we use the modified time of the symbol_index.html as the version. - index_page_path = os.path.join(cpp_root, "symbol_index.html") + index_page_path = os.path.join(page_root, "index.html") cppreference_modified_date = datetime.datetime.fromtimestamp( os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d') - print STDGEN_CODE_PREFIX % cppreference_modified_date + print CODE_PREFIX % (args.language.upper(), cppreference_modified_date) for symbol in symbols: if len(symbol.headers) == 1: # SYMBOL(unqualified_name, namespace, header) Index: clang-tools-extra/trunk/clangd/include-mapping/test.py =================================================================== --- clang-tools-extra/trunk/clangd/include-mapping/test.py +++ clang-tools-extra/trunk/clangd/include-mapping/test.py @@ -7,7 +7,7 @@ # #===------------------------------------------------------------------------===# -from gen_std import ParseSymbolPage, ParseIndexPage +from cppreference_parser import _ParseSymbolPage, _ParseIndexPage import unittest @@ -22,7 +22,7 @@ as_bytes<>() (since C++20)
""" - actual = ParseIndexPage(html) + actual = _ParseIndexPage(html) expected = [ ("abs", "abs.html", True), ("abs", "complex/abs.html", True), @@ -53,7 +53,7 @@ """ - self.assertEqual(ParseSymbolPage(html, 'foo'), set([''])) + self.assertEqual(_ParseSymbolPage(html, 'foo'), set([''])) def testParseSymbolPage_MulHeaders(self): @@ -94,7 +94,7 @@ """ - self.assertEqual(ParseSymbolPage(html, "foo"), + self.assertEqual(_ParseSymbolPage(html, "foo"), set(['', ''])) @@ -121,7 +121,7 @@ """ - self.assertEqual(ParseSymbolPage(html, "foo"), + self.assertEqual(_ParseSymbolPage(html, "foo"), set(['', ''])) def testParseSymbolPage_MulSymbolsInSameTd(self): @@ -145,9 +145,9 @@ """ - self.assertEqual(ParseSymbolPage(html, "int8_t"), + self.assertEqual(_ParseSymbolPage(html, "int8_t"), set([''])) - self.assertEqual(ParseSymbolPage(html, "int16_t"), + self.assertEqual(_ParseSymbolPage(html, "int16_t"), set([''])) Index: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h =================================================================== --- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h +++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h @@ -84,7 +84,8 @@ /// - Compiler extensions, e.g. include/avx512bwintrin.h$ -> /// The mapping is hardcoded and hand-maintained, so it might not cover all /// headers. -void addSystemHeadersMapping(CanonicalIncludes *Includes); +void addSystemHeadersMapping(CanonicalIncludes *Includes, + const LangOptions &Language); } // namespace clangd } // namespace clang Index: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp =================================================================== --- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp +++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp @@ -86,16 +86,25 @@ return llvm::make_unique(Includes); } -void addSystemHeadersMapping(CanonicalIncludes *Includes) { +void addSystemHeadersMapping(CanonicalIncludes *Includes, + const LangOptions &Language) { static const std::vector> SymbolMap = { #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header }, #include "StdSymbolMap.inc" #undef SYMBOL }; - - for (const auto &Pair : SymbolMap) - Includes->addSymbolMapping(Pair.first, Pair.second); - + static const std::vector> CSymbolMap = { +#define SYMBOL(Name, NameSpace, Header) { #Name, #Header }, + #include "CSymbolMap.inc" +#undef SYMBOL + }; + if (Language.CPlusPlus) { + for (const auto &Pair : SymbolMap) + Includes->addSymbolMapping(Pair.first, Pair.second); + } else if (Language.C11) { + for (const auto &Pair : CSymbolMap) + Includes->addSymbolMapping(Pair.first, Pair.second); + } // FIXME: remove the std header mapping once we support ambiguous symbols, now // it serves as a fallback to disambiguate: // - symbols with mulitiple headers (e.g. std::move) Index: clang-tools-extra/trunk/clangd/index/IndexAction.cpp =================================================================== --- clang-tools-extra/trunk/clangd/index/IndexAction.cpp +++ clang-tools-extra/trunk/clangd/index/IndexAction.cpp @@ -128,6 +128,7 @@ std::unique_ptr CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) override { CI.getPreprocessor().addCommentHandler(PragmaHandler.get()); + addSystemHeadersMapping(Includes.get(), CI.getLangOpts()); if (IncludeGraphCallback != nullptr) CI.getPreprocessor().addPPCallbacks( llvm::make_unique(CI.getSourceManager(), IG)); @@ -200,7 +201,6 @@ Opts.RefsInHeaders = true; } auto Includes = llvm::make_unique(); - addSystemHeadersMapping(Includes.get()); Opts.Includes = Includes.get(); return llvm::make_unique( std::make_shared(std::move(Opts)), std::move(Includes), Index: clang-tools-extra/trunk/clangd/unittests/CanonicalIncludesTests.cpp =================================================================== --- clang-tools-extra/trunk/clangd/unittests/CanonicalIncludesTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/CanonicalIncludesTests.cpp @@ -13,12 +13,24 @@ namespace clangd { namespace { +TEST(CanonicalIncludesTest, CStandardLibrary) { + CanonicalIncludes CI; + auto Language = LangOptions(); + Language.C11 = true; + addSystemHeadersMapping(&CI, Language); + // Usual standard library symbols are mapped correctly. + EXPECT_EQ("", CI.mapHeader("path/stdio.h", "printf")); +} + TEST(CanonicalIncludesTest, CXXStandardLibrary) { CanonicalIncludes CI; - addSystemHeadersMapping(&CI); + auto Language = LangOptions(); + Language.CPlusPlus = true; + addSystemHeadersMapping(&CI, Language); // Usual standard library symbols are mapped correctly. 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("path/utility.h", CI.mapHeader("path/utility.h", "std::move")); Index: clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp =================================================================== --- clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp @@ -945,7 +945,9 @@ TEST_F(SymbolCollectorTest, CanonicalSTLHeader) { CollectorOpts.CollectIncludePath = true; CanonicalIncludes Includes; - addSystemHeadersMapping(&Includes); + auto Language = LangOptions(); + Language.CPlusPlus = true; + addSystemHeadersMapping(&Includes, Language); CollectorOpts.Includes = &Includes; runSymbolCollector("namespace std { class string {}; }", /*Main=*/""); EXPECT_THAT(Symbols,