royjacobson created this revision. royjacobson added reviewers: shafik, cjdb. Herald added a subscriber: kristof.beyls. Herald added a project: All. royjacobson requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
A bad QualType cast caused us not to detect _BigInt types if they were wrapped inside sugar types like SubstTemplateTypeParm. Fix https://github.com/llvm/llvm-project/issues/62019 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147904 Files: clang/lib/AST/ASTContext.cpp clang/test/SemaCXX/type-traits.cpp Index: clang/test/SemaCXX/type-traits.cpp =================================================================== --- clang/test/SemaCXX/type-traits.cpp +++ clang/test/SemaCXX/type-traits.cpp @@ -2970,6 +2970,12 @@ bool b = __has_unique_object_representations(T); }; +static_assert(!has_unique_object_representations<_BitInt(7)>::value, "BitInt:"); +static_assert(has_unique_object_representations<_BitInt(8)>::value, "BitInt:"); +static_assert(!has_unique_object_representations<_BitInt(127)>::value, "BitInt:"); +static_assert(has_unique_object_representations<_BitInt(128)>::value, "BitInt:"); + + namespace PR46209 { // Foo has both a trivial assignment operator and a non-trivial one. struct Foo { Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -2832,7 +2832,7 @@ // All integrals and enums are unique. if (Ty->isIntegralOrEnumerationType()) { // Except _BitInt types that have padding bits. - if (const auto *BIT = dyn_cast<BitIntType>(Ty)) + if (const auto *BIT = Ty->getAs<BitIntType>()) return getTypeSize(BIT) == BIT->getNumBits(); return true;
Index: clang/test/SemaCXX/type-traits.cpp =================================================================== --- clang/test/SemaCXX/type-traits.cpp +++ clang/test/SemaCXX/type-traits.cpp @@ -2970,6 +2970,12 @@ bool b = __has_unique_object_representations(T); }; +static_assert(!has_unique_object_representations<_BitInt(7)>::value, "BitInt:"); +static_assert(has_unique_object_representations<_BitInt(8)>::value, "BitInt:"); +static_assert(!has_unique_object_representations<_BitInt(127)>::value, "BitInt:"); +static_assert(has_unique_object_representations<_BitInt(128)>::value, "BitInt:"); + + namespace PR46209 { // Foo has both a trivial assignment operator and a non-trivial one. struct Foo { Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -2832,7 +2832,7 @@ // All integrals and enums are unique. if (Ty->isIntegralOrEnumerationType()) { // Except _BitInt types that have padding bits. - if (const auto *BIT = dyn_cast<BitIntType>(Ty)) + if (const auto *BIT = Ty->getAs<BitIntType>()) return getTypeSize(BIT) == BIT->getNumBits(); return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits