diff --git a/libcxx/.clang-tidy b/libcxx/.clang-tidy --- a/libcxx/.clang-tidy +++ b/libcxx/.clang-tidy @@ -1,2 +1,2 @@ InheritParentConfig: true -Checks: '-readability-identifier-naming,-llvm-header-guard,-llvm-include-order,-misc-unconventional-assign-operator,-llvm-else-after-return' +Checks: '-readability-identifier-naming,-llvm-header-guard,-misc-unconventional-assign-operator,-llvm-else-after-return' diff --git a/libcxx/test/libcxx/clang_tidy.sh.cpp b/libcxx/test/libcxx/clang_tidy.sh.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/clang_tidy.sh.cpp @@ -0,0 +1,240 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: !has-clang-tidy +// RUN: clang-tidy %s --warnings-as-errors=* -header-filter=.* -- %{compile_flags} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-W#warnings" + +//////////////////////////////////////////////////////////////////////////////// +// BEGIN-GENERATED-HEADERS +//////////////////////////////////////////////////////////////////////////////// + +// clang-format off + +// WARNING: This test was generated by generate_header_tests.py +// and should not be edited manually. + +// Top level headers +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +#endif +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +#endif +#include +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#include +#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +#endif +#include +#include +#ifndef _LIBCPP_HAS_NO_THREADS +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +#endif +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +#endif + +// experimental headers +#if __cplusplus >= 201103L +# include +# ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES +# include +# endif +# include +# ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY +# include +# endif +# include +# include +# include +# include +# include +# include +# include +# ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +# endif +# include +# include +# include +# include +# include +# include +# include +# include +#endif // __cplusplus >= 201103L + +// extended headers +#include +#include + +// clang-format on + +//////////////////////////////////////////////////////////////////////////////// +// END-GENERATED-HEADERS +//////////////////////////////////////////////////////////////////////////////// + +#pragma clang diagnostic pop diff --git a/libcxx/test/libcxx/lint/lint_headers.sh.py b/libcxx/test/libcxx/lint/lint_headers.sh.py deleted file mode 100644 --- a/libcxx/test/libcxx/lint/lint_headers.sh.py +++ /dev/null @@ -1,52 +0,0 @@ -# RUN: %{python} %s - -# Verify that each run of consecutive #include directives -# in each libcxx/include/ header is maintained in alphabetical order. - -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 diff --git a/libcxx/utils/generate_header_tests.py b/libcxx/utils/generate_header_tests.py --- a/libcxx/utils/generate_header_tests.py +++ b/libcxx/utils/generate_header_tests.py @@ -206,6 +206,7 @@ produce_test('min_max_macros.compile.pass.cpp', post_include='TEST_MACROS();') produce_test('nasty_macros.compile.pass.cpp') produce_test('no_assert_include.compile.pass.cpp', exclusions=['cassert']) + produce_test('clang_tidy.sh.cpp') if __name__ == '__main__': diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -103,6 +103,9 @@ Feature(name='msvc', when=_isMSVC), Feature(name=lambda cfg: 'msvc-{}'.format(*_msvcVersion(cfg)), when=_isMSVC), Feature(name=lambda cfg: 'msvc-{}.{}'.format(*_msvcVersion(cfg)), when=_isMSVC), + + Feature(name='has-clang-tidy', + when=lambda cfg: runScriptExitCode(cfg, ['clang-tidy --version']) == 0), ] # Deduce and add the test features that that are implied by the #defines in