[PATCH] D105553: [analyzer][NFC] Split the main logic of NoStoreFuncVisitor to an abstract NoStateChangeVisitor class

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 8 06:29:37 PDT 2021


Szelethus updated this revision to Diff 357202.
Szelethus edited the summary of this revision.
Szelethus added a comment.

- Don't depend on D105552 <https://reviews.llvm.org/D105552>.
- Merge with a followup patch; it was a poor splitting point, and the diffs didn't really convey what actually changed. However, it didn't make this patch look any more obfuscated.
  - Split up `maybeEmitNote` to special cases. Descendants will need to check whether the entity of interest was passed into the function or not, and emit a note if so.
    - `NoStateChangeVisitor` forces you to override 3 of these functions, one for ObjC 'self', one for C++ 'this', and one for regular parameters.
- D105552#2864085 <https://reviews.llvm.org/D105552#2864085> gives a bit more insight into the longer term plans:

> [...] clients only need to define these 3 [...]:
>
>> - What constitutes as a change to an entity
>> - What the diagnostic message should be
>> - What constitutes as the entity of interest being passed into the function
>
> In the end, in my eye, it would look like this:
>
>                        <--- NoStateChangeToRegionVisitor <--- NoStoreFuncVisitor
>                       /
>   NoStateChangeVisitor                                   <--- NoDynamicMemoryOwnershipChangeVisitor
>                       \                                 /
>                        <--- NoStateChangeToSymbolVisitor
>                                                         \
>                                                          <--- NoStreamOwnershipChangeVisitor
>
> - `NoStateChangeVisitor` will ask its clients the above mentioned 3 questions.
> - `NoStateChangeToSymbolVisitor` and `NoStateChangeToRegionVisitor` would answer whether the entity of interest was actually passed into the function, and propagate the rest.
> - Visitors on the bottom would take care of what remains.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105553/new/

https://reviews.llvm.org/D105553

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105553.357202.patch
Type: text/x-patch
Size: 26214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210708/f1591ce7/attachment-0001.bin>


More information about the cfe-commits mailing list