[libcxx-commits] [libcxx] f10909a - [libc++][test] Run clang-tidy during CI
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 15 15:22:22 PST 2022
Author: Nikolas Klauser
Date: 2022-02-16T00:22:08+01:00
New Revision: f10909a50823906e8926a4710a0400f9cc850ae6
URL: https://github.com/llvm/llvm-project/commit/f10909a50823906e8926a4710a0400f9cc850ae6
DIFF: https://github.com/llvm/llvm-project/commit/f10909a50823906e8926a4710a0400f9cc850ae6.diff
LOG: [libc++][test] Run clang-tidy during CI
I'm trying to get libc++ to the point of being able to run clang-tidy. This is a PR to see if clang-tidy is happy with all the CI configs.
Reviewed By: Quuxplusone, ldionne, #libc
Spies: mgorny, aheejin, libcxx-commits, arichardson
Differential Revision: https://reviews.llvm.org/D117174
Added:
libcxx/test/libcxx/clang_tidy.sh.cpp
Modified:
libcxx/.clang-tidy
libcxx/test/libcxx/lint/lint_headers.sh.py
libcxx/utils/generate_header_tests.py
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/.clang-tidy b/libcxx/.clang-tidy
index 7dab781ee1a3..afa5d29f4079 100644
--- 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
index 000000000000..f2c3ba84a80a
--- /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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: has-clang-tidy
+// XFAIL: modules-build
+// RUN: clang-tidy %s --warnings-as-errors=* -header-filter=.* -- -Wno-unknown-warning-option %{compile_flags}
+// -Wno-unknown-warning-option tells clang-tidy to ignore '-W' command-line arguments that it doesn't know.
+// There are some GCC-specific ones where clang-tidy would warn otherwise.
+
+// Prevent <ext/hash_map> 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 <algorithm>
+#include <any>
+#include <array>
+#include <atomic>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <barrier>
+#endif
+#include <bit>
+#include <bitset>
+#include <cassert>
+#include <ccomplex>
+#include <cctype>
+#include <cerrno>
+#include <cfenv>
+#include <cfloat>
+#include <charconv>
+#include <chrono>
+#include <cinttypes>
+#include <ciso646>
+#include <climits>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <clocale>
+#endif
+#include <cmath>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <codecvt>
+#endif
+#include <compare>
+#include <complex>
+#include <complex.h>
+#include <concepts>
+#include <condition_variable>
+#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES
+# include <coroutine>
+#endif
+#include <csetjmp>
+#include <csignal>
+#include <cstdarg>
+#include <cstdbool>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctgmath>
+#include <ctime>
+#include <ctype.h>
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <cwchar>
+#endif
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <cwctype>
+#endif
+#include <deque>
+#include <errno.h>
+#include <exception>
+#include <execution>
+#include <fenv.h>
+#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
+# include <filesystem>
+#endif
+#include <float.h>
+#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
+# include <format>
+#endif
+#include <forward_list>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <fstream>
+#endif
+#include <functional>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <future>
+#endif
+#include <initializer_list>
+#include <inttypes.h>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <iomanip>
+#endif
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <ios>
+#endif
+#include <iosfwd>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <iostream>
+#endif
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <istream>
+#endif
+#include <iterator>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <latch>
+#endif
+#include <limits>
+#include <limits.h>
+#include <list>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <locale>
+#endif
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <locale.h>
+#endif
+#include <map>
+#include <math.h>
+#include <memory>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <mutex>
+#endif
+#include <new>
+#include <numbers>
+#include <numeric>
+#include <optional>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <ostream>
+#endif
+#include <queue>
+#include <random>
+#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
+# include <ranges>
+#endif
+#include <ratio>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <regex>
+#endif
+#include <scoped_allocator>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <semaphore>
+#endif
+#include <set>
+#include <setjmp.h>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <shared_mutex>
+#endif
+#include <span>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <sstream>
+#endif
+#include <stack>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdexcept>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <streambuf>
+#endif
+#include <string>
+#include <string.h>
+#include <string_view>
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <strstream>
+#endif
+#include <system_error>
+#include <tgmath.h>
+#ifndef _LIBCPP_HAS_NO_THREADS
+# include <thread>
+#endif
+#include <tuple>
+#include <type_traits>
+#include <typeindex>
+#include <typeinfo>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <valarray>
+#include <variant>
+#include <vector>
+#include <version>
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <wchar.h>
+#endif
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# include <wctype.h>
+#endif
+
+// experimental headers
+#if __cplusplus >= 201103L
+# include <experimental/algorithm>
+# ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
+# include <experimental/coroutine>
+# endif
+# include <experimental/deque>
+# include <experimental/forward_list>
+# include <experimental/functional>
+# include <experimental/iterator>
+# include <experimental/list>
+# include <experimental/map>
+# include <experimental/memory_resource>
+# include <experimental/propagate_const>
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <experimental/regex>
+# endif
+# include <experimental/set>
+# include <experimental/simd>
+# include <experimental/string>
+# include <experimental/type_traits>
+# include <experimental/unordered_map>
+# include <experimental/unordered_set>
+# include <experimental/utility>
+# include <experimental/vector>
+#endif // __cplusplus >= 201103L
+
+// extended headers
+#include <ext/hash_map>
+#include <ext/hash_set>
+
+// 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
index ec9e5b782d77..b2e6b477f1ae 100644
--- a/libcxx/test/libcxx/lint/lint_headers.sh.py
+++ b/libcxx/test/libcxx/lint/lint_headers.sh.py
@@ -44,17 +44,4 @@ def pretty(path):
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
index 55bbc58e39b5..4a265386a07d 100755
--- a/libcxx/utils/generate_header_tests.py
+++ b/libcxx/utils/generate_header_tests.py
@@ -201,6 +201,7 @@ def produce_test(test_filename, exclusions=None, post_include=None):
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
index 5ddc47c616c5..0dfb516ae529 100644
--- 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),
More information about the libcxx-commits
mailing list