[PATCH] D51388: [analyzer] Legalize state manager factory injection.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 28 15:56:35 PDT 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs.
Herald added subscribers: cfe-commits, Szelethus, mikhail.ramalho, baloghadamsoftware.

When a checker maintains a program state trait that isn't a simple list/set/map, but is a combination of multiple lists/sets/maps (eg., a multimap - which may be implemented as a map from something to set of something), `ProgramStateManager` only contains the factory for the trait itself. All auxiliary lists/sets/maps need a factory to be provided by the checker, which is annoying.

So far two checkers wanted a multimap, and both decided to trick the `ProgramStateManager` into keeping the auxiliary factory within itself by pretending that it's some sort of trait they're interested in, but then never using this trait but only using the factory.

I decided to make it legal because this functionality seems useful and i didn't want to dig deeply into the template magic around state traits when there's already a one-liner solution, though i agree that it should be possible to implement this in a more straightforward manner.

One thing that becomes apparent once all pieces are put together is that these two checkers are in fact //using the same factory//, because the type that identifies it, `ImmutableMap<const MemRegion *, ImmutableSet<SymbolRef>>`, is the same. This situation is different from two checkers registering similar traits.

I also moved stuff around a bit because it always bothered me.


Repository:
  rC Clang

https://reviews.llvm.org/D51388

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51388.162968.patch
Type: text/x-patch
Size: 10912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180828/1efd6752/attachment-0001.bin>


More information about the cfe-commits mailing list