[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-20 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/69465 >From 627f68e57b2526fb72285ef4831fc3c02a6ee6d0 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Wed, 18 Oct 2023 08:47:02 +0800 Subject: [PATCH 1/8] [clang-tidy]Add new check bugprone-casting-through-void

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/69465 >From 627f68e57b2526fb72285ef4831fc3c02a6ee6d0 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Wed, 18 Oct 2023 08:47:02 +0800 Subject: [PATCH 1/7] [clang-tidy]Add new check bugprone-casting-through-void

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread via cfe-commits
@@ -0,0 +1,50 @@ +//===--- CastingThroughVoidCheck.cpp - clang-tidy -===// +// +// 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:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,50 @@ +//===--- CastingThroughVoidCheck.cpp - clang-tidy -===// +// +// 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:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -2732,6 +2732,16 @@ extern const internal::VariadicDynCastAllOfMatcher castExpr; extern const internal::VariadicDynCastAllOfMatcher cxxFunctionalCastExpr; +/// Matches a builtin bit cast expression. +/// +/// Example: Matches __builtin_bit_cast(double, i) in +/// \code

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,32 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects unsafe or redundant two-step casting operations involving ``void*``. + +Two-step type conversions via void* are discouraged

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,50 @@ +//===--- CastingThroughVoidCheck.cpp - clang-tidy -===// +// +// 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:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,96 @@ +// RUN: %check_clang_tidy %s bugprone-casting-through-void %t + +using V = void*; +using CV = const void*; + +int i = 100; +double d = 100; +const int ci = 100; +const double cd = 100; + +void normal_test() { + static_cast(static_cast()); + // CHECK-MESSAGES:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,96 @@ +// RUN: %check_clang_tidy %s bugprone-casting-through-void %t + +using V = void*; +using CV = const void*; + +int i = 100; +double d = 100; +const int ci = 100; +const double cd = 100; + +void normal_test() { + static_cast(static_cast()); + // CHECK-MESSAGES:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,96 @@ +// RUN: %check_clang_tidy %s bugprone-casting-through-void %t + +using V = void*; +using CV = const void*; + +int i = 100; +double d = 100; +const int ci = 100; +const double cd = 100; + +void normal_test() { + static_cast(static_cast()); + // CHECK-MESSAGES:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,96 @@ +// RUN: %check_clang_tidy %s bugprone-casting-through-void %t + +using V = void*; +using CV = const void*; + +int i = 100; +double d = 100; +const int ci = 100; +const double cd = 100; + +void normal_test() { + static_cast(static_cast()); + // CHECK-MESSAGES:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,32 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects unsafe or redundant two-step casting operations involving ``void*``. + +Two-step type conversions via void* are discouraged

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,32 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects unsafe or redundant two-step casting operations involving ``void*``. + +Two-step type conversions via void* are discouraged

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,32 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects unsafe or redundant two-step casting operations involving ``void*``. PiotrZSL wrote: do not start with A

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,32 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects unsafe or redundant two-step casting operations involving ``void*``. + +Two-step type conversions via void* are discouraged

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,50 @@ +//===--- CastingThroughVoidCheck.cpp - clang-tidy -===// +// +// 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:

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Adrian Prantl via cfe-commits
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/69465 >From 627f68e57b2526fb72285ef4831fc3c02a6ee6d0 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Wed, 18 Oct 2023 08:47:02 +0800 Subject: [PATCH 1/6] [clang-tidy]Add new check bugprone-casting-through-void

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,11 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects usage of ``static_cast`` pointer to the other pointer throght +``static_cast`` to ``void *`` in C++ code. + +Use of these

[clang] [clang-tidy]Add new check bugprone-casting-through-void (PR #69465)

2023-10-18 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,11 @@ +.. title:: clang-tidy - bugprone-casting-through-void + +bugprone-casting-through-void += + +A check detects usage of ``static_cast`` pointer to the other pointer throght +``static_cast`` to ``void *`` in C++ code. + +Use of these