[PATCH] D88088: WIP [clang] improve accuracy of ExprMutAnalyzer
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 24 07:24:30 PDT 2020
JonasToth added inline comments.
================
Comment at: clang/lib/Analysis/ExprMutationAnalyzer.cpp:455
+ const auto HasAnyNonConstIterator =
+ anyOf(allOf(hasMethod(allOf(hasName("begin"), unless(isConst()))),
+ unless(hasMethod(allOf(hasName("begin"), isConst())))),
----------------
aaron.ballman wrote:
> 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()`?
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.
================
Comment at: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp:65
+
+ std::string buffer;
for (const auto *E = selectFirst<Expr>("expr", Results); E != nullptr;) {
----------------
aaron.ballman wrote:
> Was there a reason you hoisted this out of the `for` loop?
Jup.
```
buffer.clear()
```
The current form does proper memory-recycling (i believe at least :D)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88088/new/
https://reviews.llvm.org/D88088
More information about the cfe-commits
mailing list