Izaron added a comment.

Cases that show the difference (they're covered in tests, though do we need an 
AST test as well?):

  X test(bool B) {
    if (B) {
      X y; // before: nrvo, after: nrvo (same)
      return y;
    }
    X x; // before: no nrvo, after: nrvo (better)
    return x;
  }

  X test(bool B) {
    X x; // before: no nrvo, after: no nrvo (same)
    if (B)
      return x;
    X y; // before: no nrvo, after: nrvo (better)
    return y;
  }

  X test(bool A, bool B) {
    {
      {
        X x; // before: nrvo, after: nrvo (same)
        if (A)
          return x;
      }
      X y; // before: no nrvo, after: nrvo (better)
      if (B)
        return y;
    }
    X z;
    retur n z; // before: no nrvo, after: nrvo (better)
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119792

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to