[pkg-d-commits] [ldc] 11/149: Use SCOPE_EXIT in DtoDefineFunction

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.2.0
in repository ldc.

commit 6c4f421ead36f90529f5f99fe5524582ff9ea31c
Author: Ivan <ivan.butygin at gmail.com>
Date:   Sun Dec 18 23:12:56 2016 +0300

    Use SCOPE_EXIT in DtoDefineFunction
---
 gen/functions.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gen/functions.cpp b/gen/functions.cpp
index e69c1cf..c87b5fd 100644
--- a/gen/functions.cpp
+++ b/gen/functions.cpp
@@ -25,6 +25,7 @@
 #include "gen/dvalue.h"
 #include "gen/funcgenstate.h"
 #include "gen/function-inlining.h"
+#include "gen/helpers.h"
 #include "gen/inlineir.h"
 #include "gen/irstate.h"
 #include "gen/linkage.h"
@@ -909,6 +910,10 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
   IF_LOG Logger::println("Doing function body for: %s", fd->toChars());
   gIR->funcGenStates.emplace_back(new FuncGenState(*irFunc, *gIR));
   auto &funcGen = gIR->funcGen();
+  SCOPE_EXIT {
+    assert(&gIR->funcGen() == &funcGen);
+    gIR->funcGenStates.pop_back();
+  };
 
   const auto f = static_cast<TypeFunction *>(fd->type->toBasetype());
   IrFuncTy &irFty = irFunc->irFty;
@@ -1116,9 +1121,6 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
   }
 
   gIR->scopes.pop_back();
-
-  assert(&gIR->funcGen() == &funcGen);
-  gIR->funcGenStates.pop_back();
 }
 
 ////////////////////////////////////////////////////////////////////////////////

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list