[clang-tools-extra] 0e5fd43 - [clang-tidy][NFC] Add a few cppcoreguidelines checks to codebase (#170977)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 6 07:01:35 PST 2025
Author: Baranov Victor
Date: 2025-12-06T18:01:31+03:00
New Revision: 0e5fd438f407712b220510a2fd2e094d3b49d43e
URL: https://github.com/llvm/llvm-project/commit/0e5fd438f407712b220510a2fd2e094d3b49d43e
DIFF: https://github.com/llvm/llvm-project/commit/0e5fd438f407712b220510a2fd2e094d3b49d43e.diff
LOG: [clang-tidy][NFC] Add a few cppcoreguidelines checks to codebase (#170977)
Added:
Modified:
clang-tools-extra/clang-tidy/.clang-tidy
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
Removed:
################################################################################
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