Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions clang/lib/StaticAnalyzer/Core/CallEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,27 +435,27 @@ static SVal processArgument(SVal Value, const Expr *ArgumentExpr,
/// runtime definition don't match in terms of argument and parameter count.
static SVal castArgToParamTypeIfNeeded(const CallEvent &Call, unsigned ArgIdx,
SVal ArgVal, SValBuilder &SVB) {
const FunctionDecl *RTDecl =
Call.getRuntimeDefinition().getDecl()->getAsFunction();
const auto *CallExprDecl = dyn_cast_or_null<FunctionDecl>(Call.getDecl());

if (!RTDecl || !CallExprDecl)
if (!CallExprDecl)
return ArgVal;

const FunctionDecl *Definition = CallExprDecl;
Definition->hasBody(Definition);

// The function decl of the Call (in the AST) will not have any parameter
// declarations, if it was 'only' declared without a prototype. However, the
// engine will find the appropriate runtime definition - basically a
// redeclaration, which has a function body (and a function prototype).
if (CallExprDecl->hasPrototype() || !RTDecl->hasPrototype())
if (CallExprDecl->hasPrototype() || !Definition->hasPrototype())
return ArgVal;

// Only do this cast if the number arguments at the callsite matches with
// the parameters at the runtime definition.
if (Call.getNumArgs() != RTDecl->getNumParams())
if (Call.getNumArgs() != Definition->getNumParams())
return UnknownVal();

const Expr *ArgExpr = Call.getArgExpr(ArgIdx);
const ParmVarDecl *Param = RTDecl->getParamDecl(ArgIdx);
const ParmVarDecl *Param = Definition->getParamDecl(ArgIdx);
return SVB.evalCast(ArgVal, Param->getType(), ArgExpr->getType());
}

Expand Down
Loading