[clang-tools-extra] [clang-tidy][NFC] Enable misc-const-correctness rule in clang-tidy codebase (PR #167172)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 8 11:41:31 PST 2025
https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/167172
After successful `misc-const-correctness` cleanup (last patch https://github.com/llvm/llvm-project/pull/167131), we can enable `misc-const-correctness` rule for the whole project.
During cleanup, I didn't encounter any false positives so it's safe to assume that we will have minimal FP in the future.
>From 42636a402f0e14ff0a0577549b6713bcd45837ce Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sat, 8 Nov 2025 22:37:45 +0300
Subject: [PATCH] [clang-tidy] Enable misc-const-correctness rule in clang-tidy
codebase
---
clang-tools-extra/clang-tidy/.clang-tidy | 1 +
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/.clang-tidy b/clang-tools-extra/clang-tidy/.clang-tidy
index 0c2f34b529016..24f7d9ffdcf50 100644
--- a/clang-tools-extra/clang-tidy/.clang-tidy
+++ b/clang-tools-extra/clang-tidy/.clang-tidy
@@ -7,6 +7,7 @@ Checks: >
-bugprone-narrowing-conversions,
-bugprone-unchecked-optional-access,
-bugprone-unused-return-value,
+ misc-const-correctness,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-pass-by-value,
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 8ead26407ee5d..ac0adc498e2cc 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -601,13 +601,14 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
// whether the call itself throws.
if (const auto *Call = dyn_cast<CallExpr>(St)) {
if (const FunctionDecl *Func = Call->getDirectCallee()) {
- ExceptionInfo Excs =
+ const ExceptionInfo Excs =
throwsException(Func, Caught, CallStack, Call->getBeginLoc());
Results.merge(Excs);
}
} else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
- ExceptionInfo Excs = throwsException(Construct->getConstructor(), Caught,
- CallStack, Construct->getBeginLoc());
+ const ExceptionInfo Excs =
+ throwsException(Construct->getConstructor(), Caught, CallStack,
+ Construct->getBeginLoc());
Results.merge(Excs);
}
}
More information about the cfe-commits
mailing list