[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-06 Thread A. Jiang via cfe-commits
frederick-vs-ja wrote: IIUC this intrinsic is unrelated to assignment operators. Do you have any plan for `__is_bitwise_assignable`, which should determine whether the assignment operator equivalently copies the value representation, possibly modulo the vptrs? ```C++ struct Cat {}; //

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 3ce87797dbc36ae792b4d82077cd8f27f1eee53e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH] [clang] Implement a bitwise_copyable builtin type trait. This patch

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-05 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 0eec9639530a137da6c4c4b2cc4249a3f9dd9939 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH] [clang] Implement a bitwise_copyable builtin type trait. This patch

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-03 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Also, we need to fix formatting errors and make sure the CI is green. E.g. the newly added test fails (needs an update to capture some notes). https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-03 Thread Ilya Biryukov via cfe-commits
@@ -2749,6 +2749,41 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + auto CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-03 Thread Ilya Biryukov via cfe-commits
@@ -4016,6 +4016,34 @@ Note that the `size` argument must be a compile time constant. Note that this intrinsic cannot yet be called in a ``constexpr`` context. +``__is_bitwise_cloneable`` +-- + +A type trait is used to check whether a type can be

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-03 Thread Ilya Biryukov via cfe-commits
@@ -1120,6 +1120,22 @@ class QualType { /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) bool isTriviallyCopyableType(const ASTContext ) const; + /// Return true if the type is safe to bitwise copy using memcpy/memmove. + /// + /// This is

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-03 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGTM with a few NITs to fix before submitting. https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-06-03 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
hokein wrote: Add @eugenis as a reviewer, could you take a look on the sanitizer bit? https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
hokein wrote: > Could we rewrite the description and documentation to capture what the type > trait is doing now? We have a lot of references to the > `is_trivially_copyable`, which is almost fully irrelevant to the current > implementation. Thanks, I updated the PR description and

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
@@ -4016,6 +4016,34 @@ Note that the `size` argument must be a compile time constant. Note that this intrinsic cannot yet be called in a ``constexpr`` context. +``__is_bitwise_cloneable`` +-- + +A type trait is used to check whether a type can be

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
@@ -2749,6 +2749,17 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + if (const auto *RD =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
@@ -1120,6 +1120,14 @@ class QualType { /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) bool isTriviallyCopyableType(const ASTContext ) const; + /// Return true if the type is safe to bitwise copy by memcpy. + /// + /// This is an extension

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 011d6bbb434bdb46efe92891fe356885f82c4445 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH] ination of 2 commits. [clang] Implement a bitwise_copyable builtin

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-29 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-28 Thread Ilya Biryukov via cfe-commits
@@ -4016,6 +4016,34 @@ Note that the `size` argument must be a compile time constant. Note that this intrinsic cannot yet be called in a ``constexpr`` context. +``__is_bitwise_cloneable`` +-- + +A type trait is used to check whether a type can be

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-28 Thread Ilya Biryukov via cfe-commits
@@ -2749,6 +2749,17 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + if (const auto *RD =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-28 Thread Ilya Biryukov via cfe-commits
@@ -1120,6 +1120,14 @@ class QualType { /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) bool isTriviallyCopyableType(const ASTContext ) const; + /// Return true if the type is safe to bitwise copy by memcpy. + /// + /// This is an extension

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. Could we rewrite the description and documentation to capture what the type trait is doing now? We have a lot of references to the `is_trivially_copyable`, which is almost fully irrelevant to the current implementation.

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-28 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 49747cde60dc8a1f4ed4ddcee020f71c88f35287 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH] [clang] Implement a bitwise_copyable builtin type trait. This patch

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-17 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-17 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
@@ -2718,6 +2718,36 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
@@ -2718,6 +2718,36 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein commented: thanks for the review. https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
@@ -3958,6 +3958,50 @@ Note that the `size` argument must be a compile time constant. Note that this intrinsic cannot yet be called in a ``constexpr`` context. +``__is_bitwise_cloneable`` +- + +A type trait is used to check whether a type can be

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 10d06e728d836f4aaad7dbf1a6b06b57e4092bb1 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH 1/3] [clang] Implement a bitwise_copyable builtin type trait. This

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
@@ -2718,6 +2718,36 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
@@ -2718,6 +2718,36 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCloneableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
@@ -3958,6 +3958,50 @@ Note that the `size` argument must be a compile time constant. Note that this intrinsic cannot yet be called in a ``constexpr`` context. +``__is_bitwise_cloneable`` +- + +A type trait is used to check whether a type can be

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise clonable. +static_assert(__is_bitwise_cloneable(int)); +static_assert(__is_bitwise_cloneable(int*)); +// array +static_assert(__is_bitwise_cloneable(int[10])); + +// non-scalar

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-05-14 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: A few comments from me to move this review forward. The major question I have is about the tests and how reference members should affect the results of that trait. https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-29 Thread Haojian Wu via cfe-commits
hokein wrote: Friendly ping, it is ready for the second round of review. https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -2667,6 +2667,29 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCopyableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -917,6 +917,18 @@ class QualType { /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) bool isTriviallyCopyableType(const ASTContext ) const; + /// Return true if this is a bitwise copyable type. + /// + /// This is an extension in clang:

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) hokein wrote: Done, added one,

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -917,6 +917,18 @@ class QualType { /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) bool isTriviallyCopyableType(const ASTContext ) const; + /// Return true if this is a bitwise copyable type. + /// + /// This is an extension in clang:

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) hokein wrote: switched to

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise copyable. +static_assert(__is_bitwise_copyable(int)); +static_assert(__is_bitwise_copyable(int*)); +// array +static_assert(__is_bitwise_copyable(int[10])); + + +struct

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -2667,6 +2667,29 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCopyableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -5056,6 +5056,8 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema , TypeTrait UTT, case UTT_IsStandardLayout: case UTT_IsPOD: case UTT_IsLiteral: + // Clang extension: hokein wrote: Removed. https://github.com/llvm/llvm-project/pull/86512

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) hokein wrote: OK, renamed to

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
@@ -2667,6 +2667,29 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCopyableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-04-16 Thread Haojian Wu via cfe-commits
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86512 >From 10d4b9e505d5ad7476071153d2d13799f5b5cf1f Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2024 15:10:51 +0100 Subject: [PATCH 1/2] [clang] Implement a bitwise_copyable builtin type trait. This

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -5056,6 +5056,8 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema , TypeTrait UTT, case UTT_IsStandardLayout: case UTT_IsPOD: case UTT_IsLiteral: + // Clang extension: sam-mccall wrote: AFAIK these are all clang extensions (the `__`

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) sam-mccall wrote: naming

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -2667,6 +2667,29 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCopyableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s + +// Scalar types are bitwise copyable. +static_assert(__is_bitwise_copyable(int)); +static_assert(__is_bitwise_copyable(int*)); +// array +static_assert(__is_bitwise_copyable(int[10])); + + +struct

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -2667,6 +2667,29 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCopyableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) sam-mccall wrote: naming

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) sam-mccall wrote: why c++ only?

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -526,6 +526,7 @@ TYPE_TRAIT_2(__is_layout_compatible, IsLayoutCompatible, KEYCXX) #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__is_bitwise_copyable, IsBitwiseCopyable, KEYCXX) sam-mccall wrote: this new

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
@@ -2667,6 +2667,29 @@ bool QualType::isTriviallyCopyableType(const ASTContext ) const { /*IsCopyConstructible=*/false); } +bool QualType::isBitwiseCopyableType(const ASTContext & Context) const { + QualType CanonicalType =

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
https://github.com/sam-mccall edited https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-27 Thread Sam McCall via cfe-commits
https://github.com/sam-mccall commented: I'm in favour of this, but we should have someone less-attached to it sign off on at least the basic design. One question this doesn't explicitly address: after memcpying, does user code need to bless the bits somehow to start the new object's

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-25 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5a744776bb6192dae04360609457c9f49dce43a2 481627e3bacf2e9fa5ca71adece32e4ca5fa94ef --

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-25 Thread via cfe-commits
github-actions[bot] wrote: :white_check_mark: With the latest revision this PR passed the Python code formatter. https://github.com/llvm/llvm-project/pull/86512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-25 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Haojian Wu (hokein) Changes This patch implements a `__is_bitwise_copyable` builtin in clang. The bitwise copyable types act as the trivially copyable types, but they support a wider range of types (e.g. classes with virtual methods) --

[clang] [clang] Implement a bitwise_copyable builtin type trait. (PR #86512)

2024-03-25 Thread Haojian Wu via cfe-commits
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/86512 This patch implements a `__is_bitwise_copyable` builtin in clang. The bitwise copyable types act as the trivially copyable types, but they support a wider range of types (e.g. classes with virtual methods) --