[libc++] Enable clang-tidy in the CI again (#195047)
clang-tidy currently doesn't run in the CI because CMake doesn't find the appropriate `ClangConfig.cmake` anymore. This adds the path so clang-tidy is built again and fixes most issues. Some things are disabled for now to get most checks back. They will be re-enabled later.
This commit is contained in:
parent
e5f8e65fb2
commit
44546e0e32
16 changed files with 37 additions and 29 deletions
|
|
@ -15,7 +15,7 @@ if(NOT TARGET llvm-libc-common-utilities)
|
|||
if (NOT(LIBCXX_ENABLE_THREADS))
|
||||
target_compile_definitions(llvm-libc-common-utilities INTERFACE LIBC_THREAD_MODE=LIBC_THREAD_MODE_SINGLE)
|
||||
endif()
|
||||
target_include_directories(llvm-libc-common-utilities INTERFACE ${libc_path})
|
||||
target_include_directories(llvm-libc-common-utilities SYSTEM INTERFACE ${libc_path})
|
||||
target_compile_definitions(llvm-libc-common-utilities INTERFACE LIBC_NAMESPACE=__llvm_libc_common_utils)
|
||||
target_compile_features(llvm-libc-common-utilities INTERFACE cxx_std_17)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ namespace __function {
|
|||
template <class _Fp>
|
||||
class __base;
|
||||
|
||||
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
|
||||
template <class _Rp, class... _ArgTypes>
|
||||
class __base<_Rp(_ArgTypes...)> {
|
||||
public:
|
||||
|
|
@ -149,6 +150,7 @@ public:
|
|||
virtual const std::type_info& target_type() const _NOEXCEPT = 0;
|
||||
# endif // _LIBCPP_HAS_RTTI
|
||||
};
|
||||
_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
|
||||
|
||||
// __func implements __base for a given functor type.
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ _LIBCPP_PUSH_MACROS
|
|||
# include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
|
||||
|
||||
template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
|
||||
class _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> {
|
||||
|
|
@ -419,6 +420,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__
|
|||
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
|
||||
_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <size_t _Alignment, class _Tp>
|
||||
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_sufficiently_aligned(_Tp* __ptr) {
|
||||
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __is_sufficiently_aligned(_Tp* __ptr) {
|
||||
return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public:
|
|||
#endif
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
|
||||
reset(__u.release());
|
||||
reset(__u.release()); // NOLINT(misc-uniqueptr-reset-release)
|
||||
__deleter_ = std::forward<deleter_type>(__u.get_deleter());
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -478,7 +478,7 @@ public:
|
|||
__checker_(std::move(__u.__checker_)) {}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
|
||||
reset(__u.release());
|
||||
reset(__u.release()); // NOLINT(misc-uniqueptr-reset-release)
|
||||
__deleter_ = std::forward<deleter_type>(__u.get_deleter());
|
||||
__checker_ = std::move(__u.__checker_);
|
||||
return *this;
|
||||
|
|
|
|||
|
|
@ -1257,7 +1257,7 @@ public:
|
|||
|
||||
template <class _Key>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Key& __key) {
|
||||
auto [__, __match] = __find_equal(__key);
|
||||
auto [__dummy, __match] = __find_equal(__key);
|
||||
if (__match == nullptr)
|
||||
return end();
|
||||
return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__match));
|
||||
|
|
@ -1265,7 +1265,7 @@ public:
|
|||
|
||||
template <class _Key>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Key& __key) const {
|
||||
auto [__, __match] = __find_equal(__key);
|
||||
auto [__dummy, __match] = __find_equal(__key);
|
||||
if (__match == nullptr)
|
||||
return end();
|
||||
return const_iterator(std::__static_fancy_pointer_cast<__node_pointer>(__match));
|
||||
|
|
|
|||
|
|
@ -1155,7 +1155,7 @@ public:
|
|||
template <class _Arg,
|
||||
__enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0>
|
||||
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(_Arg&& __arg) {
|
||||
auto [_, __child] = __tree_.__find_equal(__arg);
|
||||
auto [__dummy, __child] = __tree_.__find_equal(__arg);
|
||||
if (__child == nullptr)
|
||||
std::__throw_out_of_range("map::at: key not found");
|
||||
return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
|
||||
|
|
@ -1164,7 +1164,7 @@ public:
|
|||
template <class _Arg,
|
||||
__enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0>
|
||||
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(_Arg&& __arg) const {
|
||||
auto [_, __child] = __tree_.__find_equal(__arg);
|
||||
auto [__dummy, __child] = __tree_.__find_equal(__arg);
|
||||
if (__child == nullptr)
|
||||
std::__throw_out_of_range("map::at: key not found");
|
||||
return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
|
||||
|
|
@ -1581,7 +1581,7 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<map<_Key,
|
|||
|
||||
template <class _Map, class _Func, class _Proj>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto operator()(_Map&& __map, _Func __func, _Proj __proj) {
|
||||
auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
|
||||
auto [__dummy, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
|
||||
__map.__tree_, std::move(__func), std::move(__proj));
|
||||
return std::make_pair(__map.end(), std::move(__func2));
|
||||
}
|
||||
|
|
@ -1632,7 +1632,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
|
|||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {
|
||||
auto [_, __child] = __tree_.__find_equal(__k);
|
||||
auto [__dummy, __child] = __tree_.__find_equal(__k);
|
||||
if (__child == nullptr)
|
||||
std::__throw_out_of_range("map::at: key not found");
|
||||
return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
|
||||
|
|
@ -1640,7 +1640,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(cons
|
|||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX26 const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const {
|
||||
auto [_, __child] = __tree_.__find_equal(__k);
|
||||
auto [__dummy, __child] = __tree_.__find_equal(__k);
|
||||
if (__child == nullptr)
|
||||
std::__throw_out_of_range("map::at: key not found");
|
||||
return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
|
||||
|
|
@ -2247,7 +2247,7 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<multimap<_
|
|||
|
||||
template <class _Map, class _Func, class _Proj>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto operator()(_Map&& __map, _Func __func, _Proj __proj) {
|
||||
auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
|
||||
auto [__dummy, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
|
||||
__map.__tree_, std::move(__func), std::move(__proj));
|
||||
return std::make_pair(__map.end(), std::move(__func2));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ private:
|
|||
}
|
||||
|
||||
template <class, class _Tp>
|
||||
using __expander = _Tp;
|
||||
using __expander _LIBCPP_NODEBUG = _Tp;
|
||||
|
||||
template <size_t _Ip, class _Fp, class... _Vs>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto __make_fdiagonal_impl() {
|
||||
|
|
@ -1593,6 +1593,7 @@ template < class _Visitor, class... _Vs, typename>
|
|||
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
|
||||
using __variant_detail::__visitation::__variant;
|
||||
std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
|
||||
// NOLINTNEXTLINE(bugprone-use-after-move) __throw_if_valueless doesn't actually forward the variants
|
||||
return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace __itoa {
|
|||
inline constexpr char _Charconv_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
|
||||
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
|
||||
static_assert(std::size(_Charconv_digits) == 36);
|
||||
} // __itoa
|
||||
} // namespace __itoa
|
||||
|
||||
// vvvvvvvvvv DERIVED FROM corecrt_internal_fltintrn.h vvvvvvvvvv
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ config.substitutions.append(('%{flags}',
|
|||
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
|
||||
))
|
||||
config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdlibinc -I %{include-dir} -I %{target-include-dir} -I @CMAKE_BINARY_DIR@/libc/include -I %{libcxx-dir}/test/support -idirafter @LIBC_KERNEL_HEADERS@'
|
||||
'-nostdlibinc -I %{include-dir} -I %{target-include-dir} -isystem @CMAKE_BINARY_DIR@/libc/include -I %{libcxx-dir}/test/support -idirafter @LIBC_KERNEL_HEADERS@'
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'-nodefaultlibs -nostartfiles -L %{lib-dir} -lc++ -lc++abi @CMAKE_BINARY_DIR@/libc/startup/linux/crt1.o @CMAKE_BINARY_DIR@/libc/lib/libc.a @CMAKE_BINARY_DIR@/libc/lib/libm.a -static -fno-use-cxa-atexit @CMAKE_BINARY_DIR@/compiler-rt/lib/linux/libclang_rt.builtins-x86_64.a'
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
# The GCC compiler flags are not always compatible with clang-tidy.
|
||||
# UNSUPPORTED: gcc
|
||||
|
||||
# FIXME: Enable this again in C++03
|
||||
# UNSUPPORTED: c++03
|
||||
|
||||
# RUN: %{python} %s %{libcxx-dir}/utils
|
||||
# END.
|
||||
|
||||
|
|
@ -20,6 +23,8 @@ import sys
|
|||
sys.path.append(sys.argv[1])
|
||||
from libcxx.header_information import lit_header_undeprecations, public_headers
|
||||
|
||||
# FIXME: Enable -Wweak-vtables again
|
||||
|
||||
for header in public_headers:
|
||||
print(f"""\
|
||||
//--- {header}.sh.cpp
|
||||
|
|
@ -30,7 +35,7 @@ for header in public_headers:
|
|||
// RUN: -header-filter=.* \\
|
||||
// RUN: --config-file=%{{libcxx-dir}}/.clang-tidy \\
|
||||
// RUN: --load=%{{test-tools-dir}}/clang_tidy_checks/libcxx-tidy.plugin \\
|
||||
// RUN: -- -Wweak-vtables %{{flags}} %{{compile_flags}} -fno-modules
|
||||
// RUN: -- %{{flags}} %{{compile_flags}} -fno-modules
|
||||
|
||||
#include <{header}>
|
||||
""")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
# to be one monolitic test. Since the test doesn't take very long it's
|
||||
# not a huge issue.
|
||||
|
||||
# FIXME: Re-enable this test when we fix the clang-tidy plugin that implements it
|
||||
# UNSUPPORTED: true
|
||||
|
||||
# RUN: %{python} %s %{libcxx-dir}/utils
|
||||
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -78,9 +78,6 @@ void hide_from_abi::registerMatchers(clang::ast_matchers::MatchFinder* finder) {
|
|||
isDefinition())
|
||||
.bind("hide_from_abi_on_member_function"),
|
||||
this);
|
||||
|
||||
finder->addMatcher(
|
||||
cxxMethodDecl(has_hide_from_abi_attr, on_trivial).bind("hide_from_abi_on_defaulted_smf_in_trivial_class"), this);
|
||||
}
|
||||
|
||||
void hide_from_abi::check(const clang::ast_matchers::MatchFinder::MatchResult& result) {
|
||||
|
|
@ -99,12 +96,5 @@ void hide_from_abi::check(const clang::ast_matchers::MatchFinder::MatchResult& r
|
|||
call != nullptr) {
|
||||
diag(call->getLocation(), "_LIBCPP_HIDE_FROM_ABI or _LIBCPP_HIDE_FROM_ABI_VIRTUAL is missing");
|
||||
}
|
||||
|
||||
if (const auto* call =
|
||||
result.Nodes.getNodeAs<clang::CXXMethodDecl>("hide_from_abi_on_defaulted_smf_in_trivial_class");
|
||||
call != nullptr) {
|
||||
diag(call->getLocation(),
|
||||
"_LIBCPP_HIDE_FROM_ABI should not be used for special member functions in trivial classes");
|
||||
}
|
||||
}
|
||||
} // namespace libcpp
|
||||
|
|
|
|||
|
|
@ -119,6 +119,10 @@ function clean() {
|
|||
function generate-cmake-base() {
|
||||
step "Generating CMake"
|
||||
|
||||
# FIXME: This should really be set in the Dockerfile
|
||||
export CMAKE_PREFIX_PATH="/opt/compiler-explorer/clang-trunk/lib/cmake"
|
||||
export PATH="$PATH:/opt/compiler-explorer/clang-trunk/bin"
|
||||
|
||||
# We can remove -DCMAKE_INSTALL_MESSAGE=NEVER once https://gitlab.kitware.com/cmake/cmake/-/issues/26085 is fixed.
|
||||
cmake \
|
||||
-S "${MONOREPO_ROOT}/runtimes" \
|
||||
|
|
@ -462,7 +466,8 @@ generic-llvm-libc)
|
|||
generate-cmake-base -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-llvm-libc.cmake" \
|
||||
-DLIBCXX_TEST_CONFIG="llvm-libc++-llvm-libc.cfg.in" \
|
||||
-DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-llvm-libc.cfg.in" \
|
||||
-DLIBC_KERNEL_HEADERS="${BUILD_DIR}/linux-install/include"
|
||||
-DLIBC_KERNEL_HEADERS="${BUILD_DIR}/linux-install/include" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
# Ensure we have the builtins archive built as we pass it in explicitly in
|
||||
# the test config.
|
||||
ninja -vC "${BUILD_DIR}" libclang_rt.builtins-x86_64.a
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
|
|||
#else
|
||||
class type_info; // forward declaration
|
||||
#endif
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
|
||||
// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ config.substitutions.append(('%{flags}',
|
|||
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
|
||||
))
|
||||
config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdlibinc -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I @CMAKE_BINARY_DIR@/libc/include -I %{libcxx}/test/support -I %{libcxx}/src -idirafter @LIBC_KERNEL_HEADERS@ -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
|
||||
'-nostdlibinc -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -isystem @CMAKE_BINARY_DIR@/libc/include -I %{libcxx}/test/support -I %{libcxx}/src -idirafter @LIBC_KERNEL_HEADERS@ -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'-nodefaultlibs -nostartfiles -L %{lib} -lc++ -lc++abi -pthread @CMAKE_BINARY_DIR@/libc/startup/linux/crt1.o @CMAKE_BINARY_DIR@/libc/lib/libc.a -static -fno-use-cxa-atexit'
|
||||
|
|
|
|||
Loading…
Reference in a new issue