[PATCH] D147904: [Clang] Fix cast to BigIntType in hasUniqueObjectRepresentations
Roy Jacobson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 9 21:29:04 PDT 2023
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147904.512065.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230410/cf1e9082/attachment.bin>
More information about the cfe-commits
mailing list