This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Add llvm::remove_cvref and llvm::remove_cvref_t
ClosedPublic

Authored by scott.linder on Apr 16 2021, 11:32 AM.

Diff Detail

Event Timeline

scott.linder created this revision.Apr 16 2021, 11:32 AM
scott.linder requested review of this revision.Apr 16 2021, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2021, 11:32 AM

Change the title (this patch isn't adding any std:: things, it's adding llvm:: things that are equivalent to std:: things) and I think drop the "SHIM" macro (but we'll take that up in the precursor patch that introduces that macro)

Testing - I'm not a huge fan of stamping out tests with macros - makes the tests in some ways harder to read/understand what they're testing. Not sure it's better, but gtest does offer a type based test expansion - maybe you could use that?

scott.linder retitled this revision from [ADT] Add std::remove_cvref and std::remove_cvref_t to [ADT] Add llvm::remove_cvref and llvm::remove_cvref_t.
  • Rebase
  • Change title, "std::" -> "llvm::"
  • Use TYPED_TEST instead of a bespoke macro
scott.linder added inline comments.Apr 16 2021, 3:48 PM
llvm/unittests/ADT/STLForwardCompatTest.cpp
48–52

The formatting here gets a bit muddy, I considered adding a typedef of std::pair with a longer name, so that the formatting would refer one entry per line. Does that seem like it would be an improvement?

dblaikie accepted this revision.Apr 18 2021, 11:05 AM
dblaikie added inline comments.
llvm/unittests/ADT/STLForwardCompatTest.cpp
48–52

I wouldn't change the type to force a different formatting - I think clang-format has some comment you can use to disable its formatting? Or you can add an empty comment to force a line break.

using STLForwardCompatRemoveCVRefTestTypes = ::testing::Types<
    // clang-format off
    std::pair<int, int>,
    std::pair<int &, int>,  
    std::pair<const int, int>,
    std::pair<volatile int, int>,
    std::pair<const volatile int &, int>,
    std::pair<int *, int *>,
    std::pair<int *const, int *>,
    std::pair<const int *, const int *>,
    std::pair<int *&, int *>
    // clang-format on
    >;
This revision is now accepted and ready to land.Apr 18 2021, 11:05 AM
scott.linder added inline comments.Apr 30 2021, 11:10 AM
llvm/unittests/ADT/STLForwardCompatTest.cpp
48–52

Ah, I wasn't aware that was possible, thank you!