-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang-tidy] fix bugprone-sizeof-expression when sizeof expression with template types #115275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -175,7 +175,8 @@ Changes in existing checks | |||||||||||||||
| - Improved :doc:`bugprone-sizeof-expression | ||||||||||||||||
| <clang-tidy/checks/bugprone/sizeof-expression>` check to find suspicious | ||||||||||||||||
| usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or | ||||||||||||||||
| subtracting from a pointer directly or when used to scale a numeric value. | ||||||||||||||||
| subtracting from a pointer directly or when used to scale a numeric value and | ||||||||||||||||
| fix false positive when sizeof expression with template types. | ||||||||||||||||
|
Comment on lines
+178
to
+179
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there were no releases since this change, then there is no need for the release note entry. Basically you're hotfixing a change that is coming out in the same hypothetical next release. If the change in this patch is not related to what is mentioned in this changelog entry, then it is worth a full new changelog entry, like this:
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think not. clang-tidy release-note always combines the all changes of rule in one item instead of spilt them.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. example:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you meant here. There should be a release note, unless the issue was introduced in the current, release cycle. The diagnostic reproduces in clang-tidy 18 for me, or did you mean something different (e.g., general in-case-of comment)?
+1, that's the current approach
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because of the merged release note I thought this is related to #106061, hence the confusion. |
||||||||||||||||
|
|
||||||||||||||||
| - Improved :doc:`bugprone-unchecked-optional-access | ||||||||||||||||
| <clang-tidy/checks/bugprone/unchecked-optional-access>` to support | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -385,3 +385,8 @@ int ValidExpressions() { | |
| sum += sizeof(PtrArray) / sizeof(A[0]); | ||
| return sum; | ||
| } | ||
|
|
||
| template<class T> | ||
| int ValidateTemplateTypeExpressions(T t) { | ||
| return sizeof(t.val) / sizeof(t.val[0]); | ||
| } | ||
|
Comment on lines
+390
to
+393
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please note the issue somewhere on this test-case (115175) (e.g. namespace) |
||
Uh oh!
There was an error while loading. Please reload this page.