This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy]mark record initList as non-const param
ClosedPublic

Authored by HerrCai0907 on Aug 17 2023, 12:33 AM.

Details

Summary
struct XY {
  int *x;
  int *y;
};
void recordInitList(int *x) {
  XY xy = {x, nullptr};
}

x cannot be const int* becase it in a initialize list which only accept int*

Diff Detail

Event Timeline

HerrCai0907 created this revision.Aug 17 2023, 12:33 AM
HerrCai0907 requested review of this revision.Aug 17 2023, 12:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 12:33 AM

add release note

Eugene.Zelenko added inline comments.
clang-tools-extra/docs/ReleaseNotes.rst
252

Please keep alphabetical order (by check name) in this section.

update release note

HerrCai0907 marked an inline comment as done.Aug 17 2023, 6:52 PM
HerrCai0907 added a reviewer: Eugene.Zelenko.
PiotrZSL added inline comments.Aug 19 2023, 8:37 AM
clang-tools-extra/docs/ReleaseNotes.rst
244
HerrCai0907 marked an inline comment as done.Aug 21 2023, 5:21 AM
PiotrZSL accepted this revision.Aug 21 2023, 7:50 AM

LGTM, but note that type aliases may not work properly, but that more a legacy issue that got source in line 104, simply because we should use canonical type there.

clang-tools-extra/test/clang-tidy/checkers/readability/non-const-parameter.cpp
235

Add a test with XYConst hidden behind typedef.
like

typedef XYConst XYConstTypedef;
XYConstTypedef yz = {x};
This revision is now accepted and ready to land.Aug 21 2023, 7:50 AM
This revision was landed with ongoing or failed builds.Aug 21 2023, 8:43 PM
This revision was automatically updated to reflect the committed changes.