diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc --- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc +++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc @@ -143,23 +143,43 @@ SYMBOL(bad_weak_ptr, std::, ) SYMBOL(basic_common_reference, std::, ) SYMBOL(basic_filebuf, std::, ) +SYMBOL(basic_filebuf, std::, ) SYMBOL(basic_fstream, std::, ) +SYMBOL(basic_fstream, std::, ) SYMBOL(basic_ifstream, std::, ) +SYMBOL(basic_ifstream, std::, ) SYMBOL(basic_ios, std::, ) +SYMBOL(basic_ios, std::, ) +SYMBOL(basic_ios, std::, ) SYMBOL(basic_iostream, std::, ) +SYMBOL(basic_iostream, std::, ) +SYMBOL(basic_iostream, std::, ) SYMBOL(basic_istream, std::, ) +SYMBOL(basic_istream, std::, ) +SYMBOL(basic_istream, std::, ) SYMBOL(basic_istringstream, std::, ) +SYMBOL(basic_istringstream, std::, ) SYMBOL(basic_ofstream, std::, ) +SYMBOL(basic_ofstream, std::, ) SYMBOL(basic_ostream, std::, ) +SYMBOL(basic_ostream, std::, ) +SYMBOL(basic_ostream, std::, ) SYMBOL(basic_ostringstream, std::, ) +SYMBOL(basic_ostringstream, std::, ) SYMBOL(basic_osyncstream, std::, ) +SYMBOL(basic_osyncstream, std::, ) SYMBOL(basic_regex, std::, ) SYMBOL(basic_streambuf, std::, ) +SYMBOL(basic_streambuf, std::, ) +SYMBOL(basic_streambuf, std::, ) SYMBOL(basic_string, std::, ) SYMBOL(basic_string_view, std::, ) SYMBOL(basic_stringbuf, std::, ) +SYMBOL(basic_stringbuf, std::, ) SYMBOL(basic_stringstream, std::, ) +SYMBOL(basic_stringstream, std::, ) SYMBOL(basic_syncbuf, std::, ) +SYMBOL(basic_syncbuf, std::, ) SYMBOL(begin, std::, ) SYMBOL(bernoulli_distribution, std::, ) SYMBOL(bidirectional_iterator_tag, std::, ) @@ -174,6 +194,7 @@ SYMBOL(bitset, std::, ) SYMBOL(bool_constant, std::, ) SYMBOL(boolalpha, std::, ) +SYMBOL(boolalpha, std::, ) SYMBOL(boyer_moore_horspool_searcher, std::, ) SYMBOL(boyer_moore_searcher, std::, ) SYMBOL(bsearch, std::, ) @@ -251,6 +272,7 @@ SYMBOL(cv_status, std::, ) SYMBOL(data, std::, ) SYMBOL(dec, std::, ) +SYMBOL(dec, std::, ) SYMBOL(deca, std::, ) SYMBOL(decay, std::, ) SYMBOL(decay_t, std::, ) @@ -262,6 +284,7 @@ SYMBOL(default_random_engine, std::, ) SYMBOL(default_searcher, std::, ) SYMBOL(defaultfloat, std::, ) +SYMBOL(defaultfloat, std::, ) SYMBOL(defer_lock, std::, ) SYMBOL(defer_lock_t, std::, ) SYMBOL(denorm_absent, std::, ) @@ -286,6 +309,7 @@ SYMBOL(dynamic_extent, std::, ) SYMBOL(dynamic_pointer_cast, std::, ) SYMBOL(emit_on_flush, std::, ) +SYMBOL(emit_on_flush, std::, ) SYMBOL(empty, std::, ) SYMBOL(enable_if, std::, ) SYMBOL(enable_if_t, std::, ) @@ -293,7 +317,9 @@ SYMBOL(end, std::, ) SYMBOL(endian, std::, ) SYMBOL(endl, std::, ) +SYMBOL(endl, std::, ) SYMBOL(ends, std::, ) +SYMBOL(ends, std::, ) SYMBOL(equal, std::, ) SYMBOL(equal_range, std::, ) SYMBOL(equal_to, std::, ) @@ -342,6 +368,8 @@ SYMBOL(fgetwc, std::, ) SYMBOL(fgetws, std::, ) SYMBOL(filebuf, std::, ) +SYMBOL(filebuf, std::, ) +SYMBOL(filebuf, std::, ) SYMBOL(fill, std::, ) SYMBOL(fill_n, std::, ) SYMBOL(find, std::, ) @@ -351,13 +379,16 @@ SYMBOL(find_if_not, std::, ) SYMBOL(fisher_f_distribution, std::, ) SYMBOL(fixed, std::, ) +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::, ) +SYMBOL(flush, std::, ) SYMBOL(flush_emit, std::, ) +SYMBOL(flush_emit, std::, ) SYMBOL(fma, std::, ) SYMBOL(fmax, std::, ) SYMBOL(fmin, std::, ) @@ -371,6 +402,8 @@ SYMBOL(forward_list, std::, ) SYMBOL(fpclassify, std::, ) SYMBOL(fpos, std::, ) +SYMBOL(fpos, std::, ) +SYMBOL(fpos, std::, ) SYMBOL(fpos_t, std::, ) SYMBOL(fprintf, std::, ) SYMBOL(fputc, std::, ) @@ -388,6 +421,7 @@ SYMBOL(fseek, std::, ) SYMBOL(fsetpos, std::, ) SYMBOL(fstream, std::, ) +SYMBOL(fstream, std::, ) SYMBOL(ftell, std::, ) SYMBOL(function, std::, ) SYMBOL(future, std::, ) @@ -434,11 +468,14 @@ SYMBOL(hash, std::, ) SYMBOL(hecto, std::, ) SYMBOL(hex, std::, ) +SYMBOL(hex, std::, ) SYMBOL(hexfloat, std::, ) +SYMBOL(hexfloat, std::, ) SYMBOL(holds_alternative, std::, ) SYMBOL(hypot, std::, ) SYMBOL(identity, std::, ) SYMBOL(ifstream, std::, ) +SYMBOL(ifstream, std::, ) SYMBOL(ignore, std::, ) SYMBOL(ilogb, std::, ) SYMBOL(imag, std::, ) @@ -476,6 +513,7 @@ SYMBOL(integer_sequence, std::, ) SYMBOL(integral_constant, std::, ) SYMBOL(internal, std::, ) +SYMBOL(internal, std::, ) SYMBOL(intmax_t, std::, ) SYMBOL(intptr_t, std::, ) SYMBOL(invalid_argument, std::, ) @@ -483,10 +521,17 @@ SYMBOL(invoke_result, std::, ) SYMBOL(invoke_result_t, std::, ) SYMBOL(io_errc, std::, ) +SYMBOL(io_errc, std::, ) SYMBOL(ios, std::, ) +SYMBOL(ios, std::, ) +SYMBOL(ios, std::, ) SYMBOL(ios_base, std::, ) +SYMBOL(ios_base, std::, ) SYMBOL(iostream, std::, ) +SYMBOL(iostream, std::, ) +SYMBOL(iostream, std::, ) SYMBOL(iostream_category, std::, ) +SYMBOL(iostream_category, std::, ) SYMBOL(iota, std::, ) SYMBOL(is_abstract, std::, ) SYMBOL(is_abstract_v, std::, ) @@ -668,9 +713,13 @@ SYMBOL(ispunct, std::, ) SYMBOL(isspace, std::, ) SYMBOL(istream, std::, ) +SYMBOL(istream, std::, ) +SYMBOL(istream, std::, ) SYMBOL(istream_iterator, std::, ) SYMBOL(istreambuf_iterator, std::, ) +SYMBOL(istreambuf_iterator, std::, ) SYMBOL(istringstream, std::, ) +SYMBOL(istringstream, std::, ) SYMBOL(isunordered, std::, ) SYMBOL(isupper, std::, ) SYMBOL(iswalnum, std::, ) @@ -703,6 +752,7 @@ SYMBOL(ldiv, std::, ) SYMBOL(ldiv_t, std::, ) SYMBOL(left, std::, ) +SYMBOL(left, std::, ) SYMBOL(length_error, std::, ) SYMBOL(less, std::, ) SYMBOL(less_equal, std::, ) @@ -829,21 +879,29 @@ SYMBOL(nextafter, std::, ) SYMBOL(nexttoward, std::, ) SYMBOL(no_emit_on_flush, std::, ) +SYMBOL(no_emit_on_flush, std::, ) SYMBOL(noboolalpha, std::, ) +SYMBOL(noboolalpha, std::, ) SYMBOL(none_of, std::, ) SYMBOL(norm, std::, ) SYMBOL(normal_distribution, std::, ) SYMBOL(noshowbase, std::, ) +SYMBOL(noshowbase, std::, ) SYMBOL(noshowpoint, std::, ) +SYMBOL(noshowpoint, std::, ) SYMBOL(noshowpos, std::, ) +SYMBOL(noshowpos, std::, ) SYMBOL(noskipws, std::, ) +SYMBOL(noskipws, std::, ) SYMBOL(not_equal_to, std::, ) SYMBOL(not_fn, std::, ) SYMBOL(nothrow, std::, ) SYMBOL(nothrow_t, std::, ) SYMBOL(notify_all_at_thread_exit, std::, ) SYMBOL(nounitbuf, std::, ) +SYMBOL(nounitbuf, std::, ) SYMBOL(nouppercase, std::, ) +SYMBOL(nouppercase, std::, ) SYMBOL(nth_element, std::, ) SYMBOL(nullopt, std::, ) SYMBOL(nullopt_t, std::, ) @@ -854,14 +912,21 @@ SYMBOL(numpunct, std::, ) SYMBOL(numpunct_byname, std::, ) SYMBOL(oct, std::, ) +SYMBOL(oct, std::, ) SYMBOL(ofstream, std::, ) +SYMBOL(ofstream, std::, ) SYMBOL(once_flag, std::, ) SYMBOL(optional, std::, ) SYMBOL(ostream, std::, ) +SYMBOL(ostream, std::, ) +SYMBOL(ostream, std::, ) SYMBOL(ostream_iterator, std::, ) SYMBOL(ostreambuf_iterator, std::, ) +SYMBOL(ostreambuf_iterator, std::, ) SYMBOL(ostringstream, std::, ) +SYMBOL(ostringstream, std::, ) SYMBOL(osyncstream, std::, ) +SYMBOL(osyncstream, std::, ) SYMBOL(out_of_range, std::, ) SYMBOL(output_iterator_tag, std::, ) SYMBOL(overflow_error, std::, ) @@ -991,6 +1056,7 @@ SYMBOL(reverse_iterator, std::, ) SYMBOL(rewind, std::, ) SYMBOL(right, std::, ) +SYMBOL(right, std::, ) SYMBOL(rint, std::, ) SYMBOL(rotate, std::, ) SYMBOL(rotate_copy, std::, ) @@ -1006,6 +1072,7 @@ SYMBOL(scalbn, std::, ) SYMBOL(scanf, std::, ) SYMBOL(scientific, std::, ) +SYMBOL(scientific, std::, ) SYMBOL(scoped_allocator_adaptor, std::, ) SYMBOL(search, std::, ) SYMBOL(search_n, std::, ) @@ -1033,8 +1100,11 @@ SYMBOL(shift_left, std::, ) SYMBOL(shift_right, std::, ) SYMBOL(showbase, std::, ) +SYMBOL(showbase, std::, ) SYMBOL(showpoint, std::, ) +SYMBOL(showpoint, std::, ) SYMBOL(showpos, std::, ) +SYMBOL(showpos, std::, ) SYMBOL(shuffle, std::, ) SYMBOL(shuffle_order_engine, std::, ) SYMBOL(sig_atomic_t, std::, ) @@ -1044,6 +1114,7 @@ SYMBOL(sinh, std::, ) SYMBOL(size, std::, ) SYMBOL(skipws, std::, ) +SYMBOL(skipws, std::, ) SYMBOL(slice, std::, ) SYMBOL(slice_array, std::, ) SYMBOL(smatch, std::, ) @@ -1069,15 +1140,23 @@ SYMBOL(strcpy, std::, ) SYMBOL(strcspn, std::, ) SYMBOL(streambuf, std::, ) +SYMBOL(streambuf, std::, ) +SYMBOL(streambuf, std::, ) SYMBOL(streamoff, std::, ) +SYMBOL(streamoff, std::, ) SYMBOL(streampos, std::, ) +SYMBOL(streampos, std::, ) +SYMBOL(streampos, std::, ) SYMBOL(streamsize, std::, ) +SYMBOL(streamsize, std::, ) SYMBOL(strerror, std::, ) SYMBOL(strftime, std::, ) SYMBOL(string, std::, ) SYMBOL(string_view, std::, ) SYMBOL(stringbuf, std::, ) +SYMBOL(stringbuf, std::, ) SYMBOL(stringstream, std::, ) +SYMBOL(stringstream, std::, ) SYMBOL(strlen, std::, ) SYMBOL(strncat, std::, ) SYMBOL(strncmp, std::, ) @@ -1108,6 +1187,7 @@ SYMBOL(swprintf, std::, ) SYMBOL(swscanf, std::, ) SYMBOL(syncbuf, std::, ) +SYMBOL(syncbuf, std::, ) SYMBOL(system, std::, ) SYMBOL(system_category, std::, ) SYMBOL(system_error, std::, ) @@ -1158,9 +1238,13 @@ SYMBOL(type_index, std::, ) SYMBOL(type_info, std::, ) SYMBOL(u16streampos, std::, ) +SYMBOL(u16streampos, std::, ) +SYMBOL(u16streampos, std::, ) SYMBOL(u16string, std::, ) SYMBOL(u16string_view, std::, ) SYMBOL(u32streampos, std::, ) +SYMBOL(u32streampos, std::, ) +SYMBOL(u32streampos, std::, ) SYMBOL(u32string, std::, ) SYMBOL(u32string_view, std::, ) SYMBOL(uint16_t, std::, ) @@ -1202,12 +1286,14 @@ SYMBOL(unique_lock, std::, ) SYMBOL(unique_ptr, std::, ) SYMBOL(unitbuf, std::, ) +SYMBOL(unitbuf, std::, ) SYMBOL(unordered_map, std::, ) SYMBOL(unordered_multimap, std::, ) SYMBOL(unordered_multiset, std::, ) SYMBOL(unordered_set, std::, ) SYMBOL(upper_bound, std::, ) SYMBOL(uppercase, std::, ) +SYMBOL(uppercase, std::, ) SYMBOL(use_facet, std::, ) SYMBOL(uses_allocator, std::, ) SYMBOL(uses_allocator_v, std::, ) @@ -1286,37 +1372,61 @@ SYMBOL(weak_ptr, std::, ) SYMBOL(weibull_distribution, std::, ) SYMBOL(wfilebuf, std::, ) +SYMBOL(wfilebuf, std::, ) +SYMBOL(wfilebuf, std::, ) SYMBOL(wfstream, std::, ) +SYMBOL(wfstream, std::, ) SYMBOL(wifstream, std::, ) +SYMBOL(wifstream, std::, ) SYMBOL(wios, std::, ) +SYMBOL(wios, std::, ) +SYMBOL(wios, std::, ) SYMBOL(wiostream, std::, ) +SYMBOL(wiostream, std::, ) +SYMBOL(wiostream, std::, ) SYMBOL(wistream, std::, ) +SYMBOL(wistream, std::, ) +SYMBOL(wistream, std::, ) SYMBOL(wistringstream, std::, ) +SYMBOL(wistringstream, std::, ) SYMBOL(wmemchr, std::, ) SYMBOL(wmemcmp, std::, ) SYMBOL(wmemcpy, std::, ) SYMBOL(wmemmove, std::, ) SYMBOL(wmemset, std::, ) SYMBOL(wofstream, std::, ) +SYMBOL(wofstream, std::, ) SYMBOL(wostream, std::, ) +SYMBOL(wostream, std::, ) +SYMBOL(wostream, std::, ) SYMBOL(wostringstream, std::, ) +SYMBOL(wostringstream, std::, ) SYMBOL(wosyncstream, std::, ) +SYMBOL(wosyncstream, std::, ) SYMBOL(wprintf, std::, ) SYMBOL(wregex, std::, ) SYMBOL(ws, std::, ) +SYMBOL(ws, std::, ) SYMBOL(wscanf, std::, ) SYMBOL(wsmatch, std::, ) SYMBOL(wsregex_iterator, std::, ) SYMBOL(wsregex_token_iterator, std::, ) SYMBOL(wssub_match, std::, ) SYMBOL(wstreambuf, std::, ) +SYMBOL(wstreambuf, std::, ) +SYMBOL(wstreambuf, std::, ) SYMBOL(wstreampos, std::, ) +SYMBOL(wstreampos, std::, ) +SYMBOL(wstreampos, std::, ) SYMBOL(wstring, std::, ) SYMBOL(wstring_convert, std::, ) SYMBOL(wstring_view, std::, ) SYMBOL(wstringbuf, std::, ) +SYMBOL(wstringbuf, std::, ) SYMBOL(wstringstream, std::, ) +SYMBOL(wstringstream, std::, ) SYMBOL(wsyncbuf, std::, ) +SYMBOL(wsyncbuf, std::, ) SYMBOL(yocto, std::, ) SYMBOL(yotta, std::, ) SYMBOL(zepto, std::, ) diff --git a/clang/tools/include-mapping/gen_std.py b/clang/tools/include-mapping/gen_std.py --- a/clang/tools/include-mapping/gen_std.py +++ b/clang/tools/include-mapping/gen_std.py @@ -42,6 +42,7 @@ import os import sys + CODE_PREFIX = """\ //===-- gen_std.py generated file -------------------------------*- C++ -*-===// // @@ -68,6 +69,108 @@ required=True) return parser.parse_args() +def AdditionalHeadersForIOSymbols(symbol): + # IO-related symbols declared in the header, per C++ + # [iosfwd.syn 31.3.1]: + iosfwd_symbols = [ + 'basic_ios', + 'basic_streambuf', + 'basic_istream', + 'basic_ostream', + 'basic_iostream', + + 'basic_stringbuf', + 'basic_istringstream', + 'basic_ostringstream', + 'basic_stringstream', + + 'basic_spanbuf', + 'basic_ispanstream', + 'basic_ospanstream', + 'basic_spanstream', + + 'basic_filebuf', + 'basic_ifstream', + 'basic_ofstream', + 'basic_fstream', + + 'basic_syncbuf', + 'basic_osyncstream', + + 'istreambuf_iterator', + 'ostreambuf_iterator', + + 'ios', + 'wios', + + 'streambuf', + 'istream', + 'ostream', + 'iostream', + + 'stringbuf', + 'istringstream', + 'ostringstream', + 'stringstream', + + 'spanbuf', + 'ispanstream', + 'ospanstream', + 'spanstream', + + 'filebuf', + 'ifstream', + 'ofstream', + 'fstream', + + 'syncbuf', + 'osyncstream', + + 'wstreambuf', + 'wistream', + 'wostream', + 'wiostream', + + 'wstringbuf', + 'wistringstream', + 'wostringstream', + 'wstringstream', + + 'wspanbuf', + 'wispanstream', + 'wospanstream', + 'wspanstream', + + 'wfilebuf', + 'wifstream', + 'wofstream', + 'wfstream', + + 'wsyncbuf', + 'wosyncstream', + + 'fpos', + 'streampos', + 'wstreampos', + 'u8streampos', + 'u16streampos', + 'u32streampos', + ] + assert(len(symbol.headers) == 1) + sym_header = symbol.headers[0] + headers = [] + # is preferred than + + # is an alternative of , , , . + # per C++ [iostream.syn 31.4.1] + if sym_header in ["", "", "", ""]: + headers.append("") + + if symbol.name in iosfwd_symbols: + headers.append("") + + return headers + def main(): args = ParseArg() @@ -112,8 +215,10 @@ 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])) + symbol.headers.extend(AdditionalHeadersForIOSymbols(symbol)) + for header in symbol.headers: + print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace, + header)) elif len(symbol.headers) == 0: sys.stderr.write("No header found for symbol %s\n" % symbol.name) else: diff --git a/clang/unittests/Tooling/StandardLibraryTest.cpp b/clang/unittests/Tooling/StandardLibraryTest.cpp --- a/clang/unittests/Tooling/StandardLibraryTest.cpp +++ b/clang/unittests/Tooling/StandardLibraryTest.cpp @@ -58,6 +58,11 @@ EXPECT_EQ(Vector->header(), *VectorH); EXPECT_THAT(Vector->headers(), ElementsAre(*VectorH)); + EXPECT_THAT(stdlib::Symbol::named("std::", "basic_iostream")->headers(), + ElementsAre(stdlib::Header::named(""), + stdlib::Header::named(""), + stdlib::Header::named(""))); + EXPECT_THAT(stdlib::Header::all(), Contains(*VectorH)); EXPECT_THAT(stdlib::Symbol::all(), Contains(*Vector)); EXPECT_FALSE(stdlib::Header::named(""));