Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/…
Browse files Browse the repository at this point in the history
…97230
  • Loading branch information
a-tarasyuk committed Jul 14, 2024
2 parents 88952f5 + fe7fc54 commit b2f65d8
Show file tree
Hide file tree
Showing 3,369 changed files with 106,098 additions and 100,520 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ void AssignmentInIfConditionCheck::check(
return true;
}

// Dont traverse into any requires expressions.
bool TraverseRequiresExpr(RequiresExpr *,
DataRecursionQueue * = nullptr) {
return true;
}

bool VisitBinaryOperator(BinaryOperator *BO) {
if (BO->isAssignmentOp())
Check.report(BO);
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/assert-side-effect>` check by detecting side
effect from calling a method with non-const reference parameters.

- Improved :doc:`bugprone-assignment-in-if-condition
<clang-tidy/checks/bugprone/assignment-in-if-condition>` check by ignoring
assignments in the C++20 ``requires`` clause.

- Improved :doc:`bugprone-casting-through-void
<clang-tidy/checks/bugprone/casting-through-void>` check by ignoring casts
where source is already a ``void``` pointer, making middle ``void`` pointer
Expand Down
140 changes: 113 additions & 27 deletions clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,128 @@ Example
std::end(Items2));


transforms to:
Transforms to:

.. code-block:: c++

auto Iter1 = boost::range::find(Items, 0);
auto AreSame = boost::range::equal(Items1, Items2);

Supported algorithms
--------------------

Calls to the following std library algorithms are checked:
``includes``,``set_union``,``set_intersection``,``set_difference``,
``set_symmetric_difference``,``unique``,``lower_bound``,``stable_sort``,
``equal_range``,``remove_if``,``sort``,``random_shuffle``,``remove_copy``,
``stable_partition``,``remove_copy_if``,``count``,``copy_backward``,
``reverse_copy``,``adjacent_find``,``remove``,``upper_bound``,``binary_search``,
``replace_copy_if``,``for_each``,``generate``,``count_if``,``min_element``,
``reverse``,``replace_copy``,``fill``,``unique_copy``,``transform``,``copy``,
``replace``,``find``,``replace_if``,``find_if``,``partition``,``max_element``,
``find_end``,``merge``,``partial_sort_copy``,``find_first_of``,``search``,
``lexicographical_compare``,``equal``,``mismatch``,``next_permutation``,
``prev_permutation``,``push_heap``,``pop_heap``,``make_heap``,``sort_heap``,
``copy_if``,``is_permutation``,``is_partitioned``,``find_if_not``,
``partition_copy``,``any_of``,``iota``,``all_of``,``partition_point``,
``is_sorted``,``none_of``,``is_sorted_until``,``reduce``,``accumulate``,
``parital_sum``,``adjacent_difference``.

``std::accumulate``,
``std::adjacent_difference``,
``std::adjacent_find``,
``std::all_of``,
``std::any_of``,
``std::binary_search``,
``std::copy_backward``,
``std::copy_if``,
``std::copy``,
``std::count_if``,
``std::count``,
``std::equal_range``,
``std::equal``,
``std::fill``,
``std::find_end``,
``std::find_first_of``,
``std::find_if_not``,
``std::find_if``,
``std::find``,
``std::for_each``,
``std::generate``,
``std::includes``,
``std::iota``,
``std::is_partitioned``,
``std::is_permutation``,
``std::is_sorted_until``,
``std::is_sorted``,
``std::lexicographical_compare``,
``std::lower_bound``,
``std::make_heap``,
``std::max_element``,
``std::merge``,
``std::min_element``,
``std::mismatch``,
``std::next_permutation``,
``std::none_of``,
``std::parital_sum``,
``std::partial_sort_copy``,
``std::partition_copy``,
``std::partition_point``,
``std::partition``,
``std::pop_heap``,
``std::prev_permutation``,
``std::push_heap``,
``std::random_shuffle``,
``std::reduce``,
``std::remove_copy_if``,
``std::remove_copy``,
``std::remove_if``,
``std::remove``,
``std::replace_copy_if``,
``std::replace_copy``,
``std::replace_if``,
``std::replace``,
``std::reverse_copy``,
``std::reverse``,
``std::search``,
``std::set_difference``,
``std::set_intersection``,
``std::set_symmetric_difference``,
``std::set_union``,
``std::sort_heap``,
``std::sort``,
``std::stable_partition``,
``std::stable_sort``,
``std::transform``,
``std::unique_copy``,
``std::unique``,
``std::upper_bound``.

