clang-tools 8.0.0

CanonicalIncludes.cpp
Go to the documentation of this file.
1 //===-- CanonicalIncludes.h - remap #inclue headers--------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "CanonicalIncludes.h"
11 #include "Headers.h"
12 #include "clang/Driver/Types.h"
13 #include "llvm/Support/Path.h"
14 #include <algorithm>
15
16 namespace clang {
17 namespace clangd {
18 namespace {
19 const char IWYUPragma[] = "// IWYU pragma: private, include ";
20 } // namespace
21
22 void CanonicalIncludes::addPathSuffixMapping(llvm::StringRef Suffix,
23 llvm::StringRef CanonicalPath) {
24 int Components = std::distance(llvm::sys::path::begin(Suffix),
25 llvm::sys::path::end(Suffix));
26 MaxSuffixComponents = std::max(MaxSuffixComponents, Components);
27 SuffixHeaderMapping[Suffix] = CanonicalPath;
28 }
29
30 void CanonicalIncludes::addMapping(llvm::StringRef Path,
31 llvm::StringRef CanonicalPath) {
32 FullPathMapping[Path] = CanonicalPath;
33 }
34
35 void CanonicalIncludes::addSymbolMapping(llvm::StringRef QualifiedName,
36 llvm::StringRef CanonicalPath) {
37 this->SymbolMapping[QualifiedName] = CanonicalPath;
38 }
39
40 llvm::StringRef
41 CanonicalIncludes::mapHeader(llvm::ArrayRef<std::string> Headers,
42 llvm::StringRef QualifiedName) const {
43 assert(!Headers.empty());
44 auto SE = SymbolMapping.find(QualifiedName);
45 if (SE != SymbolMapping.end())
46 return SE->second;
47 // Find the first header such that the extension is not '.inc', and isn't a
48 // recognized non-header file
49 auto I = llvm::find_if(Headers, [](llvm::StringRef Include) {
50 // Skip .inc file whose including header file should
51 // be #included instead.
52 return !Include.endswith(".inc");
53 });
54 if (I == Headers.end())
55 return Headers[0]; // Fallback to the declaring header.
56 llvm::StringRef Header = *I;
57 // If Header is not expected be included (e.g. .cc file), we fall back to
58 // the declaring header.
59 llvm::StringRef Ext = llvm::sys::path::extension(Header).trim('.');
60 // Include-able headers must have precompile type. Treat files with
61 // non-recognized extenstions (TY_INVALID) as headers.
62 auto ExtType = driver::types::lookupTypeForExtension(Ext);
63 if ((ExtType != driver::types::TY_INVALID) &&
64 !driver::types::onlyPrecompileType(ExtType))
65 return Headers[0];
66
67 auto MapIt = FullPathMapping.find(Header);
68 if (MapIt != FullPathMapping.end())
69 return MapIt->second;
70
71 int Components = 1;
72 for (auto It = llvm::sys::path::rbegin(Header),
73 End = llvm::sys::path::rend(Header);
74 It != End && Components <= MaxSuffixComponents; ++It, ++Components) {
75 auto SubPath = Header.substr(It->data() - Header.begin());
76 auto MappingIt = SuffixHeaderMapping.find(SubPath);
77 if (MappingIt != SuffixHeaderMapping.end())
78 return MappingIt->second;
79 }
80 return Header;
81 }
82
83 std::unique_ptr<CommentHandler>
84 collectIWYUHeaderMaps(CanonicalIncludes *Includes) {
85 class PragmaCommentHandler : public clang::CommentHandler {
86 public:
87 PragmaCommentHandler(CanonicalIncludes *Includes) : Includes(Includes) {}
88
89 bool HandleComment(Preprocessor &PP, SourceRange Range) override {
90 llvm::StringRef Text =
91 Lexer::getSourceText(CharSourceRange::getCharRange(Range),
92 PP.getSourceManager(), PP.getLangOpts());
93 if (!Text.consume_front(IWYUPragma))
94 return false;
95 // FIXME(ioeric): resolve the header and store actual file path. For now,
96 // we simply assume the written header is suitable to be #included.
97 Includes->addMapping(PP.getSourceManager().getFilename(Range.getBegin()),
98 isLiteralInclude(Text) ? Text.str()
99 : ("\"" + Text + "\"").str());
100 return false;
101 }
102
103 private:
104 CanonicalIncludes *const Includes;
105 };
106 return llvm::make_unique<PragmaCommentHandler>(Includes);
107 }
108
109 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
110 static const std::vector<std::pair<const char *, const char *>> SymbolMap = {
111 {"std::addressof", "<memory>"},
112 // Map symbols in <iosfwd> to their preferred includes.
113 {"std::basic_filebuf", "<fstream>"},
114 {"std::basic_fstream", "<fstream>"},
115 {"std::basic_ifstream", "<fstream>"},
116 {"std::basic_ofstream", "<fstream>"},
117 {"std::filebuf", "<fstream>"},
118 {"std::fstream", "<fstream>"},
119 {"std::ifstream", "<fstream>"},
120 {"std::ofstream", "<fstream>"},
121 {"std::wfilebuf", "<fstream>"},
122 {"std::wfstream", "<fstream>"},
123 {"std::wifstream", "<fstream>"},
124 {"std::wofstream", "<fstream>"},
125 {"std::basic_ios", "<ios>"},
126 {"std::ios", "<ios>"},
127 {"std::wios", "<ios>"},
128 {"std::basic_iostream", "<iostream>"},
129 {"std::iostream", "<iostream>"},
130 {"std::wiostream", "<iostream>"},
131 {"std::basic_istream", "<istream>"},
132 {"std::istream", "<istream>"},
133 {"std::wistream", "<istream>"},
134 {"std::istreambuf_iterator", "<iterator>"},
135 {"std::ostreambuf_iterator", "<iterator>"},
136 {"std::basic_ostream", "<ostream>"},
137 {"std::ostream", "<ostream>"},
138 {"std::wostream", "<ostream>"},
139 {"std::basic_istringstream", "<sstream>"},
140 {"std::basic_ostringstream", "<sstream>"},
141 {"std::basic_stringbuf", "<sstream>"},
142 {"std::basic_stringstream", "<sstream>"},
143 {"std::istringstream", "<sstream>"},
144 {"std::ostringstream", "<sstream>"},
145 {"std::string", "<string>"},
146 {"std::stringbuf", "<sstream>"},
147 {"std::stringstream", "<sstream>"},
148 {"std::wistringstream", "<sstream>"},
149 {"std::wostringstream", "<sstream>"},
150 {"std::wstringbuf", "<sstream>"},
151 {"std::wstringstream", "<sstream>"},
152 {"std::basic_streambuf", "<streambuf>"},
153 {"std::streambuf", "<streambuf>"},
154 {"std::wstreambuf", "<streambuf>"},
155 {"std::uint_least16_t", "<cstdint>"}, // <type_traits> redeclares these
156 {"std::uint_least32_t", "<cstdint>"},
157 {"std::declval", "<utility>"},
158 };
159 for (const auto &Pair : SymbolMap)
160 Includes->addSymbolMapping(Pair.first, Pair.second);
161
162 static const std::vector<std::pair<const char *, const char *>>
163 SystemHeaderMap = {
164 {"include/__stddef_max_align_t.h", "<cstddef>"},
165 {"include/__wmmintrin_aes.h", "<wmmintrin.h>"},
166 {"include/__wmmintrin_pclmul.h", "<wmmintrin.h>"},
167 {"include/adxintrin.h", "<immintrin.h>"},
168 {"include/ammintrin.h", "<ammintrin.h>"},
169 {"include/avx2intrin.h", "<immintrin.h>"},
170 {"include/avx512bwintrin.h", "<immintrin.h>"},
171 {"include/avx512cdintrin.h", "<immintrin.h>"},
172 {"include/avx512dqintrin.h", "<immintrin.h>"},
173 {"include/avx512erintrin.h", "<immintrin.h>"},
174 {"include/avx512fintrin.h", "<immintrin.h>"},
175 {"include/avx512ifmaintrin.h", "<immintrin.h>"},
176 {"include/avx512ifmavlintrin.h", "<immintrin.h>"},
177 {"include/avx512pfintrin.h", "<immintrin.h>"},
178 {"include/avx512vbmiintrin.h", "<immintrin.h>"},
179 {"include/avx512vbmivlintrin.h", "<immintrin.h>"},
180 {"include/avx512vlbwintrin.h", "<immintrin.h>"},
181 {"include/avx512vlcdintrin.h", "<immintrin.h>"},
182 {"include/avx512vldqintrin.h", "<immintrin.h>"},
183 {"include/avx512vlintrin.h", "<immintrin.h>"},
184 {"include/avxintrin.h", "<immintrin.h>"},
185 {"include/bmi2intrin.h", "<x86intrin.h>"},
186 {"include/bmiintrin.h", "<x86intrin.h>"},
187 {"include/emmintrin.h", "<emmintrin.h>"},
188 {"include/f16cintrin.h", "<emmintrin.h>"},
189 {"include/float.h", "<cfloat>"},
190 {"include/fma4intrin.h", "<x86intrin.h>"},
191 {"include/fmaintrin.h", "<immintrin.h>"},
192 {"include/fxsrintrin.h", "<immintrin.h>"},
193 {"include/ia32intrin.h", "<x86intrin.h>"},
194 {"include/immintrin.h", "<immintrin.h>"},
195 {"include/inttypes.h", "<cinttypes>"},
196 {"include/limits.h", "<climits>"},
197 {"include/lzcntintrin.h", "<x86intrin.h>"},
198 {"include/mm3dnow.h", "<mm3dnow.h>"},
199 {"include/mm_malloc.h", "<mm_malloc.h>"},
200 {"include/mmintrin.h", "<mmintrin>"},
201 {"include/mwaitxintrin.h", "<x86intrin.h>"},
202 {"include/pkuintrin.h", "<immintrin.h>"},
203 {"include/pmmintrin.h", "<pmmintrin.h>"},
204 {"include/popcntintrin.h", "<popcntintrin.h>"},
205 {"include/prfchwintrin.h", "<x86intrin.h>"},
206 {"include/rdseedintrin.h", "<x86intrin.h>"},
207 {"include/rtmintrin.h", "<immintrin.h>"},
208 {"include/shaintrin.h", "<immintrin.h>"},
209 {"include/smmintrin.h", "<smmintrin.h>"},
210 {"include/stdalign.h", "<cstdalign>"},
211 {"include/stdarg.h", "<cstdarg>"},
212 {"include/stdbool.h", "<cstdbool>"},
213 {"include/stddef.h", "<cstddef>"},
214 {"include/stdint.h", "<cstdint>"},
215 {"include/tbmintrin.h", "<x86intrin.h>"},
216 {"include/tmmintrin.h", "<tmmintrin.h>"},
217 {"include/wmmintrin.h", "<wmmintrin.h>"},
218 {"include/x86intrin.h", "<x86intrin.h>"},
219 {"include/xmmintrin.h", "<xmmintrin.h>"},
220 {"include/xopintrin.h", "<x86intrin.h>"},
221 {"include/xsavecintrin.h", "<immintrin.h>"},
222 {"include/xsaveintrin.h", "<immintrin.h>"},
223 {"include/xsaveoptintrin.h", "<immintrin.h>"},
224 {"include/xsavesintrin.h", "<immintrin.h>"},
225 {"include/xtestintrin.h", "<immintrin.h>"},
226 {"include/_G_config.h", "<cstdio>"},
227 {"include/assert.h", "<cassert>"},
228 {"algorithm", "<algorithm>"},
229 {"valarray", "<valarray>"},
230 {"array", "<array>"},
231 {"atomic", "<atomic>"},
232 {"backward/auto_ptr.h", "<memory>"},
233 {"backward/binders.h", "<string>"},
234 {"bits/algorithmfwd.h", "<algorithm>"},
235 {"bits/alloc_traits.h", "<memory>"},
236 {"bits/allocated_ptr.h", "<memory>"},
237 {"bits/allocator.h", "<allocator>"},
238 {"bits/atomic_base.h", "<atomic>"},
239 {"bits/atomic_lockfree_defines.h", "<exception>"},
240 {"bits/atomic_futex.h", "<atomic>"},
241 {"bits/basic_ios.h", "<ios>"},
242 {"bits/basic_ios.tcc", "<ios>"},
243 {"bits/basic_string.h", "<string>"},
244 {"bits/basic_string.tcc", "<string>"},
245 {"bits/char_traits.h", "<string>"},
246 {"bits/codecvt.h", "<locale>"},
247 {"bits/concept_check.h", "<numeric>"},
248 {"bits/cpp_type_traits.h", "<cmath>"},
249 {"bits/cxxabi_forced.h", "<cxxabi.h>"},
250 {"bits/deque.tcc", "<deque>"},
251 {"bits/exception.h", "<exception>"},
252 {"bits/exception_defines.h", "<exception>"},
253 {"bits/exception_ptr.h", "<exception>"},
254 {"bits/forward_list.h", "<forward_list>"},
255 {"bits/forward_list.tcc", "<forward_list>"},
256 {"bits/fstream.tcc", "<fstream>"},
257 {"bits/functexcept.h", "<list>"},
258 {"bits/functional_hash.h", "<functional>"},
259 {"bits/gslice.h", "<valarray>"},
260 {"bits/gslice_array.h", "<valarray>"},
261 {"bits/hash_bytes.h", "<typeinfo>"},
262 {"bits/hashtable.h", "<unordered_set>"},
263 {"bits/hashtable_policy.h", "<unordered_set>"},
264 {"bits/indirect_array.h", "<valarray>"},
265 {"bits/invoke.h", "<functional>"},
266 {"bits/ios_base.h", "<ios>"},
267 {"bits/istream.tcc", "<istream>"},
268 {"bits/list.tcc", "<list>"},
269 {"bits/locale_classes.h", "<locale>"},
270 {"bits/locale_classes.tcc", "<locale>"},
271 {"bits/locale_conv.h", "<locale>"},
272 {"bits/locale_facets.h", "<locale>"},
273 {"bits/locale_facets.tcc", "<locale>"},
274 {"bits/locale_facets_nonio.h", "<locale>"},
275 {"bits/locale_facets_nonio.tcc", "<locale>"},
276 {"bits/localefwd.h", "<locale>"},
277 {"bits/mask_array.h", "<valarray>"},
278 {"bits/memoryfwd.h", "<memory>"},
279 {"bits/move.h", "<utility>"},
280 {"bits/nested_exception.h", "<exception>"},
281 {"bits/ostream.tcc", "<ostream>"},
282 {"bits/ostream_insert.h", "<ostream>"},
283 {"bits/parse_numbers.h", "<chrono>"},
284 {"bits/postypes.h", "<ios>"},
285 {"bits/predefined_ops.h", "<algorithm>"},
286 {"bits/ptr_traits.h", "<memory>"},
287 {"bits/quoted_string.h", "<iomanip>"},
288 {"bits/random.h", "<random>"},
289 {"bits/random.tcc", "<random>"},
290 {"bits/range_access.h", "<iterator>"},
291 {"bits/refwrap.h", "<functional>"},
292 {"bits/regex.h", "<regex>"},
293 {"bits/regex_automaton.h", "<regex>"},
294 {"bits/regex_compiler.h", "<regex>"},
295 {"bits/regex_constants.h", "<regex>"},
296 {"bits/regex_cursor.h", "<regex>"},
297 {"bits/regex_error.h", "<regex>"},
298 {"bits/regex_executor.h", "<regex>"},
299 {"bits/regex_grep_matcher.h", "<regex>"},
300 {"bits/regex_grep_matcher.tcc", "<regex>"},
301 {"bits/regex_nfa.h", "<regex>"},
302 {"bits/regex_scanner.h", "<regex>"},
303 {"bits/shared_ptr.h", "<memory>"},
304 {"bits/shared_ptr_base.h", "<memory>"},
305 {"bits/shared_ptr_atomic.h", "<atomic>"},
306 {"bits/slice_array.h", "<valarray>"},
307 {"bits/sstream.tcc", "<sstream>"},
308 {"bits/std_abs.h", "<cmath>"},
309 {"bits/std_function.h", "<functional>"},
310 {"bits/std_mutex.h", "<mutex>"},
311 {"bits/stl_algo.h", "<algorithm>"},
312 {"bits/stl_algobase.h", "<algorithm>"},
313 {"bits/stl_bvector.h", "<vector>"},
314 {"bits/stl_construct.h", "<deque>"},
315 {"bits/stl_deque.h", "<deque>"},
316 {"bits/stl_function.h", "<functional>"},
317 {"bits/stl_heap.h", "<heap>"},
318 {"bits/stl_iterator.h", "<iterator>"},
319 {"bits/stl_iterator_base_funcs.h", "<iterator>"},
320 {"bits/stl_iterator_base_types.h", "<iterator>"},
321 {"bits/stl_list.h", "<list>"},
322 {"bits/stl_map.h", "<map>"},
323 {"bits/stl_multimap.h", "<map>"},
324 {"bits/stl_multiset.h", "<set>"},
325 {"bits/stl_numeric.h", "<numeric>"},
326 {"bits/stl_pair.h", "<utility>"},
327 {"bits/stl_queue.h", "<queue>"},
328 {"bits/stl_raw_storage_iter.h", "<memory>"},
329 {"bits/stl_relops.h", "<utility>"},
330 {"bits/stl_set.h", "<set>"},
331 {"bits/stl_stack.h", "<stack>"},
332 {"bits/stl_tempbuf.h", "<memory>"},
333 {"bits/stl_tree.h", "<map>"},
334 {"bits/stl_uninitialized.h", "<memory>"},
335 {"bits/stl_vector.h", "<vector>"},
336 {"bits/stream_iterator.h", "<iterator>"},
337 {"bits/streambuf.tcc", "<streambuf>"},
338 {"bits/streambuf_iterator.h", "<iterator>"},
339 {"bits/stringfwd.h", "<string>"},
340 {"bits/uniform_int_dist.h", "<random>"},
341 {"bits/unique_ptr.h", "<memory>"},
342 {"bits/unordered_map.h", "<unordered_map>"},
343 {"bits/unordered_set.h", "<unordered_set>"},
344 {"bits/uses_allocator.h", "<memory>"},
345 {"bits/valarray_after.h", "<valarray>"},
346 {"bits/valarray_array.h", "<valarray>"},
347 {"bits/valarray_array.tcc", "<valarray>"},
348 {"bits/valarray_before.h", "<valarray>"},
349 {"bits/vector.tcc", "<vector>"},
350 {"bitset", "<bitset>"},
351 {"ccomplex", "<ccomplex>"},
352 {"cctype", "<cctype>"},
353 {"cerrno", "<cerrno>"},
354 {"cfenv", "<cfenv>"},
355 {"cfloat", "<cfloat>"},
356 {"chrono", "<chrono>"},
357 {"cinttypes", "<cinttypes>"},
358 {"climits", "<climits>"},
359 {"clocale", "<clocale>"},
360 {"cmath", "<cmath>"},
361 {"complex", "<complex>"},
362 {"complex.h", "<complex.h>"},
363 {"condition_variable", "<condition_variable>"},
364 {"csetjmp", "<csetjmp>"},
365 {"csignal", "<csignal>"},
366 {"cstdalign", "<cstdalign>"},
367 {"cstdarg", "<cstdarg>"},
368 {"cstdbool", "<cstdbool>"},
369 {"cstdint", "<cstdint>"},
370 {"cstdio", "<cstdio>"},
371 {"cstdlib", "<cstdlib>"},
372 {"cstring", "<cstring>"},
373 {"ctgmath", "<ctgmath>"},
374 {"ctime", "<ctime>"},
375 {"cwchar", "<cwchar>"},
376 {"cwctype", "<cwctype>"},
377 {"cxxabi.h", "<cxxabi.h>"},
378 {"debug/debug.h", "<numeric>"},
379 {"debug/map.h", "<map>"},
380 {"debug/multimap.h", "<multimap>"},
381 {"debug/multiset.h", "<multiset>"},
382 {"debug/set.h", "<set>"},
383 {"deque", "<deque>"},
384 {"exception", "<exception>"},
385 {"ext/alloc_traits.h", "<deque>"},
386 {"ext/atomicity.h", "<memory>"},
387 {"ext/concurrence.h", "<memory>"},
388 {"ext/new_allocator.h", "<string>"},
389 {"ext/numeric_traits.h", "<list>"},
390 {"ext/string_conversions.h", "<string>"},
391 {"ext/type_traits.h", "<cmath>"},
392 {"fenv.h", "<fenv.h>"},
393 {"forward_list", "<forward_list>"},
394 {"fstream", "<fstream>"},
395 {"functional", "<functional>"},
396 {"future", "<future>"},
397 {"initializer_list", "<initializer_list>"},
398 {"iomanip", "<iomanip>"},
399 {"ios", "<ios>"},
400 {"iosfwd", "<iosfwd>"},
401 {"iostream", "<iostream>"},
402 {"istream", "<istream>"},
403 {"iterator", "<iterator>"},
404 {"limits", "<limits>"},
405 {"list", "<list>"},
406 {"locale", "<locale>"},
407 {"map", "<map>"},
408 {"memory", "<memory>"},
409 {"shared_mutex", "<shared_mutex>"},
410 {"mutex", "<mutex>"},
411 {"new", "<new>"},
412 {"numeric", "<numeric>"},
413 {"ostream", "<ostream>"},
414 {"queue", "<queue>"},
415 {"random", "<random>"},
416 {"ratio", "<ratio>"},
417 {"regex", "<regex>"},
418 {"scoped_allocator", "<scoped_allocator>"},
419 {"set", "<set>"},
420 {"sstream", "<sstream>"},
421 {"stack", "<stack>"},
422 {"stdexcept", "<stdexcept>"},
423 {"streambuf", "<streambuf>"},
424 {"string", "<string>"},
425 {"system_error", "<system_error>"},
426 {"tgmath.h", "<tgmath.h>"},
427 {"thread", "<thread>"},
428 {"tuple", "<tuple>"},
429 {"type_traits", "<type_traits>"},
430 {"typeindex", "<typeindex>"},
431 {"typeinfo", "<typeinfo>"},
432 {"unordered_map", "<unordered_map>"},
433 {"unordered_set", "<unordered_set>"},
434 {"utility", "<utility>"},
435 {"valarray", "<valarray>"},
436 {"vector", "<vector>"},
437 {"include/complex.h", "<complex.h>"},
438 {"include/ctype.h", "<cctype>"},
439 {"include/errno.h", "<cerrno>"},
440 {"include/fenv.h", "<fenv.h>"},
441 {"include/inttypes.h", "<cinttypes>"},
442 {"include/libio.h", "<cstdio>"},
443 {"include/limits.h", "<climits>"},
444 {"include/locale.h", "<clocale>"},
445 {"include/math.h", "<cmath>"},
446 {"include/setjmp.h", "<csetjmp>"},
447 {"include/signal.h", "<csignal>"},
448 {"include/stdint.h", "<cstdint>"},
449 {"include/stdio.h", "<cstdio>"},
450 {"include/stdlib.h", "<cstdlib>"},
451 {"include/string.h", "<cstring>"},
452 {"include/time.h", "<ctime>"},
453 {"include/wchar.h", "<cwchar>"},
454 {"include/wctype.h", "<cwctype>"},
455 {"bits/cmathcalls.h", "<complex.h>"},
456 {"bits/errno.h", "<cerrno>"},
457 {"bits/fenv.h", "<fenv.h>"},
458 {"bits/huge_val.h", "<cmath>"},
459 {"bits/huge_valf.h", "<cmath>"},
460 {"bits/huge_vall.h", "<cmath>"},
461 {"bits/inf.h", "<cmath>"},
462 {"bits/local_lim.h", "<climits>"},
463 {"bits/locale.h", "<clocale>"},
464 {"bits/mathcalls.h", "<math.h>"},
465 {"bits/mathdef.h", "<cmath>"},
466 {"bits/nan.h", "<cmath>"},
467 {"bits/posix1_lim.h", "<climits>"},
468 {"bits/posix2_lim.h", "<climits>"},
469 {"bits/setjmp.h", "<csetjmp>"},
470 {"bits/sigaction.h", "<csignal>"},
471 {"bits/sigcontext.h", "<csignal>"},
472 {"bits/siginfo.h", "<csignal>"},
473 {"bits/signum.h", "<csignal>"},
474 {"bits/sigset.h", "<csignal>"},
475 {"bits/sigstack.h", "<csignal>"},
476 {"bits/stdio_lim.h", "<cstdio>"},
477 {"bits/sys_errlist.h", "<cstdio>"},
478 {"bits/time.h", "<ctime>"},
479 {"bits/timex.h", "<ctime>"},
480 {"bits/typesizes.h", "<cstdio>"},
481 {"bits/wchar.h", "<cwchar>"},
482 {"bits/wordsize.h", "<csetjmp>"},
483 {"bits/xopen_lim.h", "<climits>"},
484 {"include/xlocale.h", "<cstring>"},
485 {"bits/atomic_word.h", "<memory>"},
486 {"bits/basic_file.h", "<fstream>"},
487 {"bits/c\\+\\+allocator.h", "<string>"},
488 {"bits/c\\+\\+config.h", "<cstddef>"},
489 {"bits/c\\+\\+io.h", "<ios>"},
490 {"bits/c\\+\\+locale.h", "<locale>"},
491 {"bits/cpu_defines.h", "<iosfwd>"},
492 {"bits/ctype_base.h", "<locale>"},
493 {"bits/cxxabi_tweaks.h", "<cxxabi.h>"},
494 {"bits/error_constants.h", "<system_error>"},
495 {"bits/gthr-default.h", "<memory>"},
496 {"bits/gthr.h", "<memory>"},
497 {"bits/opt_random.h", "<random>"},
498 {"bits/os_defines.h", "<iosfwd>"},
499 // GNU C headers
500 {"include/aio.h", "<aio.h>"},
501 {"include/aliases.h", "<aliases.h>"},
502 {"include/alloca.h", "<alloca.h>"},
503 {"include/ar.h", "<ar.h>"},
504 {"include/argp.h", "<argp.h>"},
505 {"include/argz.h", "<argz.h>"},
506 {"include/arpa/nameser.h", "<resolv.h>"},
507 {"include/arpa/nameser_compat.h", "<resolv.h>"},
508 {"include/byteswap.h", "<byteswap.h>"},
509 {"include/cpio.h", "<cpio.h>"},
510 {"include/crypt.h", "<crypt.h>"},
511 {"include/dirent.h", "<dirent.h>"},
512 {"include/dlfcn.h", "<dlfcn.h>"},
513 {"include/elf.h", "<elf.h>"},
514 {"include/endian.h", "<endian.h>"},
515 {"include/envz.h", "<envz.h>"},
516 {"include/err.h", "<err.h>"},
517 {"include/error.h", "<error.h>"},
518 {"include/execinfo.h", "<execinfo.h>"},
519 {"include/fcntl.h", "<fcntl.h>"},
520 {"include/features.h", "<features.h>"},
521 {"include/fenv.h", "<fenv.h>"},
522 {"include/fmtmsg.h", "<fmtmsg.h>"},
523 {"include/fnmatch.h", "<fnmatch.h>"},
524 {"include/fstab.h", "<fstab.h>"},
525 {"include/fts.h", "<fts.h>"},
526 {"include/ftw.h", "<ftw.h>"},
527 {"include/gconv.h", "<gconv.h>"},
528 {"include/getopt.h", "<getopt.h>"},
529 {"include/glob.h", "<glob.h>"},
530 {"include/grp.h", "<grp.h>"},
531 {"include/gshadow.h", "<gshadow.h>"},
532 {"include/iconv.h", "<iconv.h>"},
533 {"include/ifaddrs.h", "<ifaddrs.h>"},
534 {"include/kdb.h", "<kdb.h>"},
535 {"include/langinfo.h", "<langinfo.h>"},
536 {"include/libgen.h", "<libgen.h>"},
537 {"include/libintl.h", "<libintl.h>"},
538 {"include/link.h", "<link.h>"},
539 {"include/malloc.h", "<malloc.h>"},
540 {"include/mcheck.h", "<mcheck.h>"},
541 {"include/memory.h", "<memory.h>"},
542 {"include/mntent.h", "<mntent.h>"},
543 {"include/monetary.h", "<monetary.h>"},
544 {"include/mqueue.h", "<mqueue.h>"},
545 {"include/netdb.h", "<netdb.h>"},
546 {"include/netinet/in.h", "<netinet/in.h>"},
547 {"include/nl_types.h", "<nl_types.h>"},
548 {"include/nss.h", "<nss.h>"},
549 {"include/obstack.h", "<obstack.h>"},
550 {"include/panel.h", "<panel.h>"},
551 {"include/paths.h", "<paths.h>"},
552 {"include/printf.h", "<printf.h>"},
553 {"include/profile.h", "<profile.h>"},
554 {"include/pthread.h", "<pthread.h>"},
555 {"include/pty.h", "<pty.h>"},
556 {"include/pwd.h", "<pwd.h>"},
557 {"include/re_comp.h", "<re_comp.h>"},
558 {"include/regex.h", "<regex.h>"},
559 {"include/regexp.h", "<regexp.h>"},
560 {"include/resolv.h", "<resolv.h>"},
561 {"include/rpc/netdb.h", "<netdb.h>"},
562 {"include/sched.h", "<sched.h>"},
563 {"include/search.h", "<search.h>"},
564 {"include/semaphore.h", "<semaphore.h>"},
565 {"include/sgtty.h", "<sgtty.h>"},
566 {"include/shadow.h", "<shadow.h>"},
567 {"include/spawn.h", "<spawn.h>"},
568 {"include/stab.h", "<stab.h>"},
569 {"include/stdc-predef.h", "<stdc-predef.h>"},
570 {"include/stdio_ext.h", "<stdio_ext.h>"},
571 {"include/strings.h", "<strings.h>"},
572 {"include/stropts.h", "<stropts.h>"},
573 {"include/sudo_plugin.h", "<sudo_plugin.h>"},
574 {"include/sysexits.h", "<sysexits.h>"},
575 {"include/tar.h", "<tar.h>"},
576 {"include/tcpd.h", "<tcpd.h>"},
577 {"include/term.h", "<term.h>"},
578 {"include/term_entry.h", "<term_entry.h>"},
579 {"include/termcap.h", "<termcap.h>"},
580 {"include/termios.h", "<termios.h>"},
581 {"include/thread_db.h", "<thread_db.h>"},
582 {"include/tic.h", "<tic.h>"},
583 {"include/ttyent.h", "<ttyent.h>"},
584 {"include/uchar.h", "<uchar.h>"},
585 {"include/ucontext.h", "<ucontext.h>"},
586 {"include/ulimit.h", "<ulimit.h>"},
587 {"include/unctrl.h", "<unctrl.h>"},
588 {"include/unistd.h", "<unistd.h>"},
589 {"include/utime.h", "<utime.h>"},
590 {"include/utmp.h", "<utmp.h>"},
591 {"include/utmpx.h", "<utmpx.h>"},
592 {"include/values.h", "<values.h>"},
593 {"include/wordexp.h", "<wordexp.h>"},
594 {"fpu_control.h", "<fpu_control.h>"},
595 {"ieee754.h", "<ieee754.h>"},
596 {"include/xlocale.h", "<xlocale.h>"},
597 {"gnu/lib-names.h", "<gnu/lib-names.h>"},
598 {"gnu/libc-version.h", "<gnu/libc-version.h>"},
599 {"gnu/option-groups.h", "<gnu/option-groups.h>"},
600 {"gnu/stubs-32.h", "<gnu/stubs-32.h>"},
601 {"gnu/stubs-64.h", "<gnu/stubs-64.h>"},
602 {"gnu/stubs-x32.h", "<gnu/stubs-x32.h>"},
603 {"include/rpc/auth_des.h", "<rpc/auth_des.h>"},
604 {"include/rpc/rpc_msg.h", "<rpc/rpc_msg.h>"},
605 {"include/rpc/pmap_clnt.h", "<rpc/pmap_clnt.h>"},
606 {"include/rpc/rpc.h", "<rpc/rpc.h>"},
607 {"include/rpc/types.h", "<rpc/types.h>"},
608 {"include/rpc/auth_unix.h", "<rpc/auth_unix.h>"},
609 {"include/rpc/key_prot.h", "<rpc/key_prot.h>"},
610 {"include/rpc/pmap_prot.h", "<rpc/pmap_prot.h>"},
611 {"include/rpc/auth.h", "<rpc/auth.h>"},
612 {"include/rpc/svc_auth.h", "<rpc/svc_auth.h>"},
613 {"include/rpc/xdr.h", "<rpc/xdr.h>"},
614 {"include/rpc/pmap_rmt.h", "<rpc/pmap_rmt.h>"},
615 {"include/rpc/des_crypt.h", "<rpc/des_crypt.h>"},
616 {"include/rpc/svc.h", "<rpc/svc.h>"},
617 {"include/rpc/rpc_des.h", "<rpc/rpc_des.h>"},
618 {"include/rpc/clnt.h", "<rpc/clnt.h>"},
619 {"include/scsi/scsi.h", "<scsi/scsi.h>"},
620 {"include/scsi/sg.h", "<scsi/sg.h>"},
621 {"include/scsi/scsi_ioctl.h", "<scsi/scsi_ioctl>"},
622 {"include/netrose/rose.h", "<netrose/rose.h>"},
623 {"include/nfs/nfs.h", "<nfs/nfs.h>"},
624 {"include/netatalk/at.h", "<netatalk/at.h>"},
625 {"include/netinet/ether.h", "<netinet/ether.h>"},
626 {"include/netinet/icmp6.h", "<netinet/icmp6.h>"},
627 {"include/netinet/if_ether.h", "<netinet/if_ether.h>"},
628 {"include/netinet/if_fddi.h", "<netinet/if_fddi.h>"},
629 {"include/netinet/if_tr.h", "<netinet/if_tr.h>"},
630 {"include/netinet/igmp.h", "<netinet/igmp.h>"},
631 {"include/netinet/in.h", "<netinet/in.h>"},
632 {"include/netinet/in_systm.h", "<netinet/in_systm.h>"},
633 {"include/netinet/ip.h", "<netinet/ip.h>"},
634 {"include/netinet/ip6.h", "<netinet/ip6.h>"},
635 {"include/netinet/ip_icmp.h", "<netinet/ip_icmp.h>"},
636 {"include/netinet/tcp.h", "<netinet/tcp.h>"},
637 {"include/netinet/udp.h", "<netinet/udp.h>"},
638 {"include/netrom/netrom.h", "<netrom/netrom.h>"},
639 {"include/protocols/routed.h", "<protocols/routed.h>"},
640 {"include/protocols/rwhod.h", "<protocols/rwhod.h>"},
641 {"include/protocols/talkd.h", "<protocols/talkd.h>"},
642 {"include/protocols/timed.h", "<protocols/timed.h>"},
643 {"include/rpcsvc/klm_prot.x", "<rpcsvc/klm_prot.x>"},
644 {"include/rpcsvc/rstat.h", "<rpcsvc/rstat.h>"},
645 {"include/rpcsvc/spray.x", "<rpcsvc/spray.x>"},
646 {"include/rpcsvc/nlm_prot.x", "<rpcsvc/nlm_prot.x>"},
647 {"include/rpcsvc/nis_callback.x", "<rpcsvc/nis_callback.x>"},
648 {"include/rpcsvc/yp.h", "<rpcsvc/yp.h>"},
649 {"include/rpcsvc/yp.x", "<rpcsvc/yp.x>"},
650 {"include/rpcsvc/nfs_prot.h", "<rpcsvc/nfs_prot.h>"},
651 {"include/rpcsvc/rex.h", "<rpcsvc/rex.h>"},
652 {"include/rpcsvc/yppasswd.h", "<rpcsvc/yppasswd.h>"},
653 {"include/rpcsvc/rex.x", "<rpcsvc/rex.x>"},
654 {"include/rpcsvc/nis_tags.h", "<rpcsvc/nis_tags.h>"},
655 {"include/rpcsvc/nis_callback.h", "<rpcsvc/nis_callback.h>"},
656 {"include/rpcsvc/nfs_prot.x", "<rpcsvc/nfs_prot.x>"},
657 {"include/rpcsvc/bootparam_prot.x", "<rpcsvc/bootparam_prot.x>"},
658 {"include/rpcsvc/rusers.x", "<rpcsvc/rusers.x>"},
659 {"include/rpcsvc/rquota.x", "<rpcsvc/rquota.x>"},
660 {"include/rpcsvc/nis.h", "<rpcsvc/nis.h>"},
661 {"include/rpcsvc/nislib.h", "<rpcsvc/nislib.h>"},
662 {"include/rpcsvc/ypupd.h", "<rpcsvc/ypupd.h>"},
663 {"include/rpcsvc/bootparam.h", "<rpcsvc/bootparam.h>"},
664 {"include/rpcsvc/spray.h", "<rpcsvc/spray.h>"},
665 {"include/rpcsvc/key_prot.h", "<rpcsvc/key_prot.h>"},
666 {"include/rpcsvc/klm_prot.h", "<rpcsvc/klm_prot.h>"},
667 {"include/rpcsvc/sm_inter.h", "<rpcsvc/sm_inter.h>"},
668 {"include/rpcsvc/nlm_prot.h", "<rpcsvc/nlm_prot.h>"},
669 {"include/rpcsvc/yp_prot.h", "<rpcsvc/yp_prot.h>"},
670 {"include/rpcsvc/ypclnt.h", "<rpcsvc/ypclnt.h>"},
671 {"include/rpcsvc/rstat.x", "<rpcsvc/rstat.x>"},
672 {"include/rpcsvc/rusers.h", "<rpcsvc/rusers.h>"},
673 {"include/rpcsvc/key_prot.x", "<rpcsvc/key_prot.x>"},
674 {"include/rpcsvc/sm_inter.x", "<rpcsvc/sm_inter.x>"},
675 {"include/rpcsvc/rquota.h", "<rpcsvc/rquota.h>"},
676 {"include/rpcsvc/nis.x", "<rpcsvc/nis.x>"},
677 {"include/rpcsvc/bootparam_prot.h", "<rpcsvc/bootparam_prot.h>"},
678 {"include/rpcsvc/mount.h", "<rpcsvc/mount.h>"},
679 {"include/rpcsvc/mount.x", "<rpcsvc/mount.x>"},
680 {"include/rpcsvc/nis_object.x", "<rpcsvc/nis_object.x>"},
681 {"include/rpcsvc/yppasswd.x", "<rpcsvc/yppasswd.x>"},
682 {"sys/acct.h", "<sys/acct.h>"},
683 {"sys/auxv.h", "<sys/auxv.h>"},
684 {"sys/cdefs.h", "<sys/cdefs.h>"},
685 {"sys/debugreg.h", "<sys/debugreg.h>"},
686 {"sys/dir.h", "<sys/dir.h>"},
687 {"sys/elf.h", "<sys/elf.h>"},
688 {"sys/epoll.h", "<sys/epoll.h>"},
689 {"sys/eventfd.h", "<sys/eventfd.h>"},
690 {"sys/fanotify.h", "<sys/fanotify.h>"},
691 {"sys/file.h", "<sys/file.h>"},
692 {"sys/fsuid.h", "<sys/fsuid.h>"},
693 {"sys/gmon.h", "<sys/gmon.h>"},
694 {"sys/gmon_out.h", "<sys/gmon_out.h>"},
695 {"sys/inotify.h", "<sys/inotify.h>"},
696 {"sys/io.h", "<sys/io.h>"},
697 {"sys/ioctl.h", "<sys/ioctl.h>"},
698 {"sys/ipc.h", "<sys/ipc.h>"},
699 {"sys/kd.h", "<sys/kd.h>"},
700 {"sys/kdaemon.h", "<sys/kdaemon.h>"},
701 {"sys/klog.h", "<sys/klog.h>"},
702 {"sys/mman.h", "<sys/mman.h>"},
703 {"sys/mount.h", "<sys/mount.h>"},
704 {"sys/msg.h", "<sys/msg.h>"},
705 {"sys/mtio.h", "<sys/mtio.h>"},
706 {"sys/param.h", "<sys/param.h>"},
707 {"sys/pci.h", "<sys/pci.h>"},
708 {"sys/perm.h", "<sys/perm.h>"},
709 {"sys/personality.h", "<sys/personality.h>"},
710 {"sys/poll.h", "<sys/poll.h>"},
711 {"sys/prctl.h", "<sys/prctl.h>"},
712 {"sys/procfs.h", "<sys/procfs.h>"},
713 {"sys/profil.h", "<sys/profil.h>"},
714 {"sys/ptrace.h", "<sys/ptrace.h>"},
715 {"sys/queue.h", "<sys/queue.h>"},
716 {"sys/quota.h", "<sys/quota.h>"},
717 {"sys/raw.h", "<sys/raw.h>"},
718 {"sys/reboot.h", "<sys/reboot.h>"},
719 {"sys/reg.h", "<sys/reg.h>"},
720 {"sys/resource.h", "<sys/resource.h>"},
721 {"sys/select.h", "<sys/select.h>"},
722 {"sys/sem.h", "<sys/sem.h>"},
723 {"sys/sendfile.h", "<sys/sendfile.h>"},
724 {"sys/shm.h", "<sys/shm.h>"},
725 {"sys/signalfd.h", "<sys/signalfd.h>"},
726 {"sys/socket.h", "<sys/socket.h>"},
727 {"sys/stat.h", "<sys/stat.h>"},
728 {"sys/statfs.h", "<sys/statfs.h>"},
729 {"sys/statvfs.h", "<sys/statvfs.h>"},
730 {"sys/swap.h", "<sys/swap.h>"},
731 {"sys/syscall.h", "<sys/syscall.h>"},
732 {"sys/sysctl.h", "<sys/sysctl.h>"},
733 {"sys/sysinfo.h", "<sys/sysinfo.h>"},
734 {"sys/syslog.h", "<sys/syslog.h>"},
735 {"sys/sysmacros.h", "<sys/sysmacros.h>"},
736 {"sys/termios.h", "<sys/termios.h>"},
737 {"sys/time.h", "<sys/select.h>"},
738 {"sys/timeb.h", "<sys/timeb.h>"},
739 {"sys/timerfd.h", "<sys/timerfd.h>"},
740 {"sys/times.h", "<sys/times.h>"},
741 {"sys/timex.h", "<sys/timex.h>"},
742 {"sys/ttychars.h", "<sys/ttychars.h>"},
743 {"sys/ttydefaults.h", "<sys/ttydefaults.h>"},
744 {"sys/types.h", "<sys/types.h>"},
745 {"sys/ucontext.h", "<sys/ucontext.h>"},
746 {"sys/uio.h", "<sys/uio.h>"},
747 {"sys/un.h", "<sys/un.h>"},
748 {"sys/user.h", "<sys/user.h>"},
749 {"sys/ustat.h", "<sys/ustat.h>"},
750 {"sys/utsname.h", "<sys/utsname.h>"},
751 {"sys/vlimit.h", "<sys/vlimit.h>"},
752 {"sys/vm86.h", "<sys/vm86.h>"},
753 {"sys/vtimes.h", "<sys/vtimes.h>"},
754 {"sys/wait.h", "<sys/wait.h>"},
755 {"sys/xattr.h", "<sys/xattr.h>"},
756 {"bits/epoll.h", "<sys/epoll.h>"},
757 {"bits/eventfd.h", "<sys/eventfd.h>"},
758 {"bits/inotify.h", "<sys/inotify.h>"},
759 {"bits/ipc.h", "<sys/ipc.h>"},
760 {"bits/ipctypes.h", "<sys/ipc.h>"},
761 {"bits/mman-linux.h", "<sys/mman.h>"},
762 {"bits/mman.h", "<sys/mman.h>"},
763 {"bits/msq.h", "<sys/msg.h>"},
764 {"bits/resource.h", "<sys/resource.h>"},
765 {"bits/sem.h", "<sys/sem.h>"},
766 {"bits/shm.h", "<sys/shm.h>"},
767 {"bits/signalfd.h", "<sys/signalfd.h>"},
768 {"bits/statfs.h", "<sys/statfs.h>"},
769 {"bits/statvfs.h", "<sys/statvfs.h>"},
770 {"bits/timerfd.h", "<sys/timerfd.h>"},
771 {"bits/utsname.h", "<sys/utsname.h>"},
772 {"bits/auxv.h", "<sys/auxv.h>"},
773 {"bits/byteswap-16.h", "<byteswap.h>"},
774 {"bits/byteswap.h", "<byteswap.h>"},
775 {"bits/confname.h", "<unistd.h>"},
776 {"bits/dirent.h", "<dirent.h>"},
777 {"bits/dlfcn.h", "<dlfcn.h>"},
778 {"bits/elfclass.h", "<link.h>"},
779 {"bits/endian.h", "<endian.h>"},
780 {"bits/environments.h", "<unistd.h>"},
781 {"bits/fcntl-linux.h", "<fcntl.h>"},
782 {"bits/fcntl.h", "<fcntl.h>"},
783 {"bits/in.h", "<netinet/in.h>"},
784 {"bits/ioctl-types.h", "<sys/ioctl.h>"},
785 {"bits/ioctls.h", "<sys/ioctl.h>"},
786 {"bits/link.h", "<link.h>"},
787 {"bits/mqueue.h", "<mqueue.h>"},
788 {"bits/netdb.h", "<netdb.h>"},
789 {"bits/param.h", "<sys/param.h>"},
790 {"bits/poll.h", "<sys/poll.h>"},
791 {"bits/posix_opt.h", "<bits/posix_opt.h>"},
792 {"bits/pthreadtypes.h", "<pthread.h>"},
793 {"bits/sched.h", "<sched.h>"},
794 {"bits/select.h", "<sys/select.h>"},
795 {"bits/semaphore.h", "<semaphore.h>"},
796 {"bits/sigthread.h", "<pthread.h>"},
797 {"bits/sockaddr.h", "<sys/socket.h>"},
798 {"bits/socket.h", "<sys/socket.h>"},
799 {"bits/socket_type.h", "<sys/socket.h>"},
800 {"bits/stab.def", "<stab.h>"},
801 {"bits/stat.h", "<sys/stat.h>"},
802 {"bits/stropts.h", "<stropts.h>"},
803 {"bits/syscall.h", "<sys/syscall.h>"},
804 {"bits/syslog-path.h", "<sys/syslog.h>"},
805 {"bits/termios.h", "<termios.h>"},
806 {"bits/types.h", "<sys/types.h>"},
807 {"bits/typesizes.h", "<sys/types.h>"},
808 {"bits/uio.h", "<sys/uio.h>"},
809 {"bits/ustat.h", "<sys/ustat.h>"},
810 {"bits/utmp.h", "<utmp.h>"},
811 {"bits/utmpx.h", "<utmpx.h>"},
812 {"bits/waitflags.h", "<sys/wait.h>"},
813 {"bits/waitstatus.h", "<sys/wait.h>"},
814 {"bits/xtitypes.h", "<stropts.h>"},
815 };
816 for (const auto &Pair : SystemHeaderMap)
817 Includes->addPathSuffixMapping(Pair.first, Pair.second);
818 }
819
820 } // namespace clangd
821 } // namespace clang
clang::clangd::collectIWYUHeaderMaps
std::unique_ptr< CommentHandler > collectIWYUHeaderMaps(CanonicalIncludes *Includes)
Returns a CommentHandler that parses pragma comment on include files to determine when we should incl...
Definition: CanonicalIncludes.cpp:84
clang::clangd::CanonicalIncludes::addSymbolMapping
void addSymbolMapping(llvm::StringRef QualifiedName, llvm::StringRef CanonicalPath)
Sets the canonical include for any symbol with QualifiedName.
Definition: CanonicalIncludes.cpp:35
Headers.h
CanonicalIncludes.h
clang::clangd::CompletionItemKind::Text
clang::clangd::CanonicalIncludes
Maps a definition location onto an #include file, based on a set of filename rules.
Definition: CanonicalIncludes.h:36
clang::clangd::CanonicalIncludes::addMapping
void addMapping(llvm::StringRef Path, llvm::StringRef CanonicalPath)
Adds a string-to-string mapping from Path to CanonicalPath.
Definition: CanonicalIncludes.cpp:30
clang::clangd::Range
Definition: Protocol.h:154
clang::clangd::Path
std::string Path
A typedef to represent a file path.
Definition: Path.h:21
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::clangd::CanonicalIncludes::mapHeader
llvm::StringRef mapHeader(llvm::ArrayRef< std::string > Headers, llvm::StringRef QualifiedName) const
Returns the canonical include for symbol with QualifiedName.
Definition: CanonicalIncludes.cpp:41
clang::clangd::addSystemHeadersMapping
void addSystemHeadersMapping(CanonicalIncludes *Includes)
Adds mapping for system headers and some special symbols (e.g.
Definition: CanonicalIncludes.cpp:109
clang::clangd::isLiteralInclude
bool isLiteralInclude(llvm::StringRef Include)
Returns true if Include is literal include like "path" or <path>.
Definition: Headers.cpp:68
clang::clangd::CanonicalIncludes::addPathSuffixMapping
void addPathSuffixMapping(llvm::StringRef Suffix, llvm::StringRef CanonicalPath)
Maps files with last path components matching Suffix to CanonicalPath.
Definition: CanonicalIncludes.cpp:22