diff --git a/clang-tools-extra/clangd/CSymbolMap.inc b/clang-tools-extra/clangd/CSymbolMap.inc new file mode 100644 --- /dev/null +++ b/clang-tools-extra/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, , ) +SYMBOL(ATOMIC_CHAR16_T_LOCK_FREE, , ) +SYMBOL(ATOMIC_CHAR32_T_LOCK_FREE, , ) +SYMBOL(ATOMIC_CHAR_LOCK_FREE, , ) +SYMBOL(ATOMIC_FLAG_INIT, , ) +SYMBOL(ATOMIC_INT_LOCK_FREE, , ) +SYMBOL(ATOMIC_LLONG_LOCK_FREE, , ) +SYMBOL(ATOMIC_LONG_LOGK_FREE, , ) +SYMBOL(ATOMIC_POINTER_LOCK_FREE, , ) +SYMBOL(ATOMIC_SHORT_LOCK_FREE, , ) +SYMBOL(ATOMIC_VAR_INIT, , ) +SYMBOL(ATOMIC_WCHAR_T_LOCK_FREE, , ) +SYMBOL(BUFSIZ, , ) +SYMBOL(CHAR_BIT, , ) +SYMBOL(CHAR_MAX, , ) +SYMBOL(CHAR_MIN, , ) +SYMBOL(CLOCKS_PER_SEC, , ) +SYMBOL(CMPLX, , ) +SYMBOL(CMPLXF, , ) +SYMBOL(CMPLXL, , ) +SYMBOL(DBL_DECIMAL_DIG, , ) +SYMBOL(DBL_DIG, , ) +SYMBOL(DBL_EPSILON, , ) +SYMBOL(DBL_HAS_SUBNORM, , ) +SYMBOL(DBL_MANT_DIG, , ) +SYMBOL(DBL_MAX, , ) +SYMBOL(DBL_MAX_10_EXP, , ) +SYMBOL(DBL_MAX_EXP, , ) +SYMBOL(DBL_MIN, , ) +SYMBOL(DBL_MIN_10_EXP, , ) +SYMBOL(DBL_MIN_EXP, , ) +SYMBOL(DBL_TRUE_MIN, , ) +SYMBOL(DECIMAL_DIG, , ) +SYMBOL(EDOM, , ) +SYMBOL(EILSEQ, , ) +SYMBOL(EOF, , ) +SYMBOL(ERANGE, , ) +SYMBOL(EXIT_FAILURE, , ) +SYMBOL(EXIT_SUCCESS, , ) +SYMBOL(FE_ALL_EXCEPT, , ) +SYMBOL(FE_DFL_ENV, , ) +SYMBOL(FE_DIVBYZERO, , ) +SYMBOL(FE_DOWNWARD, , ) +SYMBOL(FE_INEXACT, , ) +SYMBOL(FE_INVALID, , ) +SYMBOL(FE_OVERFLOW, , ) +SYMBOL(FE_TONEAREST, , ) +SYMBOL(FE_TOWARDZERO, , ) +SYMBOL(FE_UNDERFLOW, , ) +SYMBOL(FE_UPWARD, , ) +SYMBOL(FILE, , ) +SYMBOL(FILENAME_MAX, , ) +SYMBOL(FLT_DECIMAL_DIG, , ) +SYMBOL(FLT_DIG, , ) +SYMBOL(FLT_EPSILON, , ) +SYMBOL(FLT_EVAL_METHOD, , ) +SYMBOL(FLT_HAS_SUBNORM, , ) +SYMBOL(FLT_MANT_DIG, , ) +SYMBOL(FLT_MAX, , ) +SYMBOL(FLT_MAX_10_EXP, , ) +SYMBOL(FLT_MAX_EXP, , ) +SYMBOL(FLT_MIN, , ) +SYMBOL(FLT_MIN_10_EXP, , ) +SYMBOL(FLT_MIN_EXP, , ) +SYMBOL(FLT_RADIX, , ) +SYMBOL(FLT_ROUNDS, , ) +SYMBOL(FLT_TRUE_MIN, , ) +SYMBOL(FOPEN_MAX, , ) +SYMBOL(FP_INFINITE, , ) +SYMBOL(FP_NAN, , ) +SYMBOL(FP_NORNAL, , ) +SYMBOL(FP_SUBNORMAL, , ) +SYMBOL(FP_ZERO, , ) +SYMBOL(HUGE_VAL, , ) +SYMBOL(HUGE_VALF, , ) +SYMBOL(HUGE_VALL, , ) +SYMBOL(I, , ) +SYMBOL(INFINITY, , ) +SYMBOL(INT16_MAX, , ) +SYMBOL(INT16_MIN, , ) +SYMBOL(INT32_MAX, , ) +SYMBOL(INT32_MIN, , ) +SYMBOL(INT64_MAX, , ) +SYMBOL(INT64_MIN, , ) +SYMBOL(INT8_MAX, , ) +SYMBOL(INT8_MIN, , ) +SYMBOL(INTMAX_MAX, , ) +SYMBOL(INTMAX_MIN, , ) +SYMBOL(INTPTR_MAX, , ) +SYMBOL(INTPTR_MIN, , ) +SYMBOL(INT_FAST16_MAX, , ) +SYMBOL(INT_FAST16_MIN, , ) +SYMBOL(INT_FAST32_MAX, , ) +SYMBOL(INT_FAST32_MIN, , ) +SYMBOL(INT_FAST64_MAX, , ) +SYMBOL(INT_FAST64_MIN, , ) +SYMBOL(INT_FAST8_MAX, , ) +SYMBOL(INT_FAST8_MIN, , ) +SYMBOL(INT_LEAST16_MAX, , ) +SYMBOL(INT_LEAST16_MIN, , ) +SYMBOL(INT_LEAST32_MAX, , ) +SYMBOL(INT_LEAST32_MIN, , ) +SYMBOL(INT_LEAST64_MAX, , ) +SYMBOL(INT_LEAST64_MIN, , ) +SYMBOL(INT_LEAST8_MAX, , ) +SYMBOL(INT_LEAST8_MIN, , ) +SYMBOL(INT_MAX, , ) +SYMBOL(INT_MIN, , ) +SYMBOL(LC_ALL, , ) +SYMBOL(LC_COLLATE, , ) +SYMBOL(LC_CTYPE, , ) +SYMBOL(LC_MONETARY, , ) +SYMBOL(LC_NUMERIC, , ) +SYMBOL(LC_TIME, , ) +SYMBOL(LDBL_DECIMAL_DIG, , ) +SYMBOL(LDBL_DIG, , ) +SYMBOL(LDBL_EPSILON, , ) +SYMBOL(LDBL_HAS_SUBNORM, , ) +SYMBOL(LDBL_MANT_DIG, , ) +SYMBOL(LDBL_MAX, , ) +SYMBOL(LDBL_MAX_10_EXP, , ) +SYMBOL(LDBL_MAX_EXP, , ) +SYMBOL(LDBL_MIN, , ) +SYMBOL(LDBL_MIN_10_EXP, , ) +SYMBOL(LDBL_MIN_EXP, , ) +SYMBOL(LDBL_TRUE_MIN, , ) +SYMBOL(LLONG_MAX, , ) +SYMBOL(LLONG_MIN, , ) +SYMBOL(LONG_MAX, , ) +SYMBOL(LONG_MIN, , ) +SYMBOL(L_tmpnam, , ) +SYMBOL(L_tmpnam_s, , ) +SYMBOL(MATH_ERREXCEPT, , ) +SYMBOL(MATH_ERRNO, , ) +SYMBOL(MB_CUR_MAX, , ) +SYMBOL(MB_LEN_MAX, , ) +SYMBOL(NAN, , ) +SYMBOL(ONCE_FLAG_INIT, , ) +SYMBOL(PTRDIFF_MAX, , ) +SYMBOL(PTRDIFF_MIN, , ) +SYMBOL(RAND_MAX, , ) +SYMBOL(RSIZE_MAX, , ) +SYMBOL(SCHAR_MAX, , ) +SYMBOL(SCHAR_MIN, , ) +SYMBOL(SEEK_CUR, , ) +SYMBOL(SEEK_END, , ) +SYMBOL(SEEK_SET, , ) +SYMBOL(SHRT_MAX, , ) +SYMBOL(SHRT_MIN, , ) +SYMBOL(SIGABRT, , ) +SYMBOL(SIGFPE, , ) +SYMBOL(SIGILL, , ) +SYMBOL(SIGINT, , ) +SYMBOL(SIGSEGV, , ) +SYMBOL(SIGTERM, , ) +SYMBOL(SIG_ATOMIC_MAX, , ) +SYMBOL(SIG_ATOMIC_MIN, , ) +SYMBOL(SIG_DFL, , ) +SYMBOL(SIG_ERR, , ) +SYMBOL(SIG_IGN, , ) +SYMBOL(SIZE_MAX, , ) +SYMBOL(TIME_UTC, , ) +SYMBOL(TMP_MAX, , ) +SYMBOL(TMP_MAX_S, , ) +SYMBOL(TSS_DTOR_ITERATIONS, , ) +SYMBOL(UCHAR_MAX, , ) +SYMBOL(UINT16_MAX, , ) +SYMBOL(UINT32_MAX, , ) +SYMBOL(UINT64_MAX, , ) +SYMBOL(UINT8_MAX, , ) +SYMBOL(UINTMAX_MAX, , ) +SYMBOL(UINTPTR_MAX, , ) +SYMBOL(UINT_FAST16_MAX, , ) +SYMBOL(UINT_FAST32_MAX, , ) +SYMBOL(UINT_FAST64_MAX, , ) +SYMBOL(UINT_FAST8_MAX, , ) +SYMBOL(UINT_LEAST16_MAX, , ) +SYMBOL(UINT_LEAST32_MAX, , ) +SYMBOL(UINT_LEAST64_MAX, , ) +SYMBOL(UINT_LEAST8_MAX, , ) +SYMBOL(UINT_MAX, , ) +SYMBOL(ULLONG_MAX, , ) +SYMBOL(ULONG_MAX, , ) +SYMBOL(USHRT_MAX, , ) +SYMBOL(WCHAR_MAX, , ) +SYMBOL(WCHAR_MIN, , ) +SYMBOL(WEOF, , ) +SYMBOL(WINT_MAX, , ) +SYMBOL(WINT_MIN, , ) +SYMBOL(_Complex_I, , ) +SYMBOL(_IOFBF, , ) +SYMBOL(_IOLBF, , ) +SYMBOL(_IONBF, , ) +SYMBOL(_Imaginary_I, , ) +SYMBOL(__alignas_is_defined, , ) +SYMBOL(__alignof_is_defined, , ) +SYMBOL(abort_handler_s, , ) +SYMBOL(abs, , ) +SYMBOL(acos, , ) +SYMBOL(acosf, , ) +SYMBOL(acosh, , ) +SYMBOL(acoshf, , ) +SYMBOL(acoshl, , ) +SYMBOL(acosl, , ) +SYMBOL(alignas, , ) +SYMBOL(aligned_alloc, , ) +SYMBOL(alignof, , ) +SYMBOL(and, , ) +SYMBOL(and_eq, , ) +SYMBOL(asctime, , ) +SYMBOL(asctime_s, , ) +SYMBOL(asin, , ) +SYMBOL(asinf, , ) +SYMBOL(asinh, , ) +SYMBOL(asinhf, , ) +SYMBOL(asinhl, , ) +SYMBOL(asinl, , ) +SYMBOL(assert, , ) +SYMBOL(at_quick_exit, , ) +SYMBOL(atan, , ) +SYMBOL(atan2, , ) +SYMBOL(atan2f, , ) +SYMBOL(atan2l, , ) +SYMBOL(atanf, , ) +SYMBOL(atanh, , ) +SYMBOL(atanhf, , ) +SYMBOL(atanhl, , ) +SYMBOL(atanl, , ) +SYMBOL(atexit, , ) +SYMBOL(atof, , ) +SYMBOL(atoi, , ) +SYMBOL(atol, , ) +SYMBOL(atoll, , ) +SYMBOL(atomic_bool, , ) +SYMBOL(atomic_char, , ) +SYMBOL(atomic_char16_t, , ) +SYMBOL(atomic_char32_t, , ) +SYMBOL(atomic_compare_exchange_strong, , ) +SYMBOL(atomic_compare_exchange_strong_explicit, , ) +SYMBOL(atomic_compare_exchange_weak, , ) +SYMBOL(atomic_compare_exchange_weak_explicit, , ) +SYMBOL(atomic_exchange, , ) +SYMBOL(atomic_exchange_explicit, , ) +SYMBOL(atomic_fetch_add, , ) +SYMBOL(atomic_fetch_add_explicit, , ) +SYMBOL(atomic_fetch_and, , ) +SYMBOL(atomic_fetch_and_explicit, , ) +SYMBOL(atomic_fetch_or, , ) +SYMBOL(atomic_fetch_or_explicit, , ) +SYMBOL(atomic_fetch_sub, , ) +SYMBOL(atomic_fetch_sub_explicit, , ) +SYMBOL(atomic_fetch_xor, , ) +SYMBOL(atomic_fetch_xor_explicit, , ) +SYMBOL(atomic_flag, , ) +SYMBOL(atomic_flag_clear, , ) +SYMBOL(atomic_flag_clear_explicit, , ) +SYMBOL(atomic_flag_test_and_set, , ) +SYMBOL(atomic_flag_test_and_set_explicit, , ) +SYMBOL(atomic_init, , ) +SYMBOL(atomic_int, , ) +SYMBOL(atomic_int_fast16_t, , ) +SYMBOL(atomic_int_fast32_t, , ) +SYMBOL(atomic_int_fast64_t, , ) +SYMBOL(atomic_int_fast8_t, , ) +SYMBOL(atomic_int_least16_t, , ) +SYMBOL(atomic_int_least32_t, , ) +SYMBOL(atomic_int_least64_t, , ) +SYMBOL(atomic_int_least8_t, , ) +SYMBOL(atomic_intmax_t, , ) +SYMBOL(atomic_intptr_t, , ) +SYMBOL(atomic_is_lock_free, , ) +SYMBOL(atomic_llong, , ) +SYMBOL(atomic_load, , ) +SYMBOL(atomic_load_explicit, , ) +SYMBOL(atomic_long, , ) +SYMBOL(atomic_ptrdiff_t, , ) +SYMBOL(atomic_schar, , ) +SYMBOL(atomic_short, , ) +SYMBOL(atomic_signal_fence, , ) +SYMBOL(atomic_size_t, , ) +SYMBOL(atomic_store, , ) +SYMBOL(atomic_store_explicit, , ) +SYMBOL(atomic_thread_fence, , ) +SYMBOL(atomic_uchar, , ) +SYMBOL(atomic_uint, , ) +SYMBOL(atomic_uint_fast16_t, , ) +SYMBOL(atomic_uint_fast32_t, , ) +SYMBOL(atomic_uint_fast64_t, , ) +SYMBOL(atomic_uint_fast8_t, , ) +SYMBOL(atomic_uint_least16_t, , ) +SYMBOL(atomic_uint_least32_t, , ) +SYMBOL(atomic_uint_least64_t, , ) +SYMBOL(atomic_uint_least8_t, , ) +SYMBOL(atomic_uintmax_t, , ) +SYMBOL(atomic_uintptr_t, , ) +SYMBOL(atomic_ullong, , ) +SYMBOL(atomic_ulong, , ) +SYMBOL(atomic_ushort, , ) +SYMBOL(atomic_wchar_t, , ) +SYMBOL(bitand, , ) +SYMBOL(bitor, , ) +SYMBOL(bsearch, , ) +SYMBOL(bsearch_s, , ) +SYMBOL(btowc, , ) +SYMBOL(c16rtomb, , ) +SYMBOL(c32rtomb, , ) +SYMBOL(cabs, , ) +SYMBOL(cabsf, , ) +SYMBOL(cabsl, , ) +SYMBOL(cacos, , ) +SYMBOL(cacosf, , ) +SYMBOL(cacosh, , ) +SYMBOL(cacoshf, , ) +SYMBOL(cacoshl, , ) +SYMBOL(cacosl, , ) +SYMBOL(call_once, , ) +SYMBOL(calloc, , ) +SYMBOL(carg, , ) +SYMBOL(cargf, , ) +SYMBOL(cargl, , ) +SYMBOL(casin, , ) +SYMBOL(casinf, , ) +SYMBOL(casinh, , ) +SYMBOL(casinhf, , ) +SYMBOL(casinhl, , ) +SYMBOL(casinl, , ) +SYMBOL(catan, , ) +SYMBOL(catanf, , ) +SYMBOL(catanh, , ) +SYMBOL(catanhf, , ) +SYMBOL(catanhl, , ) +SYMBOL(catanl, , ) +SYMBOL(cbrt, , ) +SYMBOL(cbrtf, , ) +SYMBOL(cbrtl, , ) +SYMBOL(ccos, , ) +SYMBOL(ccosf, , ) +SYMBOL(ccosh, , ) +SYMBOL(ccoshf, , ) +SYMBOL(ccoshl, , ) +SYMBOL(ccosl, , ) +SYMBOL(ceil, , ) +SYMBOL(ceilf, , ) +SYMBOL(ceill, , ) +SYMBOL(cexp, , ) +SYMBOL(cexpf, , ) +SYMBOL(cexpl, , ) +SYMBOL(char16_t, , ) +SYMBOL(char32_t, , ) +SYMBOL(cimag, , ) +SYMBOL(cimagf, , ) +SYMBOL(cimagl, , ) +SYMBOL(clearerr, , ) +SYMBOL(clock, , ) +SYMBOL(clock_t, , ) +SYMBOL(clog, , ) +SYMBOL(clogf, , ) +SYMBOL(clogl, , ) +SYMBOL(cnd_broadcast, , ) +SYMBOL(cnd_destroy, , ) +SYMBOL(cnd_init, , ) +SYMBOL(cnd_signal, , ) +SYMBOL(cnd_t, , ) +SYMBOL(cnd_timedwait, , ) +SYMBOL(cnd_wait, , ) +SYMBOL(compl, , ) +SYMBOL(complex, , ) +SYMBOL(conj, , ) +SYMBOL(conjf, , ) +SYMBOL(conjl, , ) +SYMBOL(constraint_handler_t, , ) +SYMBOL(copysign, , ) +SYMBOL(copysignf, , ) +SYMBOL(copysignl, , ) +SYMBOL(cos, , ) +SYMBOL(cosf, , ) +SYMBOL(cosh, , ) +SYMBOL(coshf, , ) +SYMBOL(coshl, , ) +SYMBOL(cosl, , ) +SYMBOL(cpow, , ) +SYMBOL(cpowf, , ) +SYMBOL(cpowl, , ) +SYMBOL(cproj, , ) +SYMBOL(cprojf, , ) +SYMBOL(cprojl, , ) +SYMBOL(creal, , ) +SYMBOL(crealf, , ) +SYMBOL(creall, , ) +SYMBOL(csin, , ) +SYMBOL(csinf, , ) +SYMBOL(csinh, , ) +SYMBOL(csinhf, , ) +SYMBOL(csinhl, , ) +SYMBOL(csinl, , ) +SYMBOL(csqrt, , ) +SYMBOL(csqrtf, , ) +SYMBOL(csqrtl, , ) +SYMBOL(ctan, , ) +SYMBOL(ctanf, , ) +SYMBOL(ctanh, , ) +SYMBOL(ctanhf, , ) +SYMBOL(ctanhl, , ) +SYMBOL(ctanl, , ) +SYMBOL(ctime, , ) +SYMBOL(ctime_s, , ) +SYMBOL(difftime, , ) +SYMBOL(double_t, , ) +SYMBOL(erf, , ) +SYMBOL(erfc, , ) +SYMBOL(erfcf, , ) +SYMBOL(erfcl, , ) +SYMBOL(erff, , ) +SYMBOL(erfl, , ) +SYMBOL(errno, , ) +SYMBOL(exit, , ) +SYMBOL(exp, , ) +SYMBOL(exp2, , ) +SYMBOL(exp2f, , ) +SYMBOL(exp2l, , ) +SYMBOL(expf, , ) +SYMBOL(expl, , ) +SYMBOL(expm1, , ) +SYMBOL(expm1f, , ) +SYMBOL(expm1l, , ) +SYMBOL(fabs, , ) +SYMBOL(fabsf, , ) +SYMBOL(fabsl, , ) +SYMBOL(fclose, , ) +SYMBOL(fdim, , ) +SYMBOL(fdimf, , ) +SYMBOL(fdiml, , ) +SYMBOL(feclearexcept, , ) +SYMBOL(fegetenv, , ) +SYMBOL(fegetexceptflag, , ) +SYMBOL(fegetround, , ) +SYMBOL(feholdexcept, , ) +SYMBOL(fenv_t, , ) +SYMBOL(feof, , ) +SYMBOL(feraiseexcept, , ) +SYMBOL(ferror, , ) +SYMBOL(fesetenv, , ) +SYMBOL(fesetexceptflag, , ) +SYMBOL(fesetround, , ) +SYMBOL(fetestexcept, , ) +SYMBOL(feupdateenv, , ) +SYMBOL(fexcept_t, , ) +SYMBOL(fflush, , ) +SYMBOL(fgetc, , ) +SYMBOL(fgetpos, , ) +SYMBOL(fgets, , ) +SYMBOL(fgetwc, , ) +SYMBOL(fgetws, , ) +SYMBOL(float_t, , ) +SYMBOL(floor, , ) +SYMBOL(floorf, , ) +SYMBOL(floorl, , ) +SYMBOL(fma, , ) +SYMBOL(fmaf, , ) +SYMBOL(fmal, , ) +SYMBOL(fmax, , ) +SYMBOL(fmaxf, , ) +SYMBOL(fmaxl, , ) +SYMBOL(fmin, , ) +SYMBOL(fminf, , ) +SYMBOL(fminl, , ) +SYMBOL(fmod, , ) +SYMBOL(fmodf, , ) +SYMBOL(fmodl, , ) +SYMBOL(fopen, , ) +SYMBOL(fopen_s, , ) +SYMBOL(fpclassify, , ) +SYMBOL(fpos_t, , ) +SYMBOL(fprintf, , ) +SYMBOL(fprintf_s, , ) +SYMBOL(fputc, , ) +SYMBOL(fputs, , ) +SYMBOL(fputwc, , ) +SYMBOL(fputws, , ) +SYMBOL(fread, , ) +SYMBOL(free, , ) +SYMBOL(freopen, , ) +SYMBOL(freopen_s, , ) +SYMBOL(frexp, , ) +SYMBOL(frexpf, , ) +SYMBOL(frexpl, , ) +SYMBOL(fscanf, , ) +SYMBOL(fscanf_s, , ) +SYMBOL(fseek, , ) +SYMBOL(fsetpos, , ) +SYMBOL(ftell, , ) +SYMBOL(fwide, , ) +SYMBOL(fwprintf, , ) +SYMBOL(fwprintf_s, , ) +SYMBOL(fwrite, , ) +SYMBOL(fwscanf, , ) +SYMBOL(fwscanf_s, , ) +SYMBOL(getc, , ) +SYMBOL(getchar, , ) +SYMBOL(getenv, , ) +SYMBOL(getenv_s, , ) +SYMBOL(gets, , ) +SYMBOL(gets_s, , ) +SYMBOL(getwc, , ) +SYMBOL(getwchar, , ) +SYMBOL(gmtime, , ) +SYMBOL(gmtime_s, , ) +SYMBOL(hypot, , ) +SYMBOL(hypotf, , ) +SYMBOL(hypotl, , ) +SYMBOL(ignore_handler_s, , ) +SYMBOL(ilogb, , ) +SYMBOL(ilogbf, , ) +SYMBOL(ilogbl, , ) +SYMBOL(imaginary, , ) +SYMBOL(imaxabs, , ) +SYMBOL(int16_t, , ) +SYMBOL(int32_t, , ) +SYMBOL(int64_t, , ) +SYMBOL(int8_t, , ) +SYMBOL(int_fast16_t, , ) +SYMBOL(int_fast32_t, , ) +SYMBOL(int_fast64_t, , ) +SYMBOL(int_fast8_t, , ) +SYMBOL(int_least16_t, , ) +SYMBOL(int_least32_t, , ) +SYMBOL(int_least64_t, , ) +SYMBOL(int_least8_t, , ) +SYMBOL(intmax_t, , ) +SYMBOL(intptr_t, , ) +SYMBOL(isalnum, , ) +SYMBOL(isalpha, , ) +SYMBOL(isblank, , ) +SYMBOL(iscntrl, , ) +SYMBOL(isdigit, , ) +SYMBOL(isfinite, , ) +SYMBOL(isgraph, , ) +SYMBOL(isgreater, , ) +SYMBOL(isgreaterequal, , ) +SYMBOL(isinf, , ) +SYMBOL(isless, , ) +SYMBOL(islessequal, , ) +SYMBOL(islessgreater, , ) +SYMBOL(islower, , ) +SYMBOL(isnan, , ) +SYMBOL(isnormal, , ) +SYMBOL(isprint, , ) +SYMBOL(ispunct, , ) +SYMBOL(isspace, , ) +SYMBOL(isunordered, , ) +SYMBOL(isupper, , ) +SYMBOL(iswalnum, , ) +SYMBOL(iswalpha, , ) +SYMBOL(iswblank, , ) +SYMBOL(iswcntrl, , ) +SYMBOL(iswctype, , ) +SYMBOL(iswdigit, , ) +SYMBOL(iswgraph, , ) +SYMBOL(iswlower, , ) +SYMBOL(iswprint, , ) +SYMBOL(iswpunct, , ) +SYMBOL(iswspace, , ) +SYMBOL(iswupper, , ) +SYMBOL(iswxdigit, , ) +SYMBOL(isxdigit, , ) +SYMBOL(jmp_buf, , ) +SYMBOL(kill_dependency, , ) +SYMBOL(labs, , ) +SYMBOL(lconv, , ) +SYMBOL(ldexp, , ) +SYMBOL(ldexpf, , ) +SYMBOL(ldexpl, , ) +SYMBOL(lgamma, , ) +SYMBOL(lgammaf, , ) +SYMBOL(lgammal, , ) +SYMBOL(llabs, , ) +SYMBOL(llrint, , ) +SYMBOL(llrintf, , ) +SYMBOL(llrintl, , ) +SYMBOL(llround, , ) +SYMBOL(llroundf, , ) +SYMBOL(llroundl, , ) +SYMBOL(localeconv, , ) +SYMBOL(localtime, , ) +SYMBOL(localtime_s, , ) +SYMBOL(log, , ) +SYMBOL(log10, , ) +SYMBOL(log10f, , ) +SYMBOL(log10l, , ) +SYMBOL(log1p, , ) +SYMBOL(log1pf, , ) +SYMBOL(log1pl, , ) +SYMBOL(log2, , ) +SYMBOL(log2f, , ) +SYMBOL(log2l, , ) +SYMBOL(logb, , ) +SYMBOL(logbf, , ) +SYMBOL(logbl, , ) +SYMBOL(logf, , ) +SYMBOL(logl, , ) +SYMBOL(longjmp, , ) +SYMBOL(lrint, , ) +SYMBOL(lrintf, , ) +SYMBOL(lrintl, , ) +SYMBOL(lround, , ) +SYMBOL(lroundf, , ) +SYMBOL(lroundl, , ) +SYMBOL(malloc, , ) +SYMBOL(math_errhandling, , ) +SYMBOL(max_align_t, , ) +SYMBOL(mblen, , ) +SYMBOL(mbrlen, , ) +SYMBOL(mbrtoc16, , ) +SYMBOL(mbrtoc32, , ) +SYMBOL(mbrtowc, , ) +SYMBOL(mbsinit, , ) +SYMBOL(mbsrtowcs, , ) +SYMBOL(mbsrtowcs_s, , ) +SYMBOL(mbstowcs, , ) +SYMBOL(mbstowcs_s, , ) +SYMBOL(mbtowc, , ) +SYMBOL(memchr, , ) +SYMBOL(memcmp, , ) +SYMBOL(memcpy, , ) +SYMBOL(memcpy_s, , ) +SYMBOL(memmove, , ) +SYMBOL(memmove_s, , ) +SYMBOL(memory_order, , ) +SYMBOL(memory_order_acq_rel, , ) +SYMBOL(memory_order_acquire, , ) +SYMBOL(memory_order_consume, , ) +SYMBOL(memory_order_relaxed, , ) +SYMBOL(memory_order_release, , ) +SYMBOL(memory_order_seq_cst, , ) +SYMBOL(memset, , ) +SYMBOL(memset_s, , ) +SYMBOL(mktime, , ) +SYMBOL(modf, , ) +SYMBOL(modff, , ) +SYMBOL(modfl, , ) +SYMBOL(mtx_destroy, , ) +SYMBOL(mtx_init, , ) +SYMBOL(mtx_lock, , ) +SYMBOL(mtx_plain, , ) +SYMBOL(mtx_recursive, , ) +SYMBOL(mtx_t, , ) +SYMBOL(mtx_timed, , ) +SYMBOL(mtx_timedlock, , ) +SYMBOL(mtx_trylock, , ) +SYMBOL(mtx_unlock, , ) +SYMBOL(nan, , ) +SYMBOL(nanf, , ) +SYMBOL(nanl, , ) +SYMBOL(nearbyint, , ) +SYMBOL(nearbyintf, , ) +SYMBOL(nearbyintl, , ) +SYMBOL(nextafter, , ) +SYMBOL(nextafterf, , ) +SYMBOL(nextafterl, , ) +SYMBOL(nexttoward, , ) +SYMBOL(nexttowardf, , ) +SYMBOL(nexttowardl, , ) +SYMBOL(noreturn, , ) +SYMBOL(not, , ) +SYMBOL(not_eq, , ) +SYMBOL(offsetof, , ) +SYMBOL(once_flag, , ) +SYMBOL(or, , ) +SYMBOL(or_eq, , ) +SYMBOL(perror, , ) +SYMBOL(pow, , ) +SYMBOL(powf, , ) +SYMBOL(powl, , ) +SYMBOL(printf, , ) +SYMBOL(printf_s, , ) +SYMBOL(ptrdiff_t, , ) +SYMBOL(putc, , ) +SYMBOL(putchar, , ) +SYMBOL(puts, , ) +SYMBOL(putwc, , ) +SYMBOL(putwchar, , ) +SYMBOL(qsort, , ) +SYMBOL(qsort_s, , ) +SYMBOL(quick_exit, , ) +SYMBOL(raise, , ) +SYMBOL(rand, , ) +SYMBOL(realloc, , ) +SYMBOL(remainder, , ) +SYMBOL(remainderf, , ) +SYMBOL(remainderl, , ) +SYMBOL(remove, , ) +SYMBOL(remquo, , ) +SYMBOL(remquof, , ) +SYMBOL(remquol, , ) +SYMBOL(rename, , ) +SYMBOL(rewind, , ) +SYMBOL(rint, , ) +SYMBOL(rintf, , ) +SYMBOL(rintl, , ) +SYMBOL(round, , ) +SYMBOL(roundf, , ) +SYMBOL(roundl, , ) +SYMBOL(rsize_t, , ) +SYMBOL(scalbln, , ) +SYMBOL(scalblnf, , ) +SYMBOL(scalblnl, , ) +SYMBOL(scalbn, , ) +SYMBOL(scalbnf, , ) +SYMBOL(scalbnl, , ) +SYMBOL(scanf, , ) +SYMBOL(scanf_s, , ) +SYMBOL(set_constraint_handler_s, , ) +SYMBOL(setbuf, , ) +SYMBOL(setjmp, , ) +SYMBOL(setlocale, , ) +SYMBOL(setvbuf, , ) +SYMBOL(sig_atomic_t, , ) +SYMBOL(signal, , ) +SYMBOL(signbit, , ) +SYMBOL(sin, , ) +SYMBOL(sinf, , ) +SYMBOL(sinh, , ) +SYMBOL(sinhf, , ) +SYMBOL(sinhl, , ) +SYMBOL(sinl, , ) +SYMBOL(snprintf, , ) +SYMBOL(snprintf_s, , ) +SYMBOL(snwprintf_s, , ) +SYMBOL(sprintf, , ) +SYMBOL(sprintf_s, , ) +SYMBOL(sqrt, , ) +SYMBOL(sqrtf, , ) +SYMBOL(sqrtl, , ) +SYMBOL(srand, , ) +SYMBOL(sscanf, , ) +SYMBOL(sscanf_s, , ) +SYMBOL(static_assert, , ) +SYMBOL(stderr, , ) +SYMBOL(stdin, , ) +SYMBOL(stdout, , ) +SYMBOL(strcat, , ) +SYMBOL(strcat_s, , ) +SYMBOL(strchr, , ) +SYMBOL(strcmp, , ) +SYMBOL(strcoll, , ) +SYMBOL(strcpy, , ) +SYMBOL(strcpy_s, , ) +SYMBOL(strcspn, , ) +SYMBOL(strerror, , ) +SYMBOL(strerror_s, , ) +SYMBOL(strerrorlen_s, , ) +SYMBOL(strftime, , ) +SYMBOL(strlen, , ) +SYMBOL(strncat, , ) +SYMBOL(strncat_s, , ) +SYMBOL(strncmp, , ) +SYMBOL(strncpy, , ) +SYMBOL(strncpy_s, , ) +SYMBOL(strnlen_s, , ) +SYMBOL(strpbrk, , ) +SYMBOL(strrchr, , ) +SYMBOL(strspn, , ) +SYMBOL(strstr, , ) +SYMBOL(strtod, , ) +SYMBOL(strtof, , ) +SYMBOL(strtoimax, , ) +SYMBOL(strtok, , ) +SYMBOL(strtok_s, , ) +SYMBOL(strtol, , ) +SYMBOL(strtold, , ) +SYMBOL(strtoll, , ) +SYMBOL(strtoul, , ) +SYMBOL(strtoull, , ) +SYMBOL(strtoumax, , ) +SYMBOL(strxfrm, , ) +SYMBOL(swprintf, , ) +SYMBOL(swprintf_s, , ) +SYMBOL(swscanf, , ) +SYMBOL(swscanf_s, , ) +SYMBOL(system, , ) +SYMBOL(tan, , ) +SYMBOL(tanf, , ) +SYMBOL(tanh, , ) +SYMBOL(tanhf, , ) +SYMBOL(tanhl, , ) +SYMBOL(tanl, , ) +SYMBOL(tgamma, , ) +SYMBOL(tgammaf, , ) +SYMBOL(tgammal, , ) +SYMBOL(thrd_busy, , ) +SYMBOL(thrd_create, , ) +SYMBOL(thrd_current, , ) +SYMBOL(thrd_detach, , ) +SYMBOL(thrd_equal, , ) +SYMBOL(thrd_error, , ) +SYMBOL(thrd_join, , ) +SYMBOL(thrd_nomem, , ) +SYMBOL(thrd_sleep, , ) +SYMBOL(thrd_start_t, , ) +SYMBOL(thrd_success, , ) +SYMBOL(thrd_t, , ) +SYMBOL(thrd_timedout, , ) +SYMBOL(thrd_yield, , ) +SYMBOL(thread_local, , ) +SYMBOL(time, , ) +SYMBOL(time_t, , ) +SYMBOL(timespec, , ) +SYMBOL(timespec_get, , ) +SYMBOL(tm, , ) +SYMBOL(tmpfile, , ) +SYMBOL(tmpfile_s, , ) +SYMBOL(tmpnam, , ) +SYMBOL(tmpnam_s, , ) +SYMBOL(tolower, , ) +SYMBOL(toupper, , ) +SYMBOL(towctrans, , ) +SYMBOL(towlower, , ) +SYMBOL(towupper, , ) +SYMBOL(trunc, , ) +SYMBOL(truncf, , ) +SYMBOL(truncl, , ) +SYMBOL(tss_create, , ) +SYMBOL(tss_delete, , ) +SYMBOL(tss_dtor_t, , ) +SYMBOL(tss_get, , ) +SYMBOL(tss_set, , ) +SYMBOL(tss_t, , ) +SYMBOL(uint16_t, , ) +SYMBOL(uint32_t, , ) +SYMBOL(uint64_t, , ) +SYMBOL(uint8_t, , ) +SYMBOL(uint_fast16_t, , ) +SYMBOL(uint_fast32_t, , ) +SYMBOL(uint_fast64_t, , ) +SYMBOL(uint_fast8_t, , ) +SYMBOL(uint_least16_t, , ) +SYMBOL(uint_least32_t, , ) +SYMBOL(uint_least64_t, , ) +SYMBOL(uint_least8_t, , ) +SYMBOL(uintmax_t, , ) +SYMBOL(uintptr_t, , ) +SYMBOL(ungetc, , ) +SYMBOL(ungetwc, , ) +SYMBOL(va_arg, , ) +SYMBOL(va_copy, , ) +SYMBOL(va_end, , ) +SYMBOL(va_start, , ) +SYMBOL(vfprintf, , ) +SYMBOL(vfprintf_s, , ) +SYMBOL(vfscanf, , ) +SYMBOL(vfscanf_s, , ) +SYMBOL(vfwprintf, , ) +SYMBOL(vfwprintf_s, , ) +SYMBOL(vfwscanf, , ) +SYMBOL(vfwscanf_s, , ) +SYMBOL(vprintf, , ) +SYMBOL(vprintf_s, , ) +SYMBOL(vscanf, , ) +SYMBOL(vscanf_s, , ) +SYMBOL(vsnprintf, , ) +SYMBOL(vsnprintf_s, , ) +SYMBOL(vsnwprintf_s, , ) +SYMBOL(vsprintf, , ) +SYMBOL(vsprintf_s, , ) +SYMBOL(vsscanf, , ) +SYMBOL(vsscanf_s, , ) +SYMBOL(vswprintf, , ) +SYMBOL(vswprintf_s, , ) +SYMBOL(vswscanf, , ) +SYMBOL(vswscanf_s, , ) +SYMBOL(vwprintf, , ) +SYMBOL(vwprintf_s, , ) +SYMBOL(vwscanf, , ) +SYMBOL(vwscanf_s, , ) +SYMBOL(wchar_t, , ) +SYMBOL(wcrtomb, , ) +SYMBOL(wcrtomb_s, , ) +SYMBOL(wcscat, , ) +SYMBOL(wcscat_s, , ) +SYMBOL(wcschr, , ) +SYMBOL(wcscmp, , ) +SYMBOL(wcscoll, , ) +SYMBOL(wcscpy, , ) +SYMBOL(wcscpy_s, , ) +SYMBOL(wcscspn, , ) +SYMBOL(wcsftime, , ) +SYMBOL(wcslen, , ) +SYMBOL(wcsncat, , ) +SYMBOL(wcsncat_s, , ) +SYMBOL(wcsncmp, , ) +SYMBOL(wcsncpy, , ) +SYMBOL(wcsncpy_s, , ) +SYMBOL(wcsnlen_s, , ) +SYMBOL(wcspbrk, , ) +SYMBOL(wcsrchr, , ) +SYMBOL(wcsrtombs, , ) +SYMBOL(wcsrtombs_s, , ) +SYMBOL(wcsspn, , ) +SYMBOL(wcsstr, , ) +SYMBOL(wcstod, , ) +SYMBOL(wcstof, , ) +SYMBOL(wcstoimax, , ) +SYMBOL(wcstok, , ) +SYMBOL(wcstok_s, , ) +SYMBOL(wcstol, , ) +SYMBOL(wcstold, , ) +SYMBOL(wcstoll, , ) +SYMBOL(wcstombs, , ) +SYMBOL(wcstombs_s, , ) +SYMBOL(wcstoul, , ) +SYMBOL(wcstoull, , ) +SYMBOL(wcstoumax, , ) +SYMBOL(wcsxfrm, , ) +SYMBOL(wctob, , ) +SYMBOL(wctomb, , ) +SYMBOL(wctomb_s, , ) +SYMBOL(wctrans, , ) +SYMBOL(wctrans_t, , ) +SYMBOL(wctype, , ) +SYMBOL(wctype_t, , ) +SYMBOL(wint_t, , ) +SYMBOL(wmemchr, , ) +SYMBOL(wmemcmp, , ) +SYMBOL(wmemcpy, , ) +SYMBOL(wmemcpy_s, , ) +SYMBOL(wmemmove, , ) +SYMBOL(wmemmove_s, , ) +SYMBOL(wmemset, , ) +SYMBOL(wprintf, , ) +SYMBOL(wprintf_s, , ) +SYMBOL(wscanf, , ) +SYMBOL(wscanf_s, , ) +SYMBOL(xor, , ) +SYMBOL(xor_eq, , ) diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp --- a/clang-tools-extra/clangd/ClangdUnit.cpp +++ b/clang-tools-extra/clangd/ClangdUnit.cpp @@ -129,7 +129,6 @@ public: CppFilePreambleCallbacks(PathRef File, PreambleParsedCallback ParsedCallback) : File(File), ParsedCallback(ParsedCallback) { - addSystemHeadersMapping(&CanonIncludes); } IncludeStructure takeIncludes() { return std::move(Includes); } @@ -148,6 +147,7 @@ } void BeforeExecute(CompilerInstance &CI) override { + addSystemHeadersMapping(&CanonIncludes, CI.getLangOpts()); SourceMgr = &CI.getSourceManager(); } @@ -413,7 +413,7 @@ if (Preamble) CanonIncludes = Preamble->CanonIncludes; else - addSystemHeadersMapping(&CanonIncludes); + addSystemHeadersMapping(&CanonIncludes, Clang->getLangOpts()); std::unique_ptr IWYUHandler = collectIWYUHeaderMaps(&CanonIncludes); Clang->getPreprocessor().addCommentHandler(IWYUHandler.get()); diff --git a/clang-tools-extra/clangd/StdSymbolMap.inc b/clang-tools-extra/clangd/StdSymbolMap.inc --- a/clang-tools-extra/clangd/StdSymbolMap.inc +++ b/clang-tools-extra/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! diff --git a/clang-tools-extra/clangd/include-mapping/gen_std.py b/clang-tools-extra/clangd/include-mapping/cppreference_parser.py old mode 100755 new mode 100644 copy from clang-tools-extra/clangd/include-mapping/gen_std.py copy to clang-tools-extra/clangd/include-mapping/cppreference_parser.py --- a/clang-tools-extra/clangd/include-mapping/gen_std.py +++ b/clang-tools-extra/clangd/include-mapping/cppreference_parser.py @@ -1,63 +1,32 @@ -#!/usr/bin/env python -#===- gen_std.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 -# -#===------------------------------------------------------------------------===# - -"""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 -files from cppreference. - -Caveats and FIXMEs: - - only symbols directly in "std" namespace are added, we should also add std's - subnamespace symbols (e.g. chrono). - - symbols with multiple variants or defined in multiple headers aren't added, - e.g. std::move, std::swap - -Usage: - 1. Install BeautifulSoup dependency, see instruction: - https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup - 2. Download cppreference offline HTML files (e.g. html_book_20181028.zip) at - https://en.cppreference.com/w/Cppreference:Archives - 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 -""" - from bs4 import BeautifulSoup, NavigableString -import argparse import collections -import datetime import multiprocessing import os import re import signal import sys -STDGEN_CODE_PREFIX = """\ -//===-- 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 %s). -//===----------------------------------------------------------------------===// -""" - -def HasClass(tag, *classes): + +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) + 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): + +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: @@ -82,14 +51,14 @@ current_headers = [] was_decl = False for row in table.select('tr'): - if HasClass(row, 't-dcl', 't-dsc'): + 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'): + 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: @@ -106,7 +75,7 @@ return headers or all_headers -def ParseIndexPage(index_page_html): +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: @@ -131,23 +100,13 @@ 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): +def _ReadSymbolPage(path, name): with open(path) as f: - return ParseSymbolPage(f.read(), name) + return _ParseSymbolPage(f.read(), name) -def GetSymbols(pool, root_dir, index_page_name, namespace): +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. @@ -163,14 +122,14 @@ 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()): + 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)))) + pool.apply_async(_ReadSymbolPage, (path, symbol_name)))) # Build map from symbol name to a set of headers. symbol_headers = collections.defaultdict(set) @@ -183,39 +142,12 @@ 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 - ) - 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 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::"), - ] +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. @@ -223,29 +155,8 @@ 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)) + symbols.extend(_GetSymbols(pool, root_dir, page_name, namespace)) finally: pool.terminate() pool.join() - - # 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") - cppreference_modified_date = datetime.datetime.fromtimestamp( - os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d') - print STDGEN_CODE_PREFIX % cppreference_modified_date - for symbol in symbols: - if len(symbol.headers) == 1: - # SYMBOL(unqualified_name, namespace, header) - print "SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace, - symbol.headers[0]) - elif len(symbol.headers) == 0: - sys.stderr.write("No header found for symbol %s\n" % symbol.name) - else: - # FIXME: support symbols with multiple headers (e.g. std::move). - sys.stderr.write("Ambiguous header for symbol %s: %s\n" % ( - symbol.name, ', '.join(symbol.headers))) - - -if __name__ == '__main__': - main() + return symbols \ No newline at end of file diff --git a/clang-tools-extra/clangd/include-mapping/gen_std.py b/clang-tools-extra/clangd/include-mapping/gen_std.py --- a/clang-tools-extra/clangd/include-mapping/gen_std.py +++ b/clang-tools-extra/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", "")] + 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) diff --git a/clang-tools-extra/clangd/include-mapping/test.py b/clang-tools-extra/clangd/include-mapping/test.py --- a/clang-tools-extra/clangd/include-mapping/test.py +++ b/clang-tools-extra/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([''])) 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 @@ -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 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 @@ -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) {#NameSpace #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) diff --git a/clang-tools-extra/clangd/index/IndexAction.cpp b/clang-tools-extra/clangd/index/IndexAction.cpp --- a/clang-tools-extra/clangd/index/IndexAction.cpp +++ b/clang-tools-extra/clangd/index/IndexAction.cpp @@ -126,6 +126,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)); @@ -194,7 +195,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), 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 @@ -15,7 +15,9 @@ 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")); diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp --- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ b/clang-tools-extra/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,