[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 7 10:53:26 PDT 2018


ahatanak added inline comments.


================
Comment at: lib/CodeGen/CGBlocks.cpp:1643
+    if (Ctx.getBlockVarCopyInits(VD))
+      return true;
+  return false;
----------------
rjmccall wrote:
> ahatanak wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > Can you just ask Sema to check `canThrow` for the expression and pass it down?
> > > Since this changes the existing behavior, I made changes to test/CodeGenCXX/block-byref-cxx-objc.cpp to test it. Previously, IRGen would emit an invoke to call `_Block_object_assign` when the constructor was marked as noexcept.
> > Perhaps I misunderstood your comment, should I have Sema set a flag or something in Expr when it calls a function that can throw?
> Sema has a `canThrow` predicate that it uses when checking things like the `noexcept` expression.  I was thinking that you could pass that down with the copy expression in the AST for the block capture.
> 
> Constructors can have default-argument expressions that can throw even if the constructor itself can't, so it's important to do it that way.
I moved the code in lib/Sema/SemaExceptionSpec.cpp that  is needed to compute the exception specification to a template class in include/AST so that both Sema and IRGen can use it. Also, I added a call to ResolveExceptionSpec in Sema::CheckCompleteVariableDeclaration to resolve the destructor's exception specification and removed the isUnresolvedExceptionSpec check in CodeGenFunction::cxxDestructorCanThrow. Richard pointed out that the constructor's and destructor's exception specifications should have been resolved by the time IRGen is run.


Repository:
  rC Clang

https://reviews.llvm.org/D50152





More information about the cfe-commits mailing list