[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-06-28 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 153267. JonasToth added a comment. - rebase on commited ExpMutationAnalyzer - clean up, documentation Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-05-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. I see. Thank you for fixing + explaining :) Am 30.04.2018 um 23:39 schrieb Shuai Wang via Phabricator: > shuaiwang added a comment. > >> Why do you think that looping is required? From my understanding, we >> >> need the first usage (DeclRefExpr) to get the analysi

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-30 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. > Why do you think that looping is required? From my understanding, we > need the first usage (DeclRefExpr) to get the analysis started. The > analysis itself will check all remaining uses. Is this necessary, > because we analysis on a `Expr` basis? Yes. the analyzer

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-30 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 144617. JonasToth added a comment. - fix bad template instantiation Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/ConstCheck.cpp clang-tidy/cppco

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-30 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 144616. JonasToth added a comment. - migrate to Decl interface - add template metaprogramming test Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/Co

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-30 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. I will migrate to the new API today evening (european time). Why do you think that looping is required? From my understanding, we need the first usage (DeclRefExpr) to get the analysis started. The analysis itself will check all remaining uses. Is this necessary, becaus

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-29 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/cppcoreguidelines/ConstCheck.cpp:229-237 + const auto *UseExpr = selectFirst("use", Usage); + + // The declared variables was used in non-const conserving way and can not + // be declared as const. + if (UseExpr && Scope

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-28 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 144458. JonasToth added a comment. - [Feature] use new statefull const checker - [Test] add more tests finding false positives Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt cla

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 142991. JonasToth added a comment. - [Misc] mark false positives Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/ConstCheck.cpp clang-tidy/cppcoreg

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. @shuaiwang I implemented the check on top of you utility function. It does fail right now (concentrating on values only for now). I added a `FIXME` for all false positives/negatives for the values test cases. Repository: rCTE Clang Tools Extra https://reviews.llvm

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 142988. JonasToth added a comment. - [Feature] refactor check to use a utility function to determine constness Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreg

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-17 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. In https://reviews.llvm.org/D45444#1069488, @shuaiwang wrote: > I've updated https://reviews.llvm.org/D45679 and I think the `isModified()` > function there is now sufficiently covering the cases you've covered here and > can be used as a good starting version if you

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. I've updated https://reviews.llvm.org/D45679 and I think the `isModified()` function there is now sufficiently covering the cases you've covered here and can be used as a good starting version if you plan to use it here. I copied your const-values test cases and it now

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. > You'll also need to check: > > - a member function calling another non-const member function -> *this can't > be const > - *this is passed as non-const reference param to a function -> *this can't > be const Yes. That is similar behaviour to checking if a function

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45444#1068967, @Eugene.Zelenko wrote: > In https://reviews.llvm.org/D45444#1068496, @shuaiwang wrote: > > > - I would imagine things could get messier if this check expands to also > > check for turning member functions const: it's basicall

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. >> I would imagine things could get messier if this check expands to also >> check for turning member functions const: it's basically checking >> CxxThisExpr, being a handle, is not modified within a member function, but >> note there's no VarDecl for "this". > > U

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. In https://reviews.llvm.org/D45444#1068496, @shuaiwang wrote: > - I would imagine things could get messier if this check expands to also > check for turning member functions const: it's basically checking > CxxThisExpr, being a handle, is not modified within a me

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. > Coming from https://reviews.llvm.org/D45679, which I should have sent out > much earlier to get in front of you :p > > Kidding aside this check is more mature than mine and I'm happy to help > incorporate mine into this one. I would love to, yours is more elegant :

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Coming from https://reviews.llvm.org/D45679, which I should have sent out much earlier to get in front of you :p Kidding aside this check is more mature than mine and I'm happy to help incorporate mine into this one. I do have a strong opinion that requires non-trivi

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. @aaron.ballman @lebedev.ri The check is getting really complex. I run it over LLVM and detected some warnings, where iam not sure if they are valid or not. Its already a somewhat usable state, but its hard to determine false positives and false negatives. For me, tha

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 142544. JonasToth added a comment. - [Misc] unify handle and value modification detection - [Misc] found new caveats, maybe take a look at refactoring first an require this check to produce clean compiles on llvm Repository: rCTE Clang Tools Extra http

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-14 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 142526. JonasToth added a comment. - [Feature] start working on handle semantic Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/ConstCheck.cpp clan

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-14 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 142521. JonasToth added a comment. - [Feature] implement array and method access - [Feature] finalize value semantic Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cp

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment. Thank you for working on this check! Comment at: clang-tidy/cppcoreguidelines/ConstCheck.h:60 + + std::unordered_map ValueCanBeConst; + std::unordered_map HandleCanBeConst; I'm guessing these should be `llvm::DenseMap`. Repositor

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-10 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. In https://reviews.llvm.org/D45444#1063291, @JonasToth wrote: > > It'll be good idea to have option to apply this check for > > pointer/references only, or include built-in types/enums. > > Agreed. I aim at a `mark handles const`(default on), `mark values > const

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. > It'll be good idea to have option to apply this check for pointer/references > only, or include built-in types/enums. Agreed. I aim at a `mark handles const`(default on), `mark values const`(default on for objects), `mark pointer (const int * >> const <<) const` (d

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. Will be good idea to add HICPP alias. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. It'll be good idea to have option to apply this check for pointer/references only, or include built-in types/enums. Comment at: clang-tidy/cppcoreguidelines/ConstCheck.cpp:13 +#include "clang/ASTMatchers/ASTMatchFinder.h" + +#include --

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. @aaron.ballman, @lebedev.ri, @alexfh and everyone else, i would love to hear your opinion on my approach. i never implemented a similar check and i might miss some cases, that need to be considered. The current state is just a proof-of-concept to see how such a check

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision. JonasToth added reviewers: alexfh, aaron.ballman, lebedev.ri, hokein. Herald added subscribers: cfe-commits, kbarton, xazax.hun, mgorny, nemanjai, klimek. This check aims to determine values and references that could be declared as const, but are not. The first v