[x86] Fix PR22706 where we would incorrectly try lower a v32i8 dynamic
[oota-llvm.git] / utils / sort_includes.py
index c1500f52e043958d9945d506bf620c91a25ca39a..fef97550db8d8f84ec5e012246ecbf2ca5d88424 100755 (executable)
@@ -18,8 +18,12 @@ def sort_includes(f):
   if 'INPUTS/' in f.name or 'test/' in f.name:
     return
 
+  ext = os.path.splitext(f.name)[1]
+  if ext not in ['.cpp', '.c', '.h', '.inc', '.def']:
+    return
+
   lines = f.readlines()
-  look_for_api_header = os.path.splitext(f.name)[1] == '.cpp'
+  look_for_api_header = ext in ['.cpp', '.c']
   found_headers = False
   headers_begin = 0
   headers_end = 0
@@ -60,9 +64,9 @@ def sort_includes(f):
   if not found_headers:
     return
 
-  local_headers.sort()
-  project_headers.sort()
-  system_headers.sort()
+  local_headers = sorted(set(local_headers))
+  project_headers = sorted(set(project_headers))
+  system_headers = sorted(set(system_headers))
   headers = api_headers + local_headers + project_headers + system_headers
   header_lines = ['#include ' + h for h in headers]
   lines = lines[:headers_begin] + header_lines + lines[headers_end + 1:]