[clangd] Minor fixes for C++ standard library header mapping.

llvm-svn: 330803
This commit is contained in:
Eric Liu 2018-04-25 09:17:05 +00:00
parent 3dd22c9898
commit 7920d2ea4e
1 changed files with 24 additions and 7 deletions

View File

@ -78,6 +78,7 @@ collectIWYUHeaderMaps(CanonicalIncludes *Includes) {
void addSystemHeadersMapping(CanonicalIncludes *Includes) {
static const std::vector<std::pair<const char *, const char *>> SymbolMap = {
{"std::addressof", "<memory>"},
// Map symbols in <iosfwd> to their preferred includes.
{"std::basic_filebuf", "<fstream>"},
{"std::basic_fstream", "<fstream>"},
@ -120,6 +121,9 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"std::basic_streambuf", "<streambuf>"},
{"std::streambuf", "<streambuf>"},
{"std::wstreambuf", "<streambuf>"},
{"std::uint_least16_t", "<cstdint>"}, // <type_traits> redeclares these
{"std::uint_least32_t", "<cstdint>"},
{"std::declval", "<utility>"},
};
for (const auto &Pair : SymbolMap)
Includes->addSymbolMapping(Pair.first, Pair.second);
@ -191,16 +195,18 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"include/_G_config.h$", "<cstdio>"},
{"include/assert.h$", "<cassert>"},
{"algorithm$", "<algorithm>"},
{"valarray$", "<valarray>"},
{"array$", "<array>"},
{"atomic$", "<atomic>"},
{"backward/auto_ptr.h$", "<memory>"},
{"backward/binders.h$", "<string>"},
{"bits/algorithmfwd.h$", "<algorithm>"},
{"bits/alloc_traits.h$", "<unordered_set>"},
{"bits/alloc_traits.h$", "<memory>"},
{"bits/allocated_ptr.h$", "<memory>"},
{"bits/allocator.h$", "<allocator>"},
{"bits/atomic_base.h$", "<atomic>"},
{"bits/atomic_lockfree_defines.h$", "<exception>"},
{"bits/atomic_futex.h$", "<atomic>"},
{"bits/basic_ios.h$", "<ios>"},
{"bits/basic_ios.tcc$", "<ios>"},
{"bits/basic_string.h$", "<string>"},
@ -211,19 +217,21 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"bits/cpp_type_traits.h$", "<cmath>"},
{"bits/cxxabi_forced.h$", "<cxxabi.h>"},
{"bits/deque.tcc$", "<deque>"},
{"bits/exception.h$", "<exception>"},
{"bits/exception_defines.h$", "<exception>"},
{"bits/exception_ptr.h$", "<exception>"},
{"bits/forward_list.h$", "<forward_list>"},
{"bits/forward_list.tcc$", "<forward_list>"},
{"bits/fstream.tcc$", "<fstream>"},
{"bits/functexcept.h$", "<list>"},
{"bits/functional_hash.h$", "<string>"},
{"bits/functional_hash.h$", "<functional>"},
{"bits/gslice.h$", "<valarray>"},
{"bits/gslice_array.h$", "<valarray>"},
{"bits/hash_bytes.h$", "<typeinfo>"},
{"bits/hashtable.h$", "<unordered_set>"},
{"bits/hashtable_policy.h$", "<unordered_set>"},
{"bits/indirect_array.h$", "<valarray>"},
{"bits/invoke.h$", "<functional>"},
{"bits/ios_base.h$", "<ios>"},
{"bits/istream.tcc$", "<istream>"},
{"bits/list.tcc$", "<list>"},
@ -241,25 +249,33 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"bits/nested_exception.h$", "<exception>"},
{"bits/ostream.tcc$", "<ostream>"},
{"bits/ostream_insert.h$", "<ostream>"},
{"bits/postypes.h$", "<iosfwd>"},
{"bits/parse_numbers.h$", "<chrono>"},
{"bits/postypes.h$", "<ios>"},
{"bits/predefined_ops.h$", "<algorithm>"},
{"bits/ptr_traits.h$", "<memory>"},
{"bits/quoted_string.h$", "<iomanip>"},
{"bits/random.h$", "<random>"},
{"bits/random.tcc$", "<random>"},
{"bits/range_access.h$", "<iterator>"},
{"bits/refwrap.h$", "<functional>"},
{"bits/regex.h$", "<regex>"},
{"bits/regex_automaton.h$", "<regex>"},
{"bits/regex_compiler.h$", "<regex>"},
{"bits/regex_constants.h$", "<regex>"},
{"bits/regex_cursor.h$", "<regex>"},
{"bits/regex_error.h$", "<regex>"},
{"bits/regex_executor.h$", "<regex>"},
{"bits/regex_grep_matcher.h$", "<regex>"},
{"bits/regex_grep_matcher.tcc$", "<regex>"},
{"bits/regex_nfa.h$", "<regex>"},
{"bits/regex_scanner.h$", "<regex>"},
{"bits/shared_ptr.h$", "<memory>"},
{"bits/shared_ptr_base.h$", "<memory>"},
{"bits/shared_ptr_atomic.h$", "<memory>"},
{"bits/shared_ptr_atomic.h$", "<atomic>"},
{"bits/slice_array.h$", "<valarray>"},
{"bits/sstream.tcc$", "<sstream>"},
{"bits/std_abs.h$", "<cmath>"},
{"bits/std_function.h$", "<functional>"},
{"bits/std_mutex.h$", "<mutex>"},
{"bits/stl_algo.h$", "<algorithm>"},
{"bits/stl_algobase.h$", "<algorithm>"},
@ -270,7 +286,7 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"bits/stl_heap.h$", "<heap>"},
{"bits/stl_iterator.h$", "<iterator>"},
{"bits/stl_iterator_base_funcs.h$", "<iterator>"},
{"bits/stl_iterator_base_types.h$", "<numeric>"},
{"bits/stl_iterator_base_types.h$", "<iterator>"},
{"bits/stl_list.h$", "<list>"},
{"bits/stl_map.h$", "<map>"},
{"bits/stl_multimap.h$", "<map>"},
@ -284,7 +300,7 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"bits/stl_stack.h$", "<stack>"},
{"bits/stl_tempbuf.h$", "<memory>"},
{"bits/stl_tree.h$", "<map>"},
{"bits/stl_uninitialized.h$", "<deque>"},
{"bits/stl_uninitialized.h$", "<memory>"},
{"bits/stl_vector.h$", "<vector>"},
{"bits/stream_iterator.h$", "<iterator>"},
{"bits/streambuf.tcc$", "<streambuf>"},
@ -294,7 +310,7 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"bits/unique_ptr.h$", "<memory>"},
{"bits/unordered_map.h$", "<unordered_map>"},
{"bits/unordered_set.h$", "<unordered_set>"},
{"bits/uses_allocator.h$", "<tuple>"},
{"bits/uses_allocator.h$", "<memory>"},
{"bits/valarray_after.h$", "<valarray>"},
{"bits/valarray_array.h$", "<valarray>"},
{"bits/valarray_array.tcc$", "<valarray>"},
@ -359,6 +375,7 @@ void addSystemHeadersMapping(CanonicalIncludes *Includes) {
{"locale$", "<locale>"},
{"map$", "<map>"},
{"memory$", "<memory>"},
{"shared_mutex$", "<shared_mutex>"},
{"mutex$", "<mutex>"},
{"new$", "<new>"},
{"numeric$", "<numeric>"},