[PATCH] D139428: Handle char{8,16,32} and wchar_t in ASTContext::getIntegerRank()
Hans Wennborg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 7 07:16:56 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb3ea52a5ae5: Handle char{8,16,32} and wchar_t in ASTContext::getIntegerRank() (authored by hans).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139428/new/
https://reviews.llvm.org/D139428
Files:
clang/lib/AST/ASTContext.cpp
clang/test/SemaCXX/vector.cpp
Index: clang/test/SemaCXX/vector.cpp
===================================================================
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++20 %s
// RUN: %clang_cc1 -flax-vector-conversions=integer -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT
// RUN: %clang_cc1 -flax-vector-conversions=none -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT -DNO_LAX_INT
@@ -530,3 +531,17 @@
S<int, 16> s;
}
} // namespace PR48540
+
+#if __cplusplus >= 202002L // C++20 or later
+// Don't crash due to missing integer ranks.
+char8_t v1 __attribute__((vector_size(16)));
+char16_t v2 __attribute__((vector_size(16)));
+char32_t v3 __attribute__((vector_size(16)));
+wchar_t v4 __attribute__((vector_size(16)));
+void triggerIntegerRankCheck() {
+ auto b1 = (v1 >= 0x12);
+ auto b2 = (v2 >= 0x12);
+ auto b3 = (v3 >= 0x12);
+ auto b4 = (v4 >= 0x12);
+}
+#endif
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -7102,6 +7102,21 @@
case BuiltinType::Int128:
case BuiltinType::UInt128:
return 7 + (getIntWidth(Int128Ty) << 3);
+
+ // "The ranks of char8_t, char16_t, char32_t, and wchar_t equal the ranks of
+ // their underlying types" [c++20 conv.rank]
+ case BuiltinType::Char8:
+ return getIntegerRank(UnsignedCharTy.getTypePtr());
+ case BuiltinType::Char16:
+ return getIntegerRank(
+ getFromTargetType(Target->getChar16Type()).getTypePtr());
+ case BuiltinType::Char32:
+ return getIntegerRank(
+ getFromTargetType(Target->getChar32Type()).getTypePtr());
+ case BuiltinType::WChar_S:
+ case BuiltinType::WChar_U:
+ return getIntegerRank(
+ getFromTargetType(Target->getWCharType()).getTypePtr());
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139428.480903.patch
Type: text/x-patch
Size: 2319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221207/46d66c3a/attachment.bin>
More information about the cfe-commits
mailing list