The check will also look for the following functions from the
``boost::algorithm`` namespace:
``reduce``,``find_backward``,``find_not_backward``,``find_if_backward``,
``find_if_not_backward``,``hex``,``hex_lower``,``unhex``,
``is_partitioned_until``,``is_palindrome``,``copy_if``,``copy_while``,
``copy_until``,``copy_if_while``,``copy_if_until``,``is_permutation``,
``is_partitioned``,``one_of``,``one_of_equal``,``find_if_not``,
``partition_copy``,``any_of``,``any_of_equal``,``iota``,``all_of``,
``all_of_equal``,``partition_point``,``is_sorted_until``,``is_sorted``,
``is_increasing``,``is_decreasing``,``is_strictly_increasing``,
``is_strictly_decreasing``,``none_of``,``none_of_equal``,``clamp_range``,
``apply_permutation``,``apply_reverse_permutation``.

``all_of_equal``,
``any_of_equal``,
``any_of``,
``apply_permutation``,
``apply_reverse_permutation``,
``clamp_range``,
``copy_if_until``,
``copy_if_while``,
``copy_if``,
``copy_until``,
``copy_while``,
``find_backward``,
``find_if_backward``,
``find_if_not_backward``,
``find_if_not``,
``find_not_backward``,
``hex_lower``,
``hex``,
``iota``, ``all_of``,
``is_decreasing``,
``is_increasing``,
``is_palindrome``,
``is_partitioned_until``,
``is_partitioned``,
``is_permutation``,
``is_sorted_until``,
``is_sorted``,
``is_strictly_decreasing``,
``is_strictly_increasing``,
``none_of_equal``,
``none_of``,
``one_of_equal``,
``one_of``,
``partition_copy``,
``partition_point``,
``reduce``,
``unhex``.

Reverse Iteration
-----------------
Expand All @@ -64,7 +150,7 @@ fixed using the ``boost::adaptors::reverse`` adaptor.
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
std::crbegin(Items2), std::crend(Items2));

transformst to:
Transforms to:

.. code-block:: c++

Expand Down
106 changes: 78 additions & 28 deletions clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,90 @@ Example
std::begin(Items2), std::end(Items2));


transforms to:
Transforms to:

.. code-block:: c++

auto Iter1 = std::ranges::find(Items, 0);
auto AreSame = std::ranges::equal(Items1, Items2);

Supported algorithms
--------------------

Calls to the following std library algorithms are checked:
``::std::all_of``,``::std::any_of``,``::std::none_of``,``::std::for_each``,
``::std::find``,``::std::find_if``,``::std::find_if_not``,
``::std::adjacent_find``,``::std::copy``,``::std::copy_if``,
``::std::copy_backward``,``::std::move``,``::std::move_backward``,
``::std::fill``,``::std::transform``,``::std::replace``,``::std::replace_if``,
``::std::generate``,``::std::remove``,``::std::remove_if``,
``::std::remove_copy``,``::std::remove_copy_if``,``::std::unique``,
``::std::unique_copy``,``::std::sample``,``::std::partition_point``,
``::std::lower_bound``,``::std::upper_bound``,``::std::equal_range``,
``::std::binary_search``,``::std::push_heap``,``::std::pop_heap``,
``::std::make_heap``,``::std::sort_heap``,``::std::next_permutation``,
``::std::prev_permutation``,``::std::iota``,``::std::reverse``,
``::std::reverse_copy``,``::std::shift_left``,``::std::shift_right``,
``::std::is_partitioned``,``::std::partition``,``::std::partition_copy``,
``::std::stable_partition``,``::std::sort``,``::std::stable_sort``,
``::std::is_sorted``,``::std::is_sorted_until``,``::std::is_heap``,
``::std::is_heap_until``,``::std::max_element``,``::std::min_element``,
``::std::minmax_element``,``::std::uninitialized_copy``,
``::std::uninitialized_fill``,``::std::uninitialized_move``,
``::std::uninitialized_default_construct``,
``::std::uninitialized_value_construct``,``::std::destroy``,
``::std::partial_sort_copy``,``::std::includes``,
``::std::set_union``,``::std::set_intersection``,``::std::set_difference``,
``::std::set_symmetric_difference``,``::std::merge``,
``::std::lexicographical_compare``,``::std::find_end``,``::std::search``,
``::std::is_permutation``,``::std::equal``,``::std::mismatch``.

