[llvm] 4f5648a - [PointerUnionTest] Fix an incorrectly written test
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 11:26:59 PDT 2022
Author: Philip Reames
Date: 2022-06-07T11:26:28-07:00
New Revision: 4f5648adc588e23e2bf52e189030c792a6f1586a
URL: https://github.com/llvm/llvm-project/commit/4f5648adc588e23e2bf52e189030c792a6f1586a
DIFF: https://github.com/llvm/llvm-project/commit/4f5648adc588e23e2bf52e189030c792a6f1586a.diff
LOG: [PointerUnionTest] Fix an incorrectly written test
The test being change appears to have been intended to exercise PointerUnion, but what it actually did was cast<> a double to a double*. This only worked because cast<> was missing the required assertion. Adding the assertion reveals a template error where isa<const double*>(double) fails to compile.
Added:
Modified:
llvm/unittests/ADT/PointerUnionTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/ADT/PointerUnionTest.cpp b/llvm/unittests/ADT/PointerUnionTest.cpp
index 5b635e1c53c64..e12a3ec4e4d4f 100644
--- a/llvm/unittests/ADT/PointerUnionTest.cpp
+++ b/llvm/unittests/ADT/PointerUnionTest.cpp
@@ -283,7 +283,8 @@ TEST_F(PointerUnionTest, NewCastInfra) {
"type mismatch for cast with PointerUnion");
PointerUnion<int *, const double *> constd2(&d);
- auto *result2 = cast<const double *>(d);
+ auto *result2 = cast<const double *>(constd2);
+ EXPECT_EQ(result2, &d);
static_assert(std::is_same<const double *, decltype(result2)>::value,
"type mismatch for cast with PointerUnion");
}
More information about the llvm-commits
mailing list