This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] readability-non-const-parameter: fixit on all function declarations
AbandonedPublic

Authored by AndersRonnholm on Aug 14 2017, 5:47 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

AndersRonnholm created this revision.Aug 14 2017, 5:47 AM
Eugene.Zelenko retitled this revision from readability-non-const-parameter: fixit on all function declarations to [clang-tidy] readability-non-const-parameter: fixit on all function declarations.Aug 14 2017, 7:16 AM
Eugene.Zelenko added a project: Restricted Project.

LGTM. But others should approve.

aaron.ballman added inline comments.Aug 16 2017, 6:54 AM
clang-tidy/readability/NonConstParameterCheck.cpp
146

Please do not use auto here, as the type is not spelled out in the initialization.

147

What if the parent is an ObjCMethodDecl instead?

148–152

Don't we need the fixit for *all* declarations of the function? e.g.,

char f(char *c); // Need it here
char f(char *c); // And here

char f(char *c) { // And here
  return *c;
}

Fixed comments

AndersRonnholm marked 2 inline comments as done.Sep 8 2017, 5:46 AM
AndersRonnholm added inline comments.
clang-tidy/readability/NonConstParameterCheck.cpp
147

I don't think this checker handles objective-c

aaron.ballman added inline comments.Sep 8 2017, 7:29 AM
clang-tidy/readability/NonConstParameterCheck.cpp
143

You should remove the quotes around %0 and drop the getName() -- the diagnostics engine automatically handled NamedDecl subclasses and properly quotes them.

147

I think it does -- it has a matcher for ParmVarDecl, which can be contained by an ObjCMethodDecl.

149

const auto *

151

You can drop the getName() call here as well.

AndersRonnholm abandoned this revision.Dec 6 2017, 7:04 AM

Fixed by rL319021. At least for c/c++ not sure if it handles objective-c.