@@ -345,6 +345,18 @@ local final DEFAULT_HEADERS_BY_INCLUDE: {string: Header} = {
345345#undef DEFAULT_HEADER
346346}.frozen;
347347
348+ local final DEFAULT_HEADERS_BY_EXPORT: {string: Set with {Header...}} = (() -> {
349+ local byExport: {string: Set with {Header...}} = Dict();
350+ for (local hdr: DEFAULT_HEADERS_BY_INCLUDE.values) {
351+ for (local export: hdr.exports) {
352+ local exp = byExport.get(export);
353+ if (exp is none)
354+ byExport[export] = exp = HashSet();
355+ exp.insert({hdr});
356+ }
357+ }
358+ return byExport.frozen;
359+ })();
348360
349361class SrcIncludeInfo {
350362 this = default;
@@ -1475,7 +1487,8 @@ insert_first_include:
14751487 if (combination.any(e -> e.filename == filename))
14761488 goto next_keyword; /* Symbol is defined by the file we're trying to fix -> ignore */
14771489 if (combination.all(e -> (
1478- (e.filename in includedFilenames)
1490+ (e.filename in includedFilenames) ||
1491+ (e.includes.any(includedSystemIncludes.operator contains))
14791492 ))) {
14801493 goto next_keyword; /* Symbol is defined by the file we're trying to fix -> ignore */
14811494 }
@@ -1489,7 +1502,8 @@ insert_first_include:
14891502 for (local hdr: combination) {
14901503 local hdrFilename = hdr.filename;
14911504 if (hdrFilename !in includedFilenames &&
1492- hdrFilename !in missingByFilename)
1505+ !hdr.includes.any(includedSystemIncludes.operator contains) &&
1506+ (hdr.filename ?? hdr.shortestInclude) !in missingByFilename)
14931507 stillMissingIncludes += 2;
14941508 if (kwd in hdr.exportsFromAlwaysIncludes)
14951509 stillMissingIncludes += 1; /* Discourage this inclusion over the original header */
@@ -1502,10 +1516,10 @@ insert_first_include:
15021516 }
15031517 assert usedCombination !is none;
15041518 for (local hdr: usedCombination) {
1505- local hdrFilename = hdr.filename;
1506- local importedKeywords: (Set with string) | none = missingByFilename.get(hdrFilename );
1519+ local hdrIdent = hdr.filename ?? hdr.shortestInclude ;
1520+ local importedKeywords: (Set with string) | none = missingByFilename.get(hdrIdent );
15071521 if (importedKeywords is none) {
1508- missingByFilename[hdrFilename ] = importedKeywords = HashSet();
1522+ missingByFilename[hdrIdent ] = importedKeywords = HashSet();
15091523 missingHeaders.append(hdr);
15101524 }
15111525 importedKeywords.insert(kwd);
@@ -1514,7 +1528,7 @@ next_keyword:;
15141528 }
15151529 return (
15161530 for (local hdr: missingHeaders)
1517- (hdr, missingByFilename[hdr.filename])
1531+ (hdr, missingByFilename[hdr.filename ?? hdr.shortestInclude ])
15181532 );
15191533 }
15201534
@@ -1980,7 +1994,10 @@ class FixIncludes {
19801994 @@always included by other headers are replace with those other headers
19811995 @@in the returned sequence.
19821996 public function getHeaderByExport(keyword: string): Set with {Header...} {
1983- return headersByExport.get(keyword, {});
1997+ local result: (Set with {Header...}) | none = headersByExport.get(keyword);
1998+ if (result is none)
1999+ result = DEFAULT_HEADERS_BY_EXPORT.get(keyword, Set());
2000+ return result;
19842001 }
19852002
19862003 @@Return the header specified by @dep and included by @base
0 commit comments