[llvm] 260bae5 - [ADT][NFC] Use declval to suppress warning for nullptr use.
Yeting Kuo via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 16:12:46 PST 2023
Author: Yeting Kuo
Date: 2023-03-07T08:12:40+08:00
New Revision: 260bae5ba27cde110590c28941966a6e02df5325
URL: https://github.com/llvm/llvm-project/commit/260bae5ba27cde110590c28941966a6e02df5325
DIFF: https://github.com/llvm/llvm-project/commit/260bae5ba27cde110590c28941966a6e02df5325.diff
LOG: [ADT][NFC] Use declval to suppress warning for nullptr use.
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<*>.
Reviewed By: dexonsmith, kuhar
Differential Revision: https://reviews.llvm.org/D145388
Added:
Modified:
llvm/unittests/ADT/RangeAdapterTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/ADT/RangeAdapterTest.cpp b/llvm/unittests/ADT/RangeAdapterTest.cpp
index 3c68103e17452..5c27225360248 100644
--- a/llvm/unittests/ADT/RangeAdapterTest.cpp
+++ b/llvm/unittests/ADT/RangeAdapterTest.cpp
@@ -157,14 +157,12 @@ TYPED_TEST(RangeAdapterRValueTest, HasRbegin) {
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]");
}
More information about the llvm-commits
mailing list