[PATCH] D26207: [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 1 12:10:56 PDT 2016


aaron.ballman added inline comments.


================
Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:242
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);
----------------
This comment doesn't really match the test cases. The original code has two *different* declarations (only one of which is a definition), not one declaration and one redeclaration with the definition.

I think what is really happening is that it is adding the `&` qualifier to the first declaration, and adding the `const` and `&` qualifiers to the second declaration, and the result is that you get harmonization. But it brings up a question to me; what happens with:
```
void f1(ExpensiveToCopyType A) {
}

void f1(const ExpensiveToCopyType A) {

}
```
Does the fix-it try to create two definitions of the same function?


================
Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:244
+void PositiveConstDeclaration(const ExpensiveToCopyType A);
+// CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A);
+void PositiveConstDeclaration(ExpensiveToCopyType A) {
----------------
Is the `CHECK-MESSAGES` missing?


Repository:
  rL LLVM

https://reviews.llvm.org/D26207





More information about the cfe-commits mailing list