Merge "Stop the kernel header scrubber from duplicating includes." into main

This commit is contained in:
Treehugger Robot 2023-11-28 23:03:37 +00:00 committed by Gerrit Code Review
commit 4195a49880

View file

@ -1202,7 +1202,7 @@ class BlockList(object):
def removeStructs(self, structs):
"""Remove structs."""
extra_includes = []
extra_includes = set()
block_num = 0
num_blocks = len(self.blocks)
while block_num < num_blocks:
@ -1248,7 +1248,7 @@ class BlockList(object):
# #include <bits/STRUCT_NAME.h>
struct_token = b.tokens[i + 1]
if not structs[struct_token.id]:
extra_includes.append("<bits/%s.h>" % struct_token.id)
extra_includes.add("<bits/%s.h>" % struct_token.id)
# Search forward for the end of the structure.
# Very simple search, look for } and ; tokens.
@ -1292,7 +1292,7 @@ class BlockList(object):
continue
i += 1
for extra_include in extra_includes:
for extra_include in sorted(extra_includes):
replacement = CppStringTokenizer(extra_include)
self.blocks.insert(2, Block(replacement.tokens, directive='include'))