how to use clang::ento::ProgramState::contains | static analyzer

Hey everyone,

while having a look at the SimpleStreamChecker example
in the checkers folder of the static analyzer I can't figure
out how to use the contains function.

I would expect it to work like the get function so it could be called like this:

SymbolRef FileDesc = Call.getArgSVal(0).getAsSymbol();
ProgramStateRef State = C.getState();
bool b = State->contains<StreamMap>(FileDesc);

But trying to compile I get an error saying:
no member named 'Contains' in'clang::ento::ProgramStateTrait<(anonymous namespace)::StreamMap>'...

Is there another function I have to implement to get this working?


Meanwhile I tried calling "contains" on the other available containers
set & list after registering them with (REGISTER_SET_WITH_PROGRAMSTATE, REGISTER_LIST_...). For those types "contains" works without any problems.

Is this a bug regarding map and the "contains" function? It seems like it. To reproduce the compile error it is sufficient to register a map with:

and then call
// CheckerContext &context

This should produce the compile error stated in my previous post.

In case anyone else is starting to use the analyzer and stumbles across this. There is no "contains" function for map like stated in the checker dev manual:
To check if the key is contained in a map one can simply use
get<YourMapName>. If get returns null the key is not contained.

This pattern is for example used in SimpleStreamChecker.cpp
like this:

const StreamState *SS = State->get<StreamMap>(FileDesc);
// if SS is null the key is not contained
if (SS && SS->isClosed()) {
     reportDoubleClose(FileDesc, Call, C);