Index: libcxx/include/CMakeLists.txt =================================================================== --- libcxx/include/CMakeLists.txt +++ libcxx/include/CMakeLists.txt @@ -23,8 +23,8 @@ __algorithm/find_if_not.h __algorithm/for_each.h __algorithm/for_each_n.h - __algorithm/generate.h __algorithm/generate_n.h + __algorithm/generate.h __algorithm/half_positive.h __algorithm/includes.h __algorithm/inplace_merge.h Index: libcxx/include/__debug =================================================================== --- libcxx/include/__debug +++ libcxx/include/__debug @@ -22,9 +22,9 @@ #endif #if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) -# include -# include # include +# include +# include #endif #if _LIBCPP_DEBUG_LEVEL == 0 Index: libcxx/include/__iterator/ostream_iterator.h =================================================================== --- libcxx/include/__iterator/ostream_iterator.h +++ libcxx/include/__iterator/ostream_iterator.h @@ -11,8 +11,8 @@ #define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H #include <__config> -#include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> +#include <__iterator/iterator.h> #include <__memory/addressof.h> #include // for forward declarations of char_traits and basic_ostream Index: libcxx/include/algorithm =================================================================== --- libcxx/include/algorithm +++ libcxx/include/algorithm @@ -680,8 +680,8 @@ #include <__algorithm/find_first_of.h> #include <__algorithm/find_if.h> #include <__algorithm/find_if_not.h> -#include <__algorithm/for_each.h> #include <__algorithm/for_each_n.h> +#include <__algorithm/for_each.h> #include <__algorithm/generate.h> #include <__algorithm/generate_n.h> #include <__algorithm/half_positive.h> Index: libcxx/include/module.modulemap =================================================================== --- libcxx/include/module.modulemap +++ libcxx/include/module.modulemap @@ -266,8 +266,8 @@ module minmax { private header "__algorithm/minmax.h" } module minmax_element { private header "__algorithm/minmax_element.h" } module mismatch { private header "__algorithm/mismatch.h" } - module move { private header "__algorithm/move.h" } module move_backward { private header "__algorithm/move_backward.h" } + module move { private header "__algorithm/move.h" } module next_permutation { private header "__algorithm/next_permutation.h" } module none_of { private header "__algorithm/none_of.h" } module nth_element { private header "__algorithm/nth_element.h" } Index: libcxx/test/libcxx/lint/lint_cmakelists.sh.py =================================================================== --- /dev/null +++ libcxx/test/libcxx/lint/lint_cmakelists.sh.py @@ -0,0 +1,28 @@ +# RUN: %{python} %s + +import os + + +if __name__ == '__main__': + libcxx_test_libcxx_lint = os.path.dirname(os.path.abspath(__file__)) + libcxx = os.path.abspath(os.path.join(libcxx_test_libcxx_lint, '..', '..', '..')) + cmakelists_name = os.path.join(libcxx, 'include', 'CMakeLists.txt') + assert os.path.isfile(cmakelists_name) + + with open(cmakelists_name, 'r') as f: + lines = f.readlines() + + assert lines[0] == 'set(files\n' + + okay = True + prevline = lines[1] + for line in lines[2:]: + if (line == ' )\n'): + break + if (line < prevline): + okay = False + print('LINES OUT OF ORDER in libcxx/include/CMakeLists.txt!') + print(prevline) + print(line) + prevline = line + assert okay Index: libcxx/test/libcxx/lint/lint_headers.sh.py =================================================================== --- /dev/null +++ libcxx/test/libcxx/lint/lint_headers.sh.py @@ -0,0 +1,49 @@ +# RUN: %{python} %s + +import glob +import os +import re + + +def exclude_from_consideration(path): + return ( + path.endswith('.txt') or + path.endswith('.modulemap') or + os.path.basename(path) == '__config' or + os.path.basename(path) == '__locale' or + not os.path.isfile(path) + ) + + +if __name__ == '__main__': + libcxx_test_libcxx_lint = os.path.dirname(os.path.abspath(__file__)) + libcxx_include = os.path.abspath(os.path.join(libcxx_test_libcxx_lint, '../../../include')) + assert os.path.isdir(libcxx_include) + + def pretty(path): + return path[len(libcxx_include) + 1:] + + all_headers = [ + p for p in ( + glob.glob(os.path.join(libcxx_include, '*')) + + glob.glob(os.path.join(libcxx_include, '__*/*.h')) + ) if not exclude_from_consideration(p) + ] + + okay = True + for fname in all_headers: + with open(fname, 'r') as f: + lines = f.readlines() + # Examine each consecutive run of #include directives. + prevline = None + for line in lines: + if re.match(r'^\s*#\s*include ', line): + if (prevline is not None) and (line < prevline): + okay = False + print('LINES OUT OF ORDER in libcxx/include/%s!' % pretty(fname)) + print(prevline) + print(line) + prevline = line + else: + prevline = None + assert okay Index: libcxx/test/libcxx/lint/lint_modulemap.sh.py =================================================================== --- /dev/null +++ libcxx/test/libcxx/lint/lint_modulemap.sh.py @@ -0,0 +1,27 @@ +# RUN: %{python} %s + +import os +import re + + +if __name__ == '__main__': + libcxx_test_libcxx_lint = os.path.dirname(os.path.abspath(__file__)) + libcxx = os.path.abspath(os.path.join(libcxx_test_libcxx_lint, '..', '..', '..')) + modulemap_name = os.path.join(libcxx, 'include', 'module.modulemap') + print(modulemap_name) + assert os.path.isfile(modulemap_name) + + okay = True + prevline = None + with open(modulemap_name, 'r') as f: + for line in f.readlines(): + if re.match(r'^\s*module.*[{]\s*private', line): + if (prevline is not None) and (line < prevline): + okay = False + print('LINES OUT OF ORDER in libcxx/include/module.modulemap!') + print(prevline) + print(line) + prevline = line + else: + prevline = None + assert okay Index: libcxx/test/libcxx/lint/lit.local.cfg =================================================================== --- /dev/null +++ libcxx/test/libcxx/lint/lit.local.cfg @@ -0,0 +1,3 @@ +# The tests in this directory need to run Python +import pipes, sys +config.substitutions.append(('%{python}', pipes.quote(sys.executable)))