Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4
# e855feac 12-Nov-2024 Congcong Cai <congcongcai0907@163.com>

[clang-tidy] fix bugprone-sizeof-expression when sizeof expression with template types (#115275)

Fixed: #115175.
`dependent type` are not the same even pointers are the same.

---------

Co-authored

[clang-tidy] fix bugprone-sizeof-expression when sizeof expression with template types (#115275)

Fixed: #115175.
`dependent type` are not the same even pointers are the same.

---------

Co-authored-by: whisperity <whisperity@gmail.com>

show more ...


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1
# 267ad430 17-Sep-2024 Zoltán Porkoláb <zporky@gmail.com>

[clang-tidy] Extend `bugprone-sizeof-expression` with matching `P +- sizeof(T)` and `P +- N */ sizeof(T)` cases, add `cert-arr39-c` alias (#106061)

Improved `bugprone-sizeof-expression` check to fin

[clang-tidy] Extend `bugprone-sizeof-expression` with matching `P +- sizeof(T)` and `P +- N */ sizeof(T)` cases, add `cert-arr39-c` alias (#106061)

Improved `bugprone-sizeof-expression` check to find suspicious pointer
arithmetic calculations where the pointer is offset by an `alignof()`,
`offsetof()`, or `sizeof()` expression.

Pointer arithmetic expressions implicitly scale the offset added to or
subtracted from the address by the size of the pointee type. Using an
offset expression that is already scaled by the size of the underlying
type effectively results in a squared offset, which is likely an invalid
pointer that points beyond the end of the intended array.

```c
void printEveryEvenIndexElement(int *Array, size_t N) {
int *P = Array;
while (P <= Array + N * sizeof(int)) { // Suspicious pointer arithmetics using sizeof()!
printf("%d ", *P);

P += 2 * sizeof(int); // Suspicious pointer arithmetics using sizeof()!
}
}
```

---------

Co-authored-by: Whisperity <whisperity@gmail.com>

show more ...


Revision tags: llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# fdcfb277 02-Jul-2024 Donát Nagy <donat.nagy@ericsson.com>

[clang-tidy] Clarify diagnostics of bugprone-sizeof-expression (#95550)

… because they were strangely worded and in a few cases outright
incorrect.


Revision tags: llvmorg-18.1.8
# 546c816a 11-Jun-2024 Donát Nagy <donat.nagy@ericsson.com>

[clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (#94356)

This commit reimplements the functionality of the Clang Static Analyzer
checker `alpha.core.SizeofPointer` withi

[clang-tidy] Improve sizeof(pointer) handling in bugprone-sizeof-expression (#94356)

This commit reimplements the functionality of the Clang Static Analyzer
checker `alpha.core.SizeofPointer` within clang-tidy by adding a new
(off-by-default) option to bugprone-sizeof-expression which activates
reporting all the `sizeof(ptr)` expressions (where ptr is an expression
that produces a pointer).

The main motivation for this change is that `alpha.core.SizeofPointer`
was an AST-based checker, which did not rely on the path sensitive
capabilities of the Static Analyzer, so there was no reason to keep it
in the Static Analyzer instead of the more lightweight clang-tidy.

After this commit I'm planning to create a separate commit that deletes
`alpha.core.SizeofPointer` from Clang Static Analyzer.

It was natural to place this moved logic in bugprone-sizeof-expression,
because that check already provided several heuristics that reported
various especially suspicious classes of `sizeof(ptr)` expressions.

The new mode `WarnOnSizeOfPointer` is off-by-default, so it won't
surprise the existing users; but it can provide a more through coverage
for the vulnerability CWE-467 ("Use of sizeof() on a Pointer Type") than
the existing partial heuristics.

Previously this checker had an exception that the RHS of a
`sizeof(array) / sizeof(array[0])` expression is not reported; I
generalized this to an exception that the check doesn't report
`sizeof(expr[0])` and `sizeof(*expr)`. This idea is taken from the
Static Analyzer checker `alpha.core.SizeofPointer` (which had an
exception for `*expr`), but analysis of open source projects confirmed
that this indeed eliminates lots of unwanted results.

Note that the suppression of `sizeof(expr[0])` and `sizeof(*expr)`
reports also affects the "old" mode `WarnOnSizeOfPointerToAggregate`
which is enabled by default.

This commit also replaces the old message "suspicious usage of
'sizeof(A*)'; pointer to aggregate" with two more concrete messages; but
I feel that this tidy check would deserve a through cleanup of all the
diagnostic messages that it can produce. (I added a FIXME to mark one
outright misleading message.)

show more ...


Revision tags: llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5
# 0e55fef0 10-Nov-2023 Nathan James <n.james93@hotmail.co.uk>

[clang-tidy] Tweak diag ranges for bugprone-sizeof-expression

Provide more useful warning locations and diagnostic ranges.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D10

[clang-tidy] Tweak diag ranges for bugprone-sizeof-expression

Provide more useful warning locations and diagnostic ranges.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D101617

show more ...


Revision tags: llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2
# e8a3ddaf 07-Aug-2023 Nathan James <n.james93@hotmail.co.uk>

[clang-tidy][NFC] Update tests to specify CheckOptions using new syntax

In D128337, The spelling of CheckOptions was updated to support a more natural dictionary syntax.
This patch is just updating

[clang-tidy][NFC] Update tests to specify CheckOptions using new syntax

In D128337, The spelling of CheckOptions was updated to support a more natural dictionary syntax.
This patch is just updating all test files to use the new syntax.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D130209

show more ...


Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3
# 9e1a4ce0 19-Aug-2022 eahcmrh <chris.hamilton@ericsson.com>

[clang-tidy] Fix for bugprone-sizeof-expression PR57167

This addresses a change in behavior of the bugprone-sizeof-expression
checker after upstream commit 15f3cd6bfc6, which cleaned up
ElaboratedTy

[clang-tidy] Fix for bugprone-sizeof-expression PR57167

This addresses a change in behavior of the bugprone-sizeof-expression
checker after upstream commit 15f3cd6bfc6, which cleaned up
ElaboratedType sugaring in the AST. This restores (mostly) the
beahvior of the checker prior to that commit, which may or may not have
been consistent with the intent of the checker, but at least gave a
tolerable level of what users would consider false positives.

Bug: https://github.com/llvm/llvm-project/issues/57167

Reviewed By: mizvekov, aaron.ballman

Differential Revision: https://reviews.llvm.org/D131926

Change-Id: Ibe5aad77ad00977134aa7fa67efbbd6bd725fd79

show more ...


Revision tags: llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6
# 89a1d03e 17-Jun-2022 Richard <legalize@xmission.com>

[clang-tidy] Organize test files into subdirectories by module (NFC)

Eliminate clutter by reorganizing the Lit test files for clang-tidy:
- Move checkers/<module>-* to checkers/<module>/*.
- Move mo

[clang-tidy] Organize test files into subdirectories by module (NFC)

Eliminate clutter by reorganizing the Lit test files for clang-tidy:
- Move checkers/<module>-* to checkers/<module>/*.
- Move module specific inputs from Inputs to <module>/Inputs. Remove
any module prefix from the file or subdirectory name as they are no
longer needed.
- Introduce a Lit substitution %clang_tidy_headers for the system
headers in checkers/Inputs/Headers and use this throughout. This
avoids referencing system headers through a relative path to the
parent directory and makes it clear that these fake system headers are
shared among all modules.
- Update add_new_check.py to follow the above conventions when creating
the boiler plate test files for a new check.
- Update Contributing.rst to describe per-module Inputs directory and
fix link to test source code.

Differential Revision: https://reviews.llvm.org/D128072

show more ...