summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2015-10-27 13:46:39 +0000
committerGabor Horvath <xazax.hun@gmail.com>2015-10-27 13:46:39 +0000
commitba7d9071fe60e53a49a6e4daf22db332f44d0b6c (patch)
treec81578a68fd3f268c304327d2e18d93b4156da1b /clang/lib
parentbd73bcf84a948afd8e1fc39ba8eeb853b634e0d1 (diff)
downloadbcm5719-llvm-ba7d9071fe60e53a49a6e4daf22db332f44d0b6c.tar.gz
bcm5719-llvm-ba7d9071fe60e53a49a6e4daf22db332f44d0b6c.zip
[analyzer] Fix lambdas that are capturing constants.
llvm-svn: 251407
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index afef624f5dc..f6129a963f8 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1859,13 +1859,20 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D,
FieldDecl *LambdaThisCaptureField;
CXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);
const FieldDecl *FD = LambdaCaptureFields[VD];
- Loc CXXThis =
- svalBuilder.getCXXThis(MD, LocCtxt->getCurrentStackFrame());
- SVal CXXThisVal = state->getSVal(CXXThis);
- V = state->getLValue(FD, CXXThisVal);
- if (FD->getType()->isReferenceType() &&
- !VD->getType()->isReferenceType())
- CaptureByReference = true;
+ if (!FD) {
+ // When a constant is captured, sometimes no corresponding field is
+ // created in the lambda object.
+ assert(VD->getType().isConstQualified());
+ V = state->getLValue(VD, LocCtxt);
+ } else {
+ Loc CXXThis =
+ svalBuilder.getCXXThis(MD, LocCtxt->getCurrentStackFrame());
+ SVal CXXThisVal = state->getSVal(CXXThis);
+ V = state->getLValue(FD, CXXThisVal);
+ if (FD->getType()->isReferenceType() &&
+ !VD->getType()->isReferenceType())
+ CaptureByReference = true;
+ }
} else {
V = state->getLValue(VD, LocCtxt);
}
OpenPOWER on IntegriCloud