summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2016-03-05 04:04:57 +0000
committerRichard Trieu <rtrieu@google.com>2016-03-05 04:04:57 +0000
commit2334a30e15fcfff5607f88472647762b76432fa1 (patch)
treede5551bd32281243959d811e36999c9f17bdad05 /clang/lib/Sema/SemaExpr.cpp
parentc4572c2a854e19457c45e2e337692cb1cb11bcb9 (diff)
downloadbcm5719-llvm-2334a30e15fcfff5607f88472647762b76432fa1.tar.gz
bcm5719-llvm-2334a30e15fcfff5607f88472647762b76432fa1.zip
Add null check to diagnostic path for lambda captures.
Previously, the failed capture of a variable in nested lambdas may crash when the lambda pointer is null. Only give the note if a location can be retreived from the lambda pointer. llvm-svn: 262765
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index a90fda8bfce..4071acd9063 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13509,8 +13509,9 @@ bool Sema::tryCaptureVariable(
Diag(ExprLoc, diag::err_lambda_impcap) << Var->getDeclName();
Diag(Var->getLocation(), diag::note_previous_decl)
<< Var->getDeclName();
- Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
- diag::note_lambda_decl);
+ if (cast<LambdaScopeInfo>(CSI)->Lambda)
+ Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
+ diag::note_lambda_decl);
// FIXME: If we error out because an outer lambda can not implicitly
// capture a variable that an inner lambda explicitly captures, we
// should have the inner lambda do the explicit capture - because
OpenPOWER on IntegriCloud