[PATCH] D77502: [clang][CodeGen] Handle throw expression in conditional operator constant folding

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 5 22:57:00 PDT 2020


rsmith added inline comments.


================
Comment at: clang/lib/CodeGen/CGExpr.cpp:4337
+        EmitCXXThrowExpr(ThrowExpr);
+        return EmitLValue(dead);
+      }
----------------
The IR we emit for the dead operand is unreachable; it's a bit wasteful to generate it here and (hopefully!) leave it to the optimizer to remove it again. Perhaps we could produce an `undef` lvalue instead? See `CodeGenFunction::EmitUnsupportedLValue` for an example of how to build such a value.


================
Comment at: clang/test/CodeGenCXX/throw-expressions.cpp:84-87
+  void conditional_throw() {
+    int a, b;
+    (true ? throw 0 : a) = 0;
+  }
----------------
Please add some `CHECK`s in here to make sure we actually emit a call to `__cxa_throw`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77502/new/

https://reviews.llvm.org/D77502





More information about the cfe-commits mailing list