[llvm] 475927d - [AsmParserTest] Avoid pointer element type accesses (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 05:32:28 PST 2022
Author: Nikita Popov
Date: 2022-01-25T14:31:51+01:00
New Revision: 475927d04606433f4ad70b9e41bbe731994ba9b6
URL: https://github.com/llvm/llvm-project/commit/475927d04606433f4ad70b9e41bbe731994ba9b6
DIFF: https://github.com/llvm/llvm-project/commit/475927d04606433f4ad70b9e41bbe731994ba9b6.diff
LOG: [AsmParserTest] Avoid pointer element type accesses (NFC)
Use isOpaqueOrPointeeTypeEquals() instead.
Added:
Modified:
llvm/unittests/AsmParser/AsmParserTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/AsmParser/AsmParserTest.cpp b/llvm/unittests/AsmParser/AsmParserTest.cpp
index 7639ff50571e6..9d2333b49bc31 100644
--- a/llvm/unittests/AsmParser/AsmParserTest.cpp
+++ b/llvm/unittests/AsmParser/AsmParserTest.cpp
@@ -252,9 +252,7 @@ TEST(AsmParserTest, TypeWithSlotMappingParsing) {
ASSERT_TRUE(Ty->isPointerTy());
PointerType *PT = cast<PointerType>(Ty);
- Ty = PT->getPointerElementType();
- ASSERT_TRUE(Ty->isIntegerTy());
- ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
+ ASSERT_TRUE(PT->isOpaqueOrPointeeTypeMatches(Type::getIntNTy(Ctx, 32)));
// Two indirections.
Ty = parseType("i32**", Error, M, &Mapping);
@@ -262,13 +260,8 @@ TEST(AsmParserTest, TypeWithSlotMappingParsing) {
ASSERT_TRUE(Ty->isPointerTy());
PT = cast<PointerType>(Ty);
- Ty = PT->getPointerElementType();
- ASSERT_TRUE(Ty->isPointerTy());
-
- PT = cast<PointerType>(Ty);
- Ty = PT->getPointerElementType();
- ASSERT_TRUE(Ty->isIntegerTy());
- ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
+ Type *ExpectedElemTy = PointerType::getUnqual(Type::getIntNTy(Ctx, 32));
+ ASSERT_TRUE(PT->isOpaqueOrPointeeTypeMatches(ExpectedElemTy));
// Check that we reject types with garbage.
Ty = parseType("i32 garbage", Error, M, &Mapping);
@@ -386,9 +379,7 @@ TEST(AsmParserTest, TypeAtBeginningWithSlotMappingParsing) {
ASSERT_TRUE(Read == 4);
PointerType *PT = cast<PointerType>(Ty);
- Ty = PT->getPointerElementType();
- ASSERT_TRUE(Ty->isIntegerTy());
- ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
+ ASSERT_TRUE(PT->isOpaqueOrPointeeTypeMatches(Type::getIntNTy(Ctx, 32)));
// Two indirections.
Ty = parseTypeAtBeginning("i32**", Read, Error, M, &Mapping);
@@ -397,13 +388,8 @@ TEST(AsmParserTest, TypeAtBeginningWithSlotMappingParsing) {
ASSERT_TRUE(Read == 5);
PT = cast<PointerType>(Ty);
- Ty = PT->getPointerElementType();
- ASSERT_TRUE(Ty->isPointerTy());
-
- PT = cast<PointerType>(Ty);
- Ty = PT->getPointerElementType();
- ASSERT_TRUE(Ty->isIntegerTy());
- ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
+ Type *ExpectedElemTy = PointerType::getUnqual(Type::getIntNTy(Ctx, 32));
+ ASSERT_TRUE(PT->isOpaqueOrPointeeTypeMatches(ExpectedElemTy));
// Check that we reject types with garbage.
Ty = parseTypeAtBeginning("i32 garbage", Read, Error, M, &Mapping);
More information about the llvm-commits
mailing list