summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-04-26 18:29:13 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-04-26 18:29:13 +0000
commitea75aad379921d3725c298b051b9909ece9ebcb1 (patch)
tree3b7c3bc9d981afe1929088c64029230b8659a148 /clang/lib/Sema/Sema.cpp
parent9c34526c172b0c4ff5b864d1796b7d88af40c414 (diff)
downloadbcm5719-llvm-ea75aad379921d3725c298b051b9909ece9ebcb1.tar.gz
bcm5719-llvm-ea75aad379921d3725c298b051b9909ece9ebcb1.zip
[Sema] Adjust Sema::getCurBlock()/getCurLambda() to take into account that we may have
switch CurContext due to class template instantiation. Fixes crash of the included test case. rdar://16527205 llvm-svn: 207325
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a0d64ac2afd..8faf29556e1 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1114,14 +1114,30 @@ BlockScopeInfo *Sema::getCurBlock() {
if (FunctionScopes.empty())
return 0;
- return dyn_cast<BlockScopeInfo>(FunctionScopes.back());
+ auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
+ if (CurBSI && CurBSI->TheDecl &&
+ !CurBSI->TheDecl->Encloses(CurContext)) {
+ // We have switched contexts due to template instantiation.
+ assert(!ActiveTemplateInstantiations.empty());
+ return nullptr;
+ }
+
+ return CurBSI;
}
LambdaScopeInfo *Sema::getCurLambda() {
if (FunctionScopes.empty())
return 0;
- return dyn_cast<LambdaScopeInfo>(FunctionScopes.back());
+ auto CurLSI = dyn_cast<LambdaScopeInfo>(FunctionScopes.back());
+ if (CurLSI && CurLSI->Lambda &&
+ !CurLSI->Lambda->Encloses(CurContext)) {
+ // We have switched contexts due to template instantiation.
+ assert(!ActiveTemplateInstantiations.empty());
+ return nullptr;
+ }
+
+ return CurLSI;
}
// We have a generic lambda if we parsed auto parameters, or we have
// an associated template parameter list.
OpenPOWER on IntegriCloud