[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 3 00:02:49 PST 2018


rjmccall added inline comments.


================
Comment at: include/clang/AST/Expr.h:875
+  /// is set to true.
+  bool IsUnique = false;
+
----------------
Humor me and pack this in the bitfields in Stmt, please. :)


================
Comment at: include/clang/AST/Expr.h:932
 
+  void setIsUnique() { IsUnique = true; }
+  bool isUnique() const { return IsUnique; }
----------------
Can we assert that there's a source expression?


================
Comment at: lib/Sema/SemaPseudoObject.cpp:432
+  if (capturedRHS->getType()->getAsCXXRecordDecl() && capturedRHS->isRValue())
+    capturedRHS->setIsUnique();
+
----------------
I think you can unconditionally set this here, actually.  You just need to teach the other two exhaustive emitters in IRGen (scalar and complex) to look through unique OVEs.  Plenty of other things in IRGen could benefit from being able to peephole through unique OVEs.

Also, you can set it on the OVE for the base expression if this is a simple assignment or load.


https://reviews.llvm.org/D39562





More information about the cfe-commits mailing list