2 # C++ alternatives to C standard headers
3 { include: [ "<assert.h>", public, "<cassert>", public ] },
4 { include: [ "<complex.h>", public, "<ccomplex>", public ] },
5 { include: [ "<ctype.h>", public, "<cctype>", public ] },
6 { include: [ "<errno.h>", public, "<cerrno>", public ] },
7 { include: [ "<float.h>", public, "<cfloat>", public ] },
8 { include: [ "<iso646.h>", public, "<ciso646>", public ] },
9 { include: [ "<limits.h>", public, "<climits>", public ] },
10 { include: [ "<locale.h>", public, "<clocale>", public ] },
11 { include: [ "<math.h>", public, "<cmath>", public ] },
12 { include: [ "<setjmp.h>", public, "<csetjmp>", public ] },
13 { include: [ "<signal.h>", public, "<csignal>", public ] },
14 { include: [ "<stdarg.h>", public, "<cstdarg>", public ] },
15 { include: [ "<stddef.h>", public, "<cstddef>", public ] },
16 { include: [ "<stdio.h>", public, "<cstdio>", public ] },
17 { include: [ "<stdlib.h>", public, "<cstdlib>", public ] },
18 { include: [ "<string.h>", public, "<cstring>", public ] },
19 { include: [ "<time.h>", public, "<ctime>", public ] },
20 { include: [ "<wchar.h>", public, "<cwchar>", public ] },
21 { include: [ "<wctype.h>", public, "<cwctype>", public ] },
23 # HACK: check whether this can be removed with next iwyu release.
24 { include: [ "<bits/cxxabi_forced.h>", private, "<ctime>", public ] },
25 { include: [ "<bits/shared_ptr.h>", private, "<memory>", public ] },
26 { include: [ "<bits/std_function.h>", private, "<functional>", public ] },
27 { include: [ "<bits/refwrap.h>", private, "<functional>", public ] },
28 { include: [ "<bits/std_abs.h>", private, "<stdlib.h>", public ] },
29 { include: [ "<bits/stdint-intn.h>", private, "<stdint.h>", public ] },
30 { include: [ "<bits/stdint-uintn.h>", private, "<stdint.h>", public ] },
31 { include: [ "<bits/string_view.tcc>", private, "<string_view>", private ] },
32 { include: [ "<bits/time.h>", private, "<time.h>", public ] },
33 { include: [ "<bits/types/clock_t.h>", private, "<time.h>", public ] },
34 { include: [ "<bits/types/mbstate_t.h>", private, "<wchar.h>", public ] },
35 { include: [ "<bits/types/struct_timespec.h>", private, "<time.h>", public ] },
36 { include: [ "<bits/types/struct_timeval.h>", private, "<time.h>", public ] },
37 { include: [ "<bits/types/struct_tm.h>", private, "<time.h>", public ] },
38 { include: [ "<bits/types/time_t.h>", private, "<time.h>", public ] },
40 # HACK: check whether this can be removed with next iwyu release.
41 { symbol: [ "__GLIBC__", private, "<stdlib.h>", public ] },
42 { symbol: [ "_Noreturn", private, "<stdlib.h>", public ] },
44 # HACK: iwyu wrongly thinks that including <iosfwd> is sufficient.
45 { symbol: [ "std::stringstream", private, "<sstream>", public ] },
46 { symbol: [ "std::istringstream", private, "<sstream>", public ] },
47 { symbol: [ "std::ostringstream", private, "<sstream>", public ] },
49 # HACK: iwyu suggests <ext/alloc_traits.h> and <memory> each time vector[] is used.
50 # https://github.com/include-what-you-use/include-what-you-use/issues/166
51 { include: [ "<ext/alloc_traits.h>", private, "<vector>", public ] },
52 { symbol: [ "std::allocator_traits<std::allocator<cmFileLock> >::value_type", private, "<vector>", public ] },
53 { symbol: [ "std::allocator_traits<std::allocator<cmFileLockPool::ScopePool> >::value_type", private, "<vector>", public ] },
54 { symbol: [ "std::allocator_traits<std::allocator<cmComputeComponentGraph::TarjanEntry> >::value_type", private, "<vector>", public ] },
55 { symbol: [ "std::allocator_traits<std::allocator<cmFortranFile> >::value_type", private, "<vector>", public ] },
56 { symbol: [ "std::allocator_traits<std::allocator<cmGraphEdgeList> >::value_type", private, "<vector>", public ] },
57 { symbol: [ "std::allocator_traits<std::allocator<cmOrderDirectories::ConflictList> >::value_type", private, "<vector>", public ] },
58 { symbol: [ "std::allocator_traits<std::allocator<cmStateSnapshot> >::value_type", private, "<vector>", public ] },
59 { symbol: [ "std::allocator_traits<std::allocator<std::basic_string<char> > >::value_type", private, "<vector>", public ] },
60 { symbol: [ "std::allocator_traits<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::value_type", private, "<vector>", public ] },
61 { symbol: [ "std::allocator_traits<std::allocator<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > > > >::value_type", private, "<vector>", public ] },
62 { symbol: [ "std::allocator_traits<std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::value_type", private, "<vector>", public ] },
63 { symbol: [ "std::allocator_traits<std::allocator<uv_stdio_container_s> >::value_type", private, "<vector>", public ] },
65 # TODO: enable this block and remove some <utility> includes?
66 #{ symbol: [ "std::pair", private, "<utility>", public ] },
67 #{ symbol: [ "std::pair", private, "<map>", public ] },
68 #{ symbol: [ "std::pair", private, "<set>", public ] },
70 # HACK: iwyu wrongly thinks that <system_error> is needed for std::hash
71 { symbol: [ "std::hash", private, "<functional>", public ] },
73 # HACK: iwyu thinks we use a libstdc++ private type
74 { symbol: [ "__gnu_cxx::size_t", private, "<cstddef>", public ] },
76 # __decay_and_strip is used internally in the C++11 standard library.
77 # IWYU does not classify it as internal and suggests to add <type_traits>.
78 # To ignore it, we simply map it to a file that is included anyway.
79 # Use '-Xiwyu -v7' to see the fully qualified names that need this.
80 # TODO: Can this be simplified with an @-expression?
81 #{ symbol: [ "@std::__decay_and_strip<.*>::__type", private, "\"cmConfigure.h\"", public ] },
82 { symbol: [ "std::__decay_and_strip<bool>::__type", private, "\"cmConfigure.h\"", public ] },
83 { symbol: [ "std::__decay_and_strip<char const (&)[1]>::__type", private, "\"cmConfigure.h\"", public ] },
84 { symbol: [ "std::__decay_and_strip<cmCommand *&>::__type", private, "\"cmConfigure.h\"", public ] },
85 { symbol: [ "std::__decay_and_strip<cmGeneratorTarget *&>::__type", private, "\"cmConfigure.h\"", public ] },
86 { symbol: [ "std::__decay_and_strip<cmFindCommon::PathLabel &>::__type", private, "\"cmConfigure.h\"", public ] },
87 { symbol: [ "std::__decay_and_strip<cmSearchPath>::__type", private, "\"cmConfigure.h\"", public ] },
88 { symbol: [ "std::__decay_and_strip<cm::string_view>::__type", private, "\"cmConfigure.h\"", public ] },
89 { symbol: [ "std::__decay_and_strip<std::basic_string<char> &>::__type", private, "\"cmConfigure.h\"", public ] },
90 { symbol: [ "std::__decay_and_strip<const std::basic_string<char> &>::__type", private, "\"cmConfigure.h\"", public ] },
91 { symbol: [ "std::__decay_and_strip<cmFindPackageCommand::PathLabel &>::__type", private, "\"cmConfigure.h\"", public ] },
92 { symbol: [ "std::__decay_and_strip<cmGlobalNinjaGenerator::TargetAlias &>::__type", private, "\"cmConfigure.h\"", public ] },
93 { symbol: [ "std::__decay_and_strip<__gnu_cxx::__normal_iterator<const cmCTestTestHandler::cmCTestTestProperties *, std::vector<cmCTestTestHandler::cmCTestTestProperties, std::allocator<cmCTestTestHandler::cmCTestTestProperties> > > &>::__type", private, "\"cmConfigure.h\"", public ] },
94 { symbol: [ "std::__decay_and_strip<const __gnu_cxx::__normal_iterator<std::pair<cm::string_view, std::function<void (ArgumentParser::Instance &, void *)> > *, std::vector<std::pair<cm::string_view, std::function<void (ArgumentParser::Instance &, void *)> >, std::allocator<std::pair<cm::string_view, std::function<void (ArgumentParser::Instance &, void *)> > > > > &>::__type", private, "\"cmConfigure.h\"", public ] },
95 { symbol: [ "std::__success_type<std::chrono::duration<double, std::ratio<1, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
96 { symbol: [ "std::__success_type<std::chrono::duration<long, std::ratio<1, 1000000000> > >::type", private, "\"cmConfigure.h\"", public ] },
97 { symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<1, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
98 { symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<60, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
99 { symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<1, 1000> > >::type", private, "\"cmConfigure.h\"", public ] },
100 { symbol: [ "__gnu_cxx::__enable_if<true, bool>::__type", private, "\"cmConfigure.h\"", public ] },
102 # Wrappers for 3rd-party libraries
103 { include: [ "@<.*curl/curlver.h>", private, "<cm3p/curl/curl.h>", public ] },
104 { include: [ "@<.*json/config.h>", private, "<cm3p/json/value.h>", public ] },
105 { include: [ "@<.*json/forwards.h>", private, "<cm3p/json/value.h>", public ] },
106 { include: [ "@<.*uv/.+\\.h>", private, "<cm3p/uv.h>", public ] },
107 { include: [ "@<.*expat_external.h>", private, "<cm3p/expat.h>", public ] },
108 { include: [ "@<.*zconf.h>", private, "<cm3p/zlib.h>", public ] },
109 { include: [ "@<.*cm_zlib_mangle.h>", private, "<cm3p/zlib.h>", public ] },
110 # # System symbols used by libuv
111 { symbol: [ "ssize_t", private, "<cm3p/uv.h>", public ] },
113 { symbol: [ "std::ifstream", private, "\"cmsys/FStream.hxx\"", public ] },
114 { symbol: [ "std::ofstream", private, "\"cmsys/FStream.hxx\"", public ] },
115 { symbol: [ "cmsys::ifstream", private, "\"cmsys/FStream.hxx\"", public ] },
116 { symbol: [ "cmsys::ofstream", private, "\"cmsys/FStream.hxx\"", public ] },
118 { include: [ "<istream>", public, "\"cmsys/FStream.hxx\"", public ] },
119 { include: [ "<ostream>", public, "\"cmsys/FStream.hxx\"", public ] },
120 { include: [ "<fstream>", public, "\"cmsys/FStream.hxx\"", public ] },
122 { include: [ "<filesystem>", private, "<cm/filesystem>", public ] },
123 { include: [ "<optional>", private, "<cm/optional>", public ] },
124 { include: [ "<shared_mutex>", private, "<cm/shared_mutex>", public ] },
125 { include: [ "<string_view>", private, "<cm/string_view>", public ] },
127 # major and minor are used as macro arguments. Those are false matches.
128 { symbol: [ "major", private, "\"cmVersion.h\"", public ] },
129 { symbol: [ "minor", private, "\"cmVersion.h\"", public ] },
131 { include: [ "<curses.h>", private, "\"cmCursesStandardIncludes.h\"", public ] },
132 { include: [ "\"form.h\"", private, "\"cmCursesStandardIncludes.h\"", public ] },
133 { include: [ "<form.h>", private, "\"cmCursesStandardIncludes.h\"", public ] },
135 # Help IWYU understand our explicit instantiation for cmConstStack.
136 { symbol: [ "cmConstStack::cmConstStack<T, Stack>", private, "\"cmConstStack.h\"", public ] },