[cfe-commits] r161017 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h lib/StaticAnalyzer/Core/CallEvent.cpp lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp lib/StaticAnalyzer/Core/Store.cpp

Jordan Rose jordan_rose at apple.com
Wed Aug 1 09:19:57 PDT 2012


>> 
>> +void BlockCall::getInitialStackFrameContents(const StackFrameContext *CalleeCtx,
>> +                                             BindingsTy &Bindings) const {
>> +  const BlockDecl *D = cast<BlockDecl>(CalleeCtx->getDecl());
>> +  SValBuilder &SVB = getState()->getStateManager().getSValBuilder();
>> +  addParameterValuesToBindings(CalleeCtx, Bindings, SVB, *this,
>> +                               D->param_begin(), D->param_end());
>> +}
>> +
>> +
> 
> Can't you reuse AnyFunctionCall's implementation of getInitialStackFrameContents(), param_begin(), and param_end()?

Wish we could, but BlockDecls are not FunctionDecls, and since we're pulling the decl out of the StackFrameContext (to avoid recomputing it) we have to cast it to one or the other. I suppose this could be templated somewhere.



>> QualType BlockCall::getDeclaredResultType() const {
>>  const BlockDataRegion *BR = getBlockRegion();
>>  if (!BR)
>> @@ -445,6 +489,21 @@
>>    Regions.push_back(static_cast<const MemRegion *>(Data));
>> }
>> 
>> +void CXXConstructorCall::getInitialStackFrameContents(
>> +                                             const StackFrameContext *CalleeCtx,
>> +                                             BindingsTy &Bindings) const {
>> +  AnyFunctionCall::getInitialStackFrameContents(CalleeCtx, Bindings);
>> +
>> +  SVal ThisVal = getCXXThisVal();
>> +  if (!ThisVal.isUnknown()) {
>> +    SValBuilder &SVB = getState()->getStateManager().getSValBuilder();
>> +    const CXXMethodDecl *MD = cast<CXXMethodDecl>(CalleeCtx->getDecl());
>> +    Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
>> +    Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
>> +  }
>> +}
>> +
>> +
>> 
> 
> Is there a reason why CXXConstructor, CXXDestructor, CXXInstanceCall cannot share the implementation (I noticed that CXXConstructorCall is not subclassed from instance call.. )?

Again, I wish they could, but constructors and destructors are not built on CallExpr. So then CXXInstanceCall would duplicate the machinery of SimpleCall (to get argument expressions and such).

(In theory this is something multiple inheritance can solve, but I'm quite leery of actually introducing it here, not in the least because it would increase the size of CXXInstanceCall objects.)



More information about the cfe-commits mailing list