Details
Diff Detail
- Repository
- rCTE Clang Tools Extra
- Build Status
Buildable 18045 Build 18045: arc lint + arc unit
Event Timeline
Please also take a look on 26817 for another idea for .data().
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
20 ↗ | (On Diff #142701) | Please separate with empty line. |
32 ↗ | (On Diff #142701) | Isn't this list redundant for using namespace clang::ast_matchers? |
docs/ReleaseNotes.rst | ||
63 | I would suggest Finds redundant .data() calls. Same in documentation. Please also move to new checks list in alphabetical order. | |
docs/clang-tidy/checks/readability-redundant-data-call.rst | ||
14 ↗ | (On Diff #142701) | Please look on other check documentation for example of option descriptions. |
docs/ReleaseNotes.rst | ||
---|---|---|
63 | Please enclose .data() in ``. Same in documentation. |
Have you run this over any large code bases to see whether the check triggers in practice?
docs/clang-tidy/checks/list.rst | ||
---|---|---|
96 | This change looks unrelated to the patch and should be handled separately. | |
docs/clang-tidy/checks/readability-redundant-data-call.rst | ||
6 ↗ | (On Diff #142701) | What does it mean for a data() call to be redundant? I think the documentation needs to explain that a bit more. |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
22 ↗ | (On Diff #143204) | Actually you should use static, not anonymous namespace for variables and functions. |
docs/ReleaseNotes.rst | ||
143 | r is after p :-) | |
146 | Please remove This check and enclose .data() in `, not . Same for documentation. | |
docs/clang-tidy/checks/readability-redundant-data-call.rst | ||
6 ↗ | (On Diff #143204) | Please use as much of 80 characters as possible. |
8 ↗ | (On Diff #143204) | operator[] should be enclosed in `, not . |
14 ↗ | (On Diff #143204) | Please insert empty line above. |
22 ↗ | (On Diff #143204) | I think will be good idea to specify default value as complete string. |
Addressed more comments.
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
22 ↗ | (On Diff #143204) | Done, but why? |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
22 ↗ | (On Diff #143204) |
Have you run this over any large code bases to see whether the check triggers in practice?
I'm still curious about this, btw.
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
45 ↗ | (On Diff #143207) | Should this check apply equally to std::string::c_str() as well as std::string::data()? |
57 ↗ | (On Diff #143207) | I think the word "redundant" isn't going to be immediately obvious to a user who would write code like that. Perhaps "accessing an element of the container does not require a call to 'data()'; did you mean to use 'operator[]()' instead?" |
docs/clang-tidy/checks/readability-redundant-data-call.rst | ||
7 ↗ | (On Diff #143207) | doing array subscript -> doing an array subscript |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
45 ↗ | (On Diff #143207) | readability-redundant-string-cstr do both. |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
31 ↗ | (On Diff #143207) | No need to register any of these matchers unless in C++ mode. |
45 ↗ | (On Diff #143207) | Yup! But that makes me wonder if the name "redundant-data-call" is an issue. Perhaps the check name should focus more on the array subscript in the presence of an operator[]()? |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
45 ↗ | (On Diff #143207) | How about "readability-circumlocutionary-subscript"? |
From randomly checking several triggerings no I didn't find any false positives. I feel the check should be pretty safe in terms of false positives because we only trigger on configured types.
Good to hear, thank you for the information.
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
45 ↗ | (On Diff #143207) | hah, I think circumlocutionary might be a bit too much. ;-) I think readability-simplify-array-subscript-expr might be reasonable, however. Right now, the simplification is just for foo.data()[0] but it seems plausible that there are other array subscript simplifications that could be added in the future, like a[1 + 1] being converted to a[2] or x ? a[200] : a[400] going to a[x ? 200 : 400] (etc). |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
45 ↗ | (On Diff #143207) | Just readability-simplify-subscript-expr? Let me know if this name looks good to you and I'll do the actual renaming (together with addressing other comments) after your confirmation. |
clang-tidy/readability/RedundantDataCallCheck.cpp | ||
---|---|---|
45 ↗ | (On Diff #143207) | I think readability-simplify-subscript-expr is a reasonable name. |
This URL looks stale.