This patch extracts the ExprMutAnalyzer changes from https://reviews.llvm.org/D54943
into its own revision for simpler review and more atomic changes.
Details
- Reviewers
aaron.ballman - Commits
- rGe517e5cfec90: [clang] improve accuracy of ExprMutAnalyzer
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Analysis/ExprMutationAnalyzer.cpp | ||
---|---|---|
44 | Unless the value -> Matches unless the value | |
65 | I think I'd prefer this to be named hasAnyInit() to complement hasInit() -- these aren't really arguments. | |
275 | operator call expression -> The call operator expression | |
277 | moditication -> modification | |
345 | casted -> cast | |
465 | It is possible, that -> It is possible that | |
468 | is faster to find then all -> is then faster to find all | |
471 | Do we want to look for methods that end with _?[Bb]egin or _?[Ee]nd so that this would catch patterns like foo_begin()/foo_end(), FooBegin()/FooEnd(), or Foo_Begin()/Foo_End()? | |
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
66 | Was there a reason you hoisted this out of the for loop? |
- improve the expression matcher, to catch the expression in general ternary-operator cases, too
- considered unresolved operator calls to be a modification
- fix method calls with templates in some instances
- adress review comments
clang/lib/Analysis/ExprMutationAnalyzer.cpp | ||
---|---|---|
471 | This specific matcher is only applied in range-for contexts. There only the begin(); end() methods matter. I updated the comment above to clarify this. | |
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
66 | Jup. buffer.clear() The current form does proper memory-recycling (i believe at least :D) |
LGTM aside from a nit.
clang/lib/Analysis/ExprMutationAnalyzer.cpp | ||
---|---|---|
471 | Ah, okay, that makes a lot more sense, thanks! | |
clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
66 | This smells like a micro-optimization to me (I think declaring the variable in the loop is more clear than clearing the buffer on each iteration). I don't insist on changing it, but if you want to keep it, you should name it Buffer per our usual coding rules. |
- document sections in the testcases, hopefully little more structure for comprehension
- fix derived-to-base-cast OUTSIDE of an conditional operator
- improve type-dependent callexpr, too
- better canResolveToExpr matcher code
- adjust matcher for comma
@aaron.ballman I update the code a bit. This stuff is just a hydra :/
But i think incrementally the current version is better, but still not perfect. I update the clang-tidy part, too.
Edit: from scrolling through there are still rough edges in the current version. i will remove the stuff tomorrow, right now i am to tired :/
LGTM though I may have spotted a potential improvement (it can be handled in a follow-up if you want).
clang/lib/Analysis/ExprMutationAnalyzer.cpp | ||
---|---|---|
61 | Do you also want to handle the binary conditional operator (a GNU extension like a ? : b)? |
clang/lib/Analysis/ExprMutationAnalyzer.cpp | ||
---|---|---|
61 | Yup, was a fast improvement. Thanks for pointing that out 👍 |
Unless the value -> Matches unless the value