``std::adjacent_find``,
``std::all_of``,
``std::any_of``,
``std::binary_search``,
``std::copy_backward``,
``std::copy_if``,
``std::copy``,
``std::destroy``,
``std::equal_range``,
``std::equal``,
``std::fill``,
``std::find_end``,
``std::find_if_not``,
``std::find_if``,
``std::find``,
``std::for_each``,
``std::generate``,
``std::includes``,
``std::iota``,
``std::is_heap_until``,
``std::is_heap``,
``std::is_partitioned``,
``std::is_permutation``,
``std::is_sorted_until``,
``std::is_sorted``,
``std::lexicographical_compare``,
``std::lower_bound``,
``std::make_heap``,
``std::max_element``,
``std::merge``,
``std::min_element``,
``std::minmax_element``,
``std::mismatch``,
``std::move_backward``,
``std::move``,
``std::next_permutation``,
``std::none_of``,
``std::partial_sort_copy``,
``std::partition_copy``,
``std::partition_point``,
``std::partition``,
``std::pop_heap``,
``std::prev_permutation``,
``std::push_heap``,
``std::remove_copy_if``,
``std::remove_copy``,
``std::remove``, ``std::remove_if``,
``std::replace_if``,
``std::replace``,
``std::reverse_copy``,
``std::reverse``,
``std::sample``,
``std::search``,
``std::set_difference``,
``std::set_intersection``,
``std::set_symmetric_difference``,
``std::set_union``,
``std::shift_left``,
``std::shift_right``,
``std::sort_heap``,
``std::sort``,
``std::stable_partition``,
``std::stable_sort``,
``std::transform``,
``std::uninitialized_copy``,
``std::uninitialized_default_construct``,
``std::uninitialized_fill``,
``std::uninitialized_move``,
``std::uninitialized_value_construct``,
``std::unique_copy``,
``std::unique``,
``std::upper_bound``.

Reverse Iteration
-----------------
Expand All @@ -62,7 +112,7 @@ fixed using the ``std::views::reverse`` adaptor.
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
std::crbegin(Items2), std::crend(Items2));

transformst to:
Transforms to:

.. code-block:: c++

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %check_clang_tidy -std=c++20 %s bugprone-assignment-in-if-condition %t

void testRequires() {
if constexpr (requires(int &a) { a = 0; }) {
}
}
8 changes: 6 additions & 2 deletions clang/cmake/caches/Fuchsia-stage2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,18 @@ if(FUCHSIA_SDK)
set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS "aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
endif()

foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m-unknown-eabi)
foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
list(APPEND BUILTIN_TARGETS "${target}")
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "")
set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
foreach(lang C;CXX;ASM)
set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb" CACHE STRING "")
set(BUILTINS_${target}_CMAKE_${lang}_local_flags "--target=${target} -mthumb")
if(${target} STREQUAL "armv8m.main-unknown-eabi")
set(BUILTINS_${target}_CMAKE_${lang}_local_flags "${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=hard -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "")
endif()
set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "")
endforeach()
foreach(type SHARED;MODULE;EXE)
set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
Expand Down
11 changes: 11 additions & 0 deletions clang/docs/HLSL/ExpectedDifferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ behavior between Clang and DXC. Some examples include:
void takesDoubles(double, double, double);

cbuffer CB {
bool B;
uint U;
int I;
float X, Y, Z;
double3 A, B;
}

void twoParams(int, int);
void twoParams(float, float);

export void call() {
halfOrInt16(U); // DXC: Fails with call ambiguous between int16_t and uint16_t overloads
// Clang: Resolves to halfOrInt16(uint16_t).
Expand All @@ -98,6 +102,13 @@ behavior between Clang and DXC. Some examples include:
// FXC: Expands to compute double dot product with fmul/fadd
// Clang: Resolves to dot(float3, float3), emits conversion warnings.

#ifndef IGNORE_ERRORS
tan(B); // DXC: resolves to tan(float).
// Clang: Fails to resolve, ambiguous between integer types.

twoParams(I, X); // DXC: resolves twoParams(int, int).
// Clang: Fails to resolve ambiguous conversions.
#endif
}

.. note::
Expand Down
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,9 @@ Bug Fixes in This Version

- Fixed Clang crashing when failing to perform some C++ Initialization Sequences. (#GH98102)

- ``__is_trivially_equality_comparable`` no longer returns true for types which
have a constrained defaulted comparison operator (#GH89293).

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -1037,6 +1040,7 @@ Bug Fixes to C++ Support
- Clang now correctly handles unexpanded packs in the template parameter list of a generic lambda expression
(#GH48937)
- Fix a crash when parsing an invalid type-requirement in a requires expression. (#GH51868)
- Fix parsing of built-in type-traits such as ``__is_pointer`` in libstdc++ headers. (#GH95598)
- Fix a crash when checking destructor reference with an invalid initializer. (#GH97230).

Bug Fixes to AST Handling
Expand Down
Loading

0 comments on commit b2f65d8

Please sign in to comment.