[PATCH] D53674: [CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 25 12:35:34 PDT 2018


vsapsai marked 2 inline comments as done.
vsapsai added inline comments.


================
Comment at: clang/lib/CodeGen/CGObjC.cpp:2527
+      return TryEmitResult(CGF.EmitScalarExpr(e),
+                           !shouldRetainObjCLifetime(type.getObjCLifetime()));
+  }
----------------
vsapsai wrote:
> rjmccall wrote:
> > Can we test constant-evaluability directly instead of only applying this when the declaration isn't otherwise used?
> We can use `IsVariableAConstantExpression` but it requires removing const from `Decl`.
> 
> Another way to test constant-evaluability is `tryEmitAsConstant`. It still requires removing const qualifier but overall it is a good approach. It captures the intention well and implementation-wise it is what `CGF.EmitScalarExpr` is doing anyway. I'll try it and will show how it looks like.
If we go with `tryEmitAsConstant`, there is a separate review D53725 to use `EmitConstant` in more places.


https://reviews.llvm.org/D53674





More information about the cfe-commits mailing list