summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-03-14 13:18:30 +0000
committerNikolai Kosjar <nikolai.kosjar@qt.io>2018-06-01 06:53:48 +0000
commit12ff64e073489179762152cef695b795eb2fcb16 (patch)
tree40664347a745d35ebb1c479e62499bf3e90d9461
parent52ffed3d7bb3f69566fb40cc3251aaa6ed8e51c2 (diff)
[backported/clang-7][Sema] Pop function scope when instantiating a func with skipped body
-------------------------------------------------------------------------- * Fixes a completion crash for which the test case was introduced with "[backported/clang-7][Sema] Don't skip function bodies with 'auto' without trailing return type" - so this makes tests pass again. -------------------------------------------------------------------------- Summary: By calling ActOnFinishFunctionBody(). Previously we were only calling ActOnSkippedFunctionBody, which didn't pop the function scope. This causes a crash when running on our internal code. No test-case, though, since I couldn't come up with a small example in reasonable time. The bug was introduced in r321174. Reviewers: bkramer, sammccall, sepavloff, aaron.ballman Reviewed By: sammccall, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: https://reviews.llvm.org/D44439 Change-Id: I45ddee589212ea4178462b1e0f9fd032ded6fdf7 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327504 91177308-0d34-0410-b5e6-96231b3b80d8 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 9163fbc6f7..85d484ecec 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3957,8 +3957,10 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
TemplateArgs))
return;
+ StmtResult Body;
if (PatternDecl->hasSkippedBody()) {
ActOnSkippedFunctionBody(Function);
+ Body = nullptr;
} else {
if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(Function)) {
// If this is a constructor, instantiate the member initializers.
@@ -3974,16 +3976,14 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
}
// Instantiate the function body.
- StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+ Body = SubstStmt(Pattern, TemplateArgs);
if (Body.isInvalid())
Function->setInvalidDecl();
-
- // FIXME: finishing the function body while in an expression evaluation
- // context seems wrong. Investigate more.
- ActOnFinishFunctionBody(Function, Body.get(),
- /*IsInstantiation=*/true);
}
+ // FIXME: finishing the function body while in an expression evaluation
+ // context seems wrong. Investigate more.
+ ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
PerformDependentDiagnostics(PatternDecl, TemplateArgs);