[clang-tools-extra] [clang-tidy][NFC] Add a few cppcoreguidelines checks to codebase (PR #170977)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 6 03:00:16 PST 2025
https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/170977
None
>From e767f73f3bed038aea881abd656297375bcd9cf0 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sat, 6 Dec 2025 13:58:14 +0300
Subject: [PATCH] [clang-tidy][NFC] Add a few cppcoreguidelines checks to
codebase
---
clang-tools-extra/clang-tidy/.clang-tidy | 4 ++++
.../clang-tidy/bugprone/UnsafeFunctionsCheck.cpp | 4 ++--
clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
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");
}
More information about the cfe-commits
mailing list