[PATCH] D27751: [LLVM] Use after move bug fixes

Lang Hames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 15:09:28 PDT 2023


lhames added inline comments.


================
Comment at: lib/Object/Error.cpp:94
     return Err2;
-  return Err;
+  return Err; // Use after move, not sure how to fix it.
 }
----------------
Prazek wrote:
> mehdi_amini wrote:
> > @lhames : can you look at this?
> ping
We can just return `Error::success()` instead of `Err`.

The reasoning is:
1. if `Err` is a success value then `handleErrors` will return `Error::success()` and we'll fall through to the implicit else case (currently `return Err;`). Returning `Error::success()` from the implicit else case maintains the expected behavior.
2. if `Err` is an `ECError` failure value with error code `object_error::invalid_file_type` then we will return `Error::success` from handleErrors, and again fall through to the implicit else case. Returning `Error::success()` from the implicit else maintains the expected behavior.
3. if `Err` is any other kind of failure value then we will return it from `handleErrors`, and then from the return in the then case, and the implicit else case does not affect the outcome.


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

https://reviews.llvm.org/D27751



More information about the llvm-commits mailing list