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,242 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// XFAIL: modules-build +// RUN: clang-tidy %s --warnings-as-errors=* -header-filter=.* -- -Wno-unknown-warning-option %{compile_flags} +// -------------------------------------------------------------- ^ ignore GCC warnings unknown to clang + +// Prevent from generating deprecated warnings for this test. +#if defined(__DEPRECATED) +# undef __DEPRECATED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// 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 +//////////////////////////////////////////////////////////////////////////////// diff --git a/libcxx/test/libcxx/lint/lint_headers.sh.py b/libcxx/test/libcxx/lint/lint_headers.sh.py --- a/libcxx/test/libcxx/lint/lint_headers.sh.py +++ b/libcxx/test/libcxx/lint/lint_headers.sh.py @@ -44,17 +44,4 @@ if pretty(fname) not in ['__undef_macros']: okay = False print('FAILED TO FIND # pragma GCC system_header in libcxx/include/%s!' % pretty(fname)) - - # 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 @@ -202,6 +202,7 @@ def main(): + produce_test('clang_tidy.sh.cpp') produce_test('double_include.sh.cpp') produce_test('min_max_macros.compile.pass.cpp', post_include='TEST_MACROS();') produce_test('nasty_macros.compile.pass.cpp') 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 @@ -83,6 +83,8 @@ # manages to find binaries to execute. Feature(name='executor-has-no-bash', when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash -c \'bash --version\'']) != 0), + Feature(name='has-clang-tidy', + when=lambda cfg: runScriptExitCode(cfg, ['clang-tidy --version']) == 0), Feature(name='apple-clang', when=_isAppleClang), Feature(name=lambda cfg: 'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)), when=_isAppleClang),