[analyzer] Address Jordan's code review of r175857.

llvm-svn: 176043
This commit is contained in:
Anna Zaks 2013-02-25 19:50:50 +00:00
parent 77cdb53cdf
commit 2d773b8138
2 changed files with 31 additions and 20 deletions

View File

@ -228,6 +228,11 @@ public:
return false; return false;
} }
/// \brief Returns true if this is a call to a variadic function or method.
virtual bool isVariadic() const {
return false;
}
/// \brief Returns a source range for the entire call, suitable for /// \brief Returns a source range for the entire call, suitable for
/// outputting in diagnostics. /// outputting in diagnostics.
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const {
@ -416,6 +421,10 @@ public:
return RuntimeDefinition(); return RuntimeDefinition();
} }
virtual bool isVariadic() const {
return getDecl()->isVariadic();
}
virtual bool argumentsMayEscape() const; virtual bool argumentsMayEscape() const;
virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx,
@ -516,6 +525,10 @@ public:
return RuntimeDefinition(getBlockDecl()); return RuntimeDefinition(getBlockDecl());
} }
virtual bool isVariadic() const {
return getBlockDecl()->isVariadic();
}
virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx,
BindingsTy &Bindings) const; BindingsTy &Bindings) const;
@ -834,6 +847,9 @@ public:
virtual const Expr *getArgExpr(unsigned Index) const { virtual const Expr *getArgExpr(unsigned Index) const {
return getOriginExpr()->getArg(Index); return getOriginExpr()->getArg(Index);
} }
virtual bool isVariadic() const {
return getDecl()->isVariadic();
}
bool isInstanceMessage() const { bool isInstanceMessage() const {
return getOriginExpr()->isInstanceMessage(); return getOriginExpr()->isInstanceMessage();

View File

@ -569,7 +569,8 @@ ProgramStateRef ExprEngine::bindReturnValue(const CallEvent &Call,
// Conservatively evaluate call by invalidating regions and binding // Conservatively evaluate call by invalidating regions and binding
// a conjured return value. // a conjured return value.
void ExprEngine::conservativeEvalCall(const CallEvent &Call, NodeBuilder &Bldr, void ExprEngine::conservativeEvalCall(const CallEvent &Call, NodeBuilder &Bldr,
ExplodedNode *Pred, ProgramStateRef State) { ExplodedNode *Pred,
ProgramStateRef State) {
State = Call.invalidateRegions(currBldrCtx->blockCount(), State); State = Call.invalidateRegions(currBldrCtx->blockCount(), State);
State = bindReturnValue(Call, Pred->getLocationContext(), State); State = bindReturnValue(Call, Pred->getLocationContext(), State);
@ -671,13 +672,13 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
if (!D) if (!D)
return false; return false;
AnalyzerOptions &Opts = getAnalysisManager().options; AnalysisManager &AMgr = getAnalysisManager();
AnalysisDeclContext *CalleeADC = AnalyzerOptions &Opts = AMgr.options;
Call.getLocationContext()->getAnalysisDeclContext()-> AnalysisDeclContextManager &ADCMgr = AMgr.getAnalysisDeclContextManager();
getManager()->getContext(D); AnalysisDeclContext *CalleeADC = ADCMgr.getContext(D);
// The auto-synthesized bodies are essential to inline as they are // The auto-synthesized bodies are essential to inline as they are
// usually small and commonly used. note, we should do this check early on to // usually small and commonly used. Note: we should do this check early on to
// ensure we always inline these calls. // ensure we always inline these calls.
if (CalleeADC->isBodyAutosynthesized()) if (CalleeADC->isBodyAutosynthesized())
return true; return true;
@ -685,7 +686,7 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
if (HowToInline == Inline_None) if (HowToInline == Inline_None)
return false; return false;
// Check if we should inline a call based on it's kind. // Check if we should inline a call based on its kind.
if (!shouldInlineCallKind(Call, Pred, Opts)) if (!shouldInlineCallKind(Call, Pred, Opts))
return false; return false;
@ -713,14 +714,8 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
return false; return false;
// Do not inline variadic calls (for now). // Do not inline variadic calls (for now).
if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) { if (Call.isVariadic())
if (BD->isVariadic())
return false; return false;
}
else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->isVariadic())
return false;
}
// Check our template policy. // Check our template policy.
if (getContext().getLangOpts().CPlusPlus) { if (getContext().getLangOpts().CPlusPlus) {
@ -744,8 +739,8 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
return false; return false;
// Do not inline large functions too many times. // Do not inline large functions too many times.
if (Engine.FunctionSummaries->getNumTimesInlined(D) > if ((Engine.FunctionSummaries->getNumTimesInlined(D) >
Opts.getMaxTimesInlineLarge() && Opts.getMaxTimesInlineLarge()) &&
CalleeCFG->getNumBlockIDs() > 13) { CalleeCFG->getNumBlockIDs() > 13) {
NumReachedInlineCountMax++; NumReachedInlineCountMax++;
return false; return false;