<div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>I'm trying to write a custom checker that would look for transaction objects being created and used, and would issue a warning when the success of the transaction was not checked after commit.<br>

<br></div>I'm using checkPreCall, and I can successfully find when a transaction object is constructed, and I add the tracking information, based on what I've seen in StreamChecker.cpp:<br><br>if(call.getKind() == CE_CXXConstructor)<br>

{<br>    auto callExpr = static_cast<const CallExpr*>(call.getOriginExpr());<br><br>    SValBuilder& svalBuilder = context.getSValBuilder();<br>    const LocationContext* locationContext = context.getPredecessor()->getLocationContext();<br>

    DefinedSVal createdTransactionObjVal = llvm::cast<DefinedSVal>(svalBuilder.conjureSymbolVal(0, callExpr, locationContext, context.blockCount()));<br>    programState = programState->BindExpr(callExpr, context.getLocationContext(), createdTransactionObjVal);<br>

<br>    if(SymbolRef createdTransactionObjSymbol = createdTransactionObjVal.getAsSymbol())<br>    {<br>        programState = programState->set<TransactionStateMap>(createdTransactionObjSymbol, TransactionState());<br>

        context.addTransition(programState);<br>    }<br>    ...<br>}<br>...<br><br></div><div>So first, is there any easier way to access the symbolic value that is created as the result of the constructor running? This seems like an awfully complicated way of doing a simple task.<br>

</div><div><br></div>Next, my problem is with detecting when members of the transaction object is called. I was trying to get the SymbolRef of the object whose member is called:<br><br>const CXXInstanceCall* instanceCall = llvm::dyn_cast<CXXInstanceCall>(&call);<br>

...<br>SymbolRef transactionObjectSymbol = instanceCall->getCXXThisVal().getAsSymbol();<br><br></div>But I find that this SymbolRef is always NULL. Why is that?<br><br></div>I also tried to work around with this:<br>SymbolRef transactionObjectSymbol = programState->getSVal(static_cast<const CXXMemberCallExpr*>(instanceCall->getOriginExpr())->getImplicitObjectArgument(), context.getLocationContext()).getAsSymbol();<br>

<br></div>But this doesn't work either.<br><br></div>What am I doing wrong?<br><br>Thanks!<br><br>Gabor<br><div><div><br></div></div></div>