https://github.com/rockwotj created
https://github.com/llvm/llvm-project/pull/76101
Introduce a new (off by default) clang tidy check to ensure that variables of a
specific type are always used even if -Wunused-variables wouldn't generate a
warning.
This check has already caught a couple of d
https://github.com/rockwotj edited
https://github.com/llvm/llvm-project/pull/76101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From 34feb9d9fefc4007a657366824ad38221228e86f Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Wed, 20 Dec 2023 15:05:48 -0600
Subject: [PATCH] clang-tidy/misc: introduce a must use check
Introduce a new (o
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From 07158b0396be8eb1d551bc98b538c5d23c42d9e9 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Wed, 20 Dec 2023 15:05:48 -0600
Subject: [PATCH] clang-tidy/misc: introduce a must use check
Introduce a new (o
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-must-use
+
+misc-must-use
+=
+
+Allows for strictly enforce variables are used for specific classes, even with
rockwotj wrote:
Done.
https://github.com/llvm/llvm-project/pull/76101
__
@@ -187,6 +187,13 @@ New checks
points in a coroutine. Such hostile types include scoped-lockable types and
types belonging to a configurable denylist.
+- New :doc:`misc-must-use
+ ` check.
+
+ Add the ability to strictly enforce variables are used for specific classes,
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-must-use
+
+misc-must-use
+=
+
+Allows for strictly enforce variables are used for specific classes, even with
+they would not be normally warned using -Wunused-variable due to templates or
+custom destructors.
+
+In the f
@@ -54,6 +55,7 @@ class MiscModule : public ClangTidyModule {
CheckFactories.registerCheck(
"misc-misleading-identifier");
CheckFactories.registerCheck("misc-misplaced-const");
+CheckFactories.registerCheck("misc-must-use");
rockwotj wrote:
@@ -54,6 +55,7 @@ class MiscModule : public ClangTidyModule {
CheckFactories.registerCheck(
"misc-misleading-identifier");
CheckFactories.registerCheck("misc-misplaced-const");
+CheckFactories.registerCheck("misc-must-use");
rockwotj wrote:
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From 5afeaab9f148b10d951e37fd27cb32687f310a9c Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH] clang-tidy/bugprone: introduce
unused-local-non-trivial-variab
@@ -54,6 +55,7 @@ class MiscModule : public ClangTidyModule {
CheckFactories.registerCheck(
"misc-misleading-identifier");
CheckFactories.registerCheck("misc-misplaced-const");
+CheckFactories.registerCheck("misc-must-use");
rockwotj wrote:
@@ -0,0 +1,49 @@
+//===--- MustUseCheck.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: Apa
@@ -0,0 +1,40 @@
+//===--- MustUseCheck.h - clang-tidy *- C++
-*-===//
+//
+// 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: Apa
@@ -0,0 +1,49 @@
+//===--- MustUseCheck.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: Apa
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-must-use
+
+misc-must-use
+=
+
+Allow strictly enforcing that variables are used for specific classes,
+even with they would not be normally warned using `-Wunused-variable` due
+templates or custom destructors.
+
+In the
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy %s misc-must-use %t -- \
+// RUN: -config="{CheckOptions: [{key: 'misc-must-use.Types', value:
'::async::Future'}]}"
+
+namespace async {
+template
+class Future {
+public:
+T get() {
+return Pending;
+}
+priva
@@ -0,0 +1,40 @@
+//===--- MustUseCheck.h - clang-tidy *- C++
-*-===//
+//
+// 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: Apa
@@ -0,0 +1,48 @@
+// RUN: %check_clang_tidy %s misc-must-use %t -- \
+// RUN: -config="{CheckOptions: [{key: 'misc-must-use.Types', value:
'::async::Future'}]}"
rockwotj wrote:
Done.
https://github.com/llvm/llvm-project/pull/76101
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-must-use
+
+misc-must-use
+=
+
+Allow strictly enforcing that variables are used for specific classes,
+even with they would not be normally warned using `-Wunused-variable` due
rockwotj wrote:
Done.
ht
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From 90d92d028833d25c218a9f184b5e1407500c9d01 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH] clang-tidy/bugprone: introduce
unused-local-non-trivial-variab
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - bugprone-unused-local-non-trivial-variable
+
+bugprone-unused-local-non-trivial-variable
+==
+
+Warns when a local non trivial variable is unused within a function.
+
+In the following example, `futu
@@ -168,6 +168,19 @@ New checks
extracted from an optional-like type and then used to create a new instance
of the same optional-like type.
+- New :doc:`bugprone-unused-local-non-trivial-variable
+ ` check.
+
+ Warns when a local non trivial variable is unused within a f
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - bugprone-unused-local-non-trivial-variable
+
+bugprone-unused-local-non-trivial-variable
+==
+
+Warns when a local non trivial variable is unused within a function.
+
+In the following example, `futu
https://github.com/rockwotj edited
https://github.com/llvm/llvm-project/pull/76101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From fff68e1854d16a166088d7199af09a7aeb19b4c4 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH] clang-tidy/bugprone: introduce
unused-local-non-trivial-variab
@@ -0,0 +1,89 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
@@ -0,0 +1,89 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - bugprone-unused-local-non-trivial-variable
+
+bugprone-unused-local-non-trivial-variable
+==
+
+Warns when a local non trivial variable is unused within a function.
+
+In the following example, `futu
@@ -0,0 +1,89 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
@@ -149,6 +149,7 @@ Clang-Tidy Checks
:doc:`bugprone-unhandled-self-assignment
`,
:doc:`bugprone-unique-ptr-array-mismatch
`, "Yes"
:doc:`bugprone-unsafe-functions `,
+ :doc:`bugprone-unused-local-non-trivial-variable
`, "Yes"
rockwotj wrote:
Don
@@ -0,0 +1,89 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s bugprone-unused-local-non-trivial-variable %t -- \
+// RUN: -config="{CheckOptions:
{bugprone-unused-local-non-trivial-variable.IncludeTypeRegex:
'::async::Future'}}"
+
+
+namespace async {
+template
+class Ptr {
+ public:
+
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s bugprone-unused-local-non-trivial-variable %t -- \
+// RUN: -config="{CheckOptions:
{bugprone-unused-local-non-trivial-variable.IncludeTypeRegex:
'::async::Future'}}"
+
+
+namespace async {
+template
+class Ptr {
+ public:
+
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From fff68e1854d16a166088d7199af09a7aeb19b4c4 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH 1/2] clang-tidy/bugprone: introduce
unused-local-non-trivial-va
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From 9a9fe7fd0a7b54c90042c64aa9db23b4ca703ec0 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH 1/2] clang-tidy/bugprone: introduce
unused-local-non-trivial-va
@@ -0,0 +1,45 @@
+.. title:: clang-tidy - bugprone-unused-local-non-trivial-variable
+
+bugprone-unused-local-non-trivial-variable
+==
+
+Warns when a local non trivial variable is unused within a function.
+The following types of variables
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From cf118a475b8dfef36c365c417c9cf63b79ff4055 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH 1/2] clang-tidy/bugprone: introduce
unused-local-non-trivial-va
@@ -0,0 +1,89 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
https://github.com/rockwotj updated
https://github.com/llvm/llvm-project/pull/76101
>From 6f0b7e5a80a8812e95357397384217dde4f81b01 Mon Sep 17 00:00:00 2001
From: Tyler Rockwood
Date: Thu, 21 Dec 2023 16:31:12 -0600
Subject: [PATCH 1/2] clang-tidy/bugprone: introduce
unused-local-non-trivial-va
@@ -0,0 +1,92 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
@@ -0,0 +1,92 @@
+//===--- UnusedLocalNonTrivialVariableCheck.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: Apa
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy -std=c++17 %s
bugprone-unused-local-non-trivial-variable %t -- \
rockwotj wrote:
Done.
https://github.com/llvm/llvm-project/pull/76101
___
cfe-commits mailing list
cfe-commi
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy -std=c++17 %s
bugprone-unused-local-non-trivial-variable %t -- \
+// RUN: -config="{CheckOptions:
{bugprone-unused-local-non-trivial-variable.IncludeTypes: '::async::Future'}}"
rockwotj wrote:
Done.
https://git
rockwotj wrote:
Changed
https://github.com/llvm/llvm-project/pull/76101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
44 matches
Mail list logo