X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2Fsort_includes.py;h=fef97550db8d8f84ec5e012246ecbf2ca5d88424;hb=71857ccdb83b6374f7a791c2dae45ce9934a85af;hp=c1500f52e043958d9945d506bf620c91a25ca39a;hpb=fd025797ea5197b838f87ce57f2df5bccf27ad20;p=oota-llvm.git diff --git a/utils/sort_includes.py b/utils/sort_includes.py index c1500f52e04..fef97550db8 100755 --- a/utils/sort_includes.py +++ b/utils/sort_includes.py @@ -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:]