[PATCH] D83864: [ClangTidy] Fix false positives of readability-non-const-parameters check
Jacques Lucke via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 15 05:07:39 PDT 2020
JacquesLucke created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
We recently started using Clang Tidy on the Blender source. We found a
couple of false positives of the `readability-non-const-parameters` check.
One of those is fixed by this patch.
struct MyStruct {
float *values;
};
void myfunc(float *values) {
MyStruct mystruct = {values};
}
Without this patch, Clang Tidy reports that the `values` parameter of
`myfunc` can be const. It does not recognize that it is assigned to
a non-const data member of `MyStruct`.
Note, this is the first time I'm working with the LLVM source code.
So please let me know if I'm doing something wrong.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83864
Files:
clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
Index: clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
@@ -99,7 +99,6 @@
for (const auto *F : D->fields()) {
if (InitNr >= ILE->getNumInits())
break;
-
const auto *Init = ILE->getInit(InitNr++);
if (!F->getType().isConstQualified())
markCanNotBeConst(Init, true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83864.278152.patch
Type: text/x-patch
Size: 564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200715/aac5a251/attachment-0001.bin>
More information about the cfe-commits
mailing list