aaron.ballman added inline comments.

================
Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:146
+
+    if (const auto *Parent = Par->getParentFunctionOrMethod()) {
+      if (const auto *F = dyn_cast<FunctionDecl>(Parent)) {
----------------
Please do not use `auto` here, as the type is not spelled out in the 
initialization.


================
Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:147
+    if (const auto *Parent = Par->getParentFunctionOrMethod()) {
+      if (const auto *F = dyn_cast<FunctionDecl>(Parent)) {
+        const auto ParDecl =
----------------
What if the parent is an `ObjCMethodDecl` instead?


================
Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:148-152
+        const auto ParDecl =
+            F->getFirstDecl()->getParamDecl(Par->getFunctionScopeIndex());
+        if (Par != ParDecl)
+          D << ParDecl->getName()
+            << FixItHint::CreateInsertion(ParDecl->getLocStart(), "const ");
----------------
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;
}
```


Repository:
  rL LLVM

https://reviews.llvm.org/D36672



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to