[clang-tools-extra] [clang-tidy][NFC] Add a few cppcoreguidelines checks to codebase (PR #170977)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 6 03:00:48 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Baranov Victor (vbvictor)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/170977.diff
3 Files Affected:
- (modified) clang-tools-extra/clang-tidy/.clang-tidy (+4)
- (modified) clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp (+2-2)
- (modified) clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp (+1-1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/.clang-tidy b/clang-tools-extra/clang-tidy/.clang-tidy
index 576b4a7b8443e..a29ee52379597 100644
--- a/clang-tools-extra/clang-tidy/.clang-tidy
+++ b/clang-tools-extra/clang-tidy/.clang-tidy
@@ -9,6 +9,10 @@ Checks: >
-bugprone-narrowing-conversions,
-bugprone-unchecked-optional-access,
-bugprone-unused-return-value,
+ cppcoreguidelines-init-variables,
+ cppcoreguidelines-missing-std-forward,
+ cppcoreguidelines-rvalue-reference-param-not-moved,
+ cppcoreguidelines-virtual-class-destructor,
misc-const-correctness,
modernize-*,
-modernize-avoid-c-arrays,
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 67d0931003c54..0a7467a0ea650 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -266,8 +266,8 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
}
void UnsafeFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
- const Expr *SourceExpr;
- const FunctionDecl *FuncDecl;
+ const Expr *SourceExpr = nullptr;
+ const FunctionDecl *FuncDecl = nullptr;
if (const auto *DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>(DeclRefId)) {
SourceExpr = DeclRef;
diff --git a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
index 09adbf1155e62..ab584cb66a523 100644
--- a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
@@ -199,7 +199,7 @@ void UseRangesCheck::check(const MatchFinder::MatchResult &Result) {
if (!NodeStr.consume_front(FuncDecl))
continue;
Function = Value.get<FunctionDecl>();
- size_t Index;
+ size_t Index = 0;
if (NodeStr.getAsInteger(10, Index)) {
llvm_unreachable("Unable to extract replacer index");
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/170977
More information about the cfe-commits
mailing list