[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 13 09:56:45 PDT 2018


ilya-biryukov created this revision.
ilya-biryukov added reviewers: bkramer, sammccall, sepavloff.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D44439

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3939,6 +3939,9 @@
 
     if (PatternDecl->hasSkippedBody()) {
       ActOnSkippedFunctionBody(Function);
+      // FIXME: finishing the function body while in an expression evaluation
+      // context seems wrong. Investigate more.
+      ActOnFinishFunctionBody(Function, nullptr, /*IsInstantiation=*/true);
     } else {
       if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(Function)) {
         // If this is a constructor, instantiate the member initializers.
@@ -3961,8 +3964,7 @@
 
       // FIXME: finishing the function body while in an expression evaluation
       // context seems wrong. Investigate more.
-      ActOnFinishFunctionBody(Function, Body.get(),
-                              /*IsInstantiation=*/true);
+      ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
     }
 
     PerformDependentDiagnostics(PatternDecl, TemplateArgs);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44439.138215.patch
Type: text/x-patch
Size: 1102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180313/01ed0a42/attachment.bin>


More information about the cfe-commits mailing list