[clang-tools-extra] [clang-tidy][NFC] Fix `bugprone-unchecked-optional-access` warnings in codebase (PR #170004)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 21 10:34:15 PST 2026
================
@@ -225,10 +225,12 @@ void FunctionSizeCheck::check(const MatchFinder::MatchResult &Result) {
<< ActualNumberParameters << ParameterThreshold.value();
}
- for (const auto &CSPos : FI.NestingThresholders) {
- diag(CSPos, "nesting level %0 starts here (threshold %1)",
- DiagnosticIDs::Note)
- << NestingThreshold.value() + 1 << NestingThreshold.value();
+ if (NestingThreshold) {
+ for (const auto &CSPos : FI.NestingThresholders) {
+ diag(CSPos, "nesting level %0 starts here (threshold %1)",
+ DiagnosticIDs::Note)
+ << NestingThreshold.value() + 1 << NestingThreshold.value();
----------------
localspook wrote:
For consistency with the rest of the code, and to assert that we really do expect the optional to be engaged:
```suggestion
<< *NestingThreshold + 1 << *NestingThreshold;
```
https://github.com/llvm/llvm-project/pull/170004
More information about the cfe-commits
mailing list