Index: clangd/StdSymbolMap.inc =================================================================== --- clangd/StdSymbolMap.inc +++ clangd/StdSymbolMap.inc @@ -134,12 +134,15 @@ SYMBOL(bad_variant_access, std::, ) SYMBOL(bad_weak_ptr, std::, ) SYMBOL(basic_common_reference, std::, ) +SYMBOL(basic_filebuf, std::, ) SYMBOL(basic_fstream, std::, ) SYMBOL(basic_ifstream, std::, ) SYMBOL(basic_ios, std::, ) SYMBOL(basic_iostream, std::, ) +SYMBOL(basic_istream, std::, ) SYMBOL(basic_istringstream, std::, ) SYMBOL(basic_ofstream, std::, ) +SYMBOL(basic_ostream, std::, ) SYMBOL(basic_ostringstream, std::, ) SYMBOL(basic_osyncstream, std::, ) SYMBOL(basic_regex, std::, ) @@ -193,6 +196,7 @@ SYMBOL(codecvt, std::, ) SYMBOL(codecvt_base, std::, ) SYMBOL(codecvt_byname, std::, ) +SYMBOL(codecvt_mode, std::, ) SYMBOL(codecvt_utf16, std::, ) SYMBOL(codecvt_utf8, std::, ) SYMBOL(codecvt_utf8_utf16, std::, ) @@ -245,6 +249,7 @@ SYMBOL(declare_reachable, std::, ) SYMBOL(declval, std::, ) SYMBOL(default_delete, std::, ) +SYMBOL(default_random_engine, std::, ) SYMBOL(default_searcher, std::, ) SYMBOL(defaultfloat, std::, ) SYMBOL(defer_lock, std::, ) @@ -264,8 +269,10 @@ SYMBOL(disjunction, std::, ) SYMBOL(disjunction_v, std::, ) SYMBOL(distance, std::, ) +SYMBOL(div_t, std::, ) SYMBOL(divides, std::, ) SYMBOL(domain_error, std::, ) +SYMBOL(double_t, std::, ) SYMBOL(dynamic_extent, std::, ) SYMBOL(dynamic_pointer_cast, std::, ) SYMBOL(emit_on_flush, std::, ) @@ -298,6 +305,7 @@ SYMBOL(extent, std::, ) SYMBOL(extent_v, std::, ) SYMBOL(extreme_value_distribution, std::, ) +SYMBOL(fabs, std::, ) SYMBOL(false_type, std::, ) SYMBOL(fclose, std::, ) SYMBOL(fdim, std::, ) @@ -323,6 +331,7 @@ SYMBOL(fgets, std::, ) SYMBOL(fgetwc, std::, ) SYMBOL(fgetws, std::, ) +SYMBOL(filebuf, std::, ) SYMBOL(fill, std::, ) SYMBOL(fill_n, std::, ) SYMBOL(find, std::, ) @@ -334,6 +343,7 @@ SYMBOL(fixed, std::, ) SYMBOL(float_denorm_style, std::, ) SYMBOL(float_round_style, std::, ) +SYMBOL(float_t, std::, ) SYMBOL(floor, std::, ) SYMBOL(floor2, std::, ) SYMBOL(flush, std::, ) @@ -422,6 +432,9 @@ SYMBOL(ignore, std::, ) SYMBOL(ilogb, std::, ) SYMBOL(imag, std::, ) +SYMBOL(imaxabs, std::, ) +SYMBOL(imaxdiv, std::, ) +SYMBOL(imaxdiv_t, std::, ) SYMBOL(in_place, std::, ) SYMBOL(in_place_index, std::, ) SYMBOL(in_place_index_t, std::, ) @@ -440,6 +453,8 @@ SYMBOL(integer_sequence, std::, ) SYMBOL(integral_constant, std::, ) SYMBOL(internal, std::, ) +SYMBOL(intmax_t, std::, ) +SYMBOL(intptr_t, std::, ) SYMBOL(invalid_argument, std::, ) SYMBOL(invoke, std::, ) SYMBOL(invoke_result, std::, ) @@ -619,6 +634,7 @@ SYMBOL(isnan, std::, ) SYMBOL(isnormal, std::, ) SYMBOL(ispow2, std::, ) +SYMBOL(istream, std::, ) SYMBOL(istream_iterator, std::, ) SYMBOL(istreambuf_iterator, std::, ) SYMBOL(istringstream, std::, ) @@ -642,11 +658,15 @@ SYMBOL(jmp_buf, std::, ) SYMBOL(kill_dependency, std::, ) SYMBOL(kilo, std::, ) +SYMBOL(knuth_b, std::, ) +SYMBOL(labs, std::, ) SYMBOL(launch, std::, ) SYMBOL(launder, std::, ) SYMBOL(lcm, std::, ) SYMBOL(lconv, std::, ) SYMBOL(ldexp, std::, ) +SYMBOL(ldiv, std::, ) +SYMBOL(ldiv_t, std::, ) SYMBOL(left, std::, ) SYMBOL(length_error, std::, ) SYMBOL(less, std::, ) @@ -656,6 +676,9 @@ SYMBOL(lgamma, std::, ) SYMBOL(linear_congruential_engine, std::, ) SYMBOL(list, std::, ) +SYMBOL(llabs, std::, ) +SYMBOL(lldiv, std::, ) +SYMBOL(lldiv_t, std::, ) SYMBOL(llrint, std::, ) SYMBOL(llround, std::, ) SYMBOL(locale, std::, ) @@ -731,6 +754,8 @@ SYMBOL(min_element, std::, ) SYMBOL(minmax, std::, ) SYMBOL(minmax_element, std::, ) +SYMBOL(minstd_rand, std::, ) +SYMBOL(minstd_rand0, std::, ) SYMBOL(minus, std::, ) SYMBOL(mismatch, std::, ) SYMBOL(mktime, std::, ) @@ -745,6 +770,8 @@ SYMBOL(move_backward, std::, ) SYMBOL(move_if_noexcept, std::, ) SYMBOL(move_iterator, std::, ) +SYMBOL(mt19937, std::, ) +SYMBOL(mt19937_64, std::, ) SYMBOL(multimap, std::, ) SYMBOL(multiplies, std::, ) SYMBOL(multiset, std::, ) @@ -793,6 +820,7 @@ SYMBOL(ofstream, std::, ) SYMBOL(once_flag, std::, ) SYMBOL(optional, std::, ) +SYMBOL(ostream, std::, ) SYMBOL(ostream_iterator, std::, ) SYMBOL(ostreambuf_iterator, std::, ) SYMBOL(ostringstream, std::, ) @@ -851,6 +879,10 @@ SYMBOL(range_error, std::, ) SYMBOL(rank, std::, ) SYMBOL(rank_v, std::, ) +SYMBOL(ranlux24, std::, ) +SYMBOL(ranlux24_base, std::, ) +SYMBOL(ranlux48, std::, ) +SYMBOL(ranlux48_base, std::, ) SYMBOL(ratio, std::, ) SYMBOL(ratio_add, std::, ) SYMBOL(ratio_divide, std::, ) @@ -1086,6 +1118,8 @@ SYMBOL(u32streampos, std::, ) SYMBOL(u32string, std::, ) SYMBOL(u32string_view, std::, ) +SYMBOL(uintmax_t, std::, ) +SYMBOL(uintptr_t, std::, ) SYMBOL(uncaught_exceptions, std::, ) SYMBOL(undeclare_no_pointers, std::, ) SYMBOL(undeclare_reachable, std::, ) @@ -1184,17 +1218,21 @@ SYMBOL(wctob, std::, ) SYMBOL(wctomb, std::, ) SYMBOL(wctrans, std::, ) +SYMBOL(wctrans_t, std::, ) SYMBOL(wctype, std::, ) +SYMBOL(wctype_t, std::, ) SYMBOL(weak_equal, std::, ) SYMBOL(weak_equality, std::, ) SYMBOL(weak_order, std::, ) SYMBOL(weak_ordering, std::, ) SYMBOL(weak_ptr, std::, ) SYMBOL(weibull_distribution, std::, ) +SYMBOL(wfilebuf, std::, ) SYMBOL(wfstream, std::, ) SYMBOL(wifstream, std::, ) SYMBOL(wios, std::, ) SYMBOL(wiostream, std::, ) +SYMBOL(wistream, std::, ) SYMBOL(wistringstream, std::, ) SYMBOL(wmemchr, std::, ) SYMBOL(wmemcmp, std::, ) @@ -1202,6 +1240,7 @@ SYMBOL(wmemmove, std::, ) SYMBOL(wmemset, std::, ) SYMBOL(wofstream, std::, ) +SYMBOL(wostream, std::, ) SYMBOL(wostringstream, std::, ) SYMBOL(wosyncstream, std::, ) SYMBOL(wprintf, std::, ) Index: clangd/include-mapping/gen_std.py =================================================================== --- clangd/include-mapping/gen_std.py +++ clangd/include-mapping/gen_std.py @@ -35,6 +35,7 @@ import datetime import multiprocessing import os +import re import signal import sys @@ -50,7 +51,13 @@ //===----------------------------------------------------------------------===// """ -def ParseSymbolPage(symbol_page_html): +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: @@ -61,17 +68,43 @@ Returns a list of headers. """ - headers = [] + headers = set() + all_headers = set() soup = BeautifulSoup(symbol_page_html, "html.parser") - # "Defined in header " are defined in or - # . - for header_tr in soup.select('tr.t-dcl-header,tr.t-dsc-header'): - if "Defined in header " in header_tr.text: - # The interesting header content (e.g. ) is wrapped in . - for header_code in header_tr.find_all("code"): - headers.append(header_code.text) - return headers + # 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 + # Declaration is in the first cell. + text = row.find('td').text + # Decl may not be for the symbol name we're looking for. + if not re.search("\\b%s\\b" % symbol_name, text): + 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): @@ -106,7 +139,7 @@ def ReadSymbolPage(path, name): with open(path) as f: - return ParseSymbolPage(f.read()) + return ParseSymbolPage(f.read(), name) def GetSymbols(pool, root_dir, index_page_name, namespace): Index: clangd/include-mapping/test.py =================================================================== --- clangd/include-mapping/test.py +++ clangd/include-mapping/test.py @@ -46,9 +46,13 @@ + + void foo() + this is matched + """ - self.assertEqual(ParseSymbolPage(html), ['']) + self.assertEqual(ParseSymbolPage(html, 'foo'), set([''])) def testParseSymbolPage_MulHeaders(self): @@ -63,6 +67,10 @@ + + void bar() + this mentions foo, but isn't matched +
Defined in header <cstdio>
@@ -75,10 +83,14 @@ + + void foo() + this is matched + """ - self.assertEqual(ParseSymbolPage(html), - ['', '', '']) + self.assertEqual(ParseSymbolPage(html, "foo"), + set(['', ''])) def testParseSymbolPage_MulHeadersInSameDiv(self): @@ -86,6 +98,7 @@ # Defined in header # Defined in header html = """ + + + + + +
Defined in header <algorithm>
@@ -93,8 +106,14 @@
void foo()this is matched
""" - self.assertEqual(ParseSymbolPage(html), ['', '']) + self.assertEqual(ParseSymbolPage(html, "foo"), + set(['', ''])) if __name__ == '__main__':