[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness
Florin Iucha via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 11 06:56:46 PST 2020
0x8000-0000 added a comment.
In D54943#1815473 <https://reviews.llvm.org/D54943#1815473>, @JonasToth wrote:
> In D54943#1815358 <https://reviews.llvm.org/D54943#1815358>, @0x8000-0000 wrote:
>
> > Here is a minimal example that shows the problem:
>
>
> I can not reproduce that case :(
> It gives me a compilation error in `const DoGooder anInstanceOf...`, because `DoGooder` requires an template parameter. I then add `DoGooder<int>` and the variable gets no transformation.
> Did you reproduce the error with exactly that code?
>
> And which version did you run? Maybe that was a previous false positive, that might be fixed right now?
The way I am testing is that I am fetching the current master branch of https://github.com/llvm/llvm-project.git, then downloading the latest patch from here and applying on top, then building.
This is the state of the tree right as of last night:
commit 1c8ab48028cc39429a392691ef2e66968460d782 (HEAD -> D54943.diff12)
Author: Florin Iucha <florin at signbit.net>
Date: Fri Jan 10 18:52:54 2020 -0500
D54943.diff12
commit 1b8c84b8dd5a4a294943a6a6f0631d2d3a1f9f27 (origin/master, origin/HEAD, master)
Author: Richard Smith <richard at metafoo.co.uk>
Date: Fri Jan 10 15:47:29 2020 -0800
Improve precision of documentation comment.
CTAD takes care of the missing template parameter, that's why I'm passing "-std=c++17" to clang-tidy.
/tmp$ /opt/clang10/bin/clang-tidy -checks="-*,cppcoreguidelines-const-correctness" -header-filter=".*" test.cpp -- -std=c++17 -Wall
54 warnings generated.
/tmp/test.cpp:22:9: warning: variable 'anInstanceOf' of type '<dependent type>' can be declared 'const' [cppcoreguidelines-const-correctness]
const DoGooder anInstanceOf{nullptr, Foo::someRandomConstant};
^
const
Suppressed 53 warnings (53 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
/tmp$ /opt/clang10/bin/clang++ -c test.cpp
test.cpp:22:15: error: use of class template 'DoGooder' requires template arguments
const DoGooder anInstanceOf{nullptr, Foo::someRandomConstant};
^
test.cpp:4:8: note: template is declared here
struct DoGooder
^
1 error generated.
/tmp$ /opt/clang10/bin/clang++ -std=c++17 -c test.cpp
-rw-r--r-- 1 florin florin 432 Jan 11 09:48 test.cpp
-rw-r--r-- 1 florin florin 744 Jan 11 09:52 test.o
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54943/new/
https://reviews.llvm.org/D54943
More information about the cfe-commits
mailing list