[PATCH] D130883: [MachineInstrBuilder] Introduce MIMetadata to simplify metadata propagation
    Vitaly Buka via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Sep  2 10:12:44 PDT 2022
    
    
  
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.
LGTM, but please blocking reviews if you are looking for their feedback in particular
================
Comment at: llvm/unittests/CodeGen/MachineInstrTest.cpp:462
+  MCInstrDesc MCID = {0, 0, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr};
+  CheckMI([&] { return BuildMI(*MF, MIMD, MCID); });
+  CheckMI([&] { return BuildMI(*MBB, MBB->end(), MIMD, MCID); });
----------------
I don't insist, but you want to avoid such wrapping of EXPECTs into functions or lambdas.
When test fails it will not provide location of the failed line with CheckMI
If you want to reuse pair of checks, 
EXPECT_EQ(MIB->getDebugLoc(), DL);
EXPECT_EQ(MIB->getPCSections(), PCS);
you can use EXPECT_THAT with custom matches 
EXPECT_THAT(BuildMI(*MBB, MBB->end(), MIMD, MCID)(), MyMatches);
another alternative:
```
 auto BuildDiPc = [&](...) -> pair<> {
    MachineInstrBuilder MIB = BuildMI(...)();
  return {MIB->getDebugLoc(), MIB->getPCSections()}
  };
EXPECT_EQ({DL, PC}. BuildDiPc(*MBB, MBB->end(), MIMD, MCID));
```
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130883/new/
https://reviews.llvm.org/D130883
    
    
More information about the llvm-commits
mailing list