[PATCH] D145388: [ADT][NFC] Use declval to suppress warning for nullptr use.
Yeting Kuo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 08:00:49 PST 2023
fakepaper56 created this revision.
Herald added a project: All.
fakepaper56 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The patch uses declval instead of nullptr to suppress warning for calling member
function by nullptr. Also the patch replace is_same<*>::value with is_same_v<*>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145388
Files:
llvm/unittests/ADT/RangeAdapterTest.cpp
Index: llvm/unittests/ADT/RangeAdapterTest.cpp
===================================================================
--- llvm/unittests/ADT/RangeAdapterTest.cpp
+++ llvm/unittests/ADT/RangeAdapterTest.cpp
@@ -157,14 +157,12 @@
TYPED_TEST(RangeAdapterRValueTest, RangeType) {
static_assert(
- std::is_same<
- decltype(reverse(*static_cast<TypeParam *>(nullptr)).begin()),
- decltype(static_cast<TypeParam *>(nullptr)->rbegin())>::value,
+ std::is_same_v<decltype(reverse(std::declval<TypeParam>()).begin()),
+ decltype(std::declval<TypeParam>().rbegin())>,
"reverse().begin() should have the same type as rbegin()");
static_assert(
- std::is_same<
- decltype(reverse(*static_cast<const TypeParam *>(nullptr)).begin()),
- decltype(static_cast<const TypeParam *>(nullptr)->rbegin())>::value,
+ std::is_same_v<decltype(reverse(std::declval<const TypeParam>()).begin()),
+ decltype(std::declval<const TypeParam>().rbegin())>,
"reverse().begin() should have the same type as rbegin() [const]");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145388.502656.patch
Type: text/x-patch
Size: 1111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230306/268a2295/attachment.bin>
More information about the llvm-commits
mailing list