[Clang] Fix cast to BigIntType in hasUniqueObjectRepresentations

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

Reviewed By: cjdb

Differential Revision: https://reviews.llvm.org/D147904
This commit is contained in:
Roy Jacobson
2023-04-10 07:26:30 +03:00
parent c19bc611bd
commit 016970d079
2 changed files with 7 additions and 1 deletions

View File

@@ -2832,7 +2832,7 @@ bool ASTContext::hasUniqueObjectRepresentations(QualType Ty) const {
// 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;

View File

@@ -2970,6 +2970,12 @@ namespace ErrorType {
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 {