diff options
author | Devin Coughlin <dcoughlin@apple.com> | 2015-12-04 05:00:36 +0000 |
---|---|---|
committer | Devin Coughlin <dcoughlin@apple.com> | 2015-12-04 05:00:36 +0000 |
commit | ebeed880786aa64c702e53faf1fb31b6bd897086 (patch) | |
tree | bb5da6e58d2dd5a28f3f66c290d7f834908dc674 /clang/lib/StaticAnalyzer/Core/CallEvent.cpp | |
parent | d31c1ba19a985d0c6e9805a68fd44604dae42799 (diff) | |
download | bcm5719-llvm-ebeed880786aa64c702e53faf1fb31b6bd897086.tar.gz bcm5719-llvm-ebeed880786aa64c702e53faf1fb31b6bd897086.zip |
[analyzer] Support inlining lambda-converted blocks.
clang converts C++ lambdas to blocks with an implicit user-defined conversion
operator method on the lambda record. This method returns a block that captures a copy
of the lambda. To inline a lambda-converted block, the analyzer now calls the lambda
records's call operator method on the lambda captured by the block.
llvm-svn: 254702
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CallEvent.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index 3a55eb1b977..51dd7c82260 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -598,10 +598,25 @@ void BlockCall::getExtraInvalidatedValues(ValueList &Values, void BlockCall::getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const { - const BlockDecl *D = cast<BlockDecl>(CalleeCtx->getDecl()); SValBuilder &SVB = getState()->getStateManager().getSValBuilder(); + ArrayRef<ParmVarDecl*> Params; + if (isConversionFromLambda()) { + auto *LambdaOperatorDecl = cast<CXXMethodDecl>(CalleeCtx->getDecl()); + Params = LambdaOperatorDecl->parameters(); + + // For blocks converted from a C++ lambda, the callee declaration is the + // operator() method on the the lambda so we bind "this" to + // the lambda captured by the block. + const VarRegion *CapturedLambdaRegion = getRegionStoringCapturedLambda(); + SVal ThisVal = loc::MemRegionVal(CapturedLambdaRegion); + Loc ThisLoc = SVB.getCXXThis(LambdaOperatorDecl, CalleeCtx); + Bindings.push_back(std::make_pair(ThisLoc, ThisVal)); + } else { + Params = cast<BlockDecl>(CalleeCtx->getDecl())->parameters(); + } + addParameterValuesToBindings(CalleeCtx, Bindings, SVB, *this, - D->parameters()); + Params); } |