[clang-tools-extra] [clang-tidy] Add 'bugprone-suspicious-fread-fwrite-return' check (PR #206359)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 28 12:15:58 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE LINT COMMENT: clang-tidy-->
:warning: C/C++ code linter, clang-tidy found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
```bash
git diff -U0 origin/main...HEAD -- clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.cpp clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.h clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp |
python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py -path build -p1 -quiet
```
</details>
<details>
<summary>
View the output from clang-tidy here.
</summary>
```
clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.cpp:85:3: warning: variable 'Val' of type 'llvm::APSInt' can be declared 'const' [misc-const-correctness]
85 | llvm::APSInt Val = Eval.Val.getInt();
| ^
| const
clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.cpp:86:3: warning: variable 'Op' of type 'BinaryOperatorKind' can be declared 'const' [misc-const-correctness]
86 | BinaryOperatorKind Op = BinOp->getOpcode();
| ^
| const
clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.cpp:89:3: warning: variable 'IsDirectComparison' of type 'bool' can be declared 'const' [misc-const-correctness]
89 | bool IsDirectComparison = isa<CallExpr>(CallOperand->IgnoreParenImpCasts());
| ^
| const
clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.cpp:112:21: warning: statement should have braces [readability-inconsistent-ifelse-braces]
112 | if (Op == BO_EQ)
| ^
| {
113 | DiagKind = DiagnosticKind::AlwaysFalse;
114 | else if (Op == BO_NE)
| }
clang-tools-extra/clang-tidy/bugprone/SuspiciousFreadFwriteReturnCheck.cpp:114:26: warning: statement should have braces [readability-inconsistent-ifelse-braces]
114 | else if (Op == BO_NE)
| ^
| {
115 | DiagKind = DiagnosticKind::AlwaysTrue;
116 | else if (IsCallLHS) {
| }
```
</details>
https://github.com/llvm/llvm-project/pull/206359
More information about the cfe-commits
mailing list