aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorVlad Serebrennikov <serebrennikov.vladislav@gmail.com>2024-02-20 16:54:51 +0400
committerGitHub <noreply@github.com>2024-02-20 16:54:51 +0400
commitd5922cf72cc18a7ac9f7afd1941ee2f7773d8469 (patch)
treeb045bfe7e6596fd4ba5428ec30e193407d5f6756 /clang/lib/Sema/SemaChecking.cpp
parentf1efc64b86d6fa60182c4d4a9ad7c8a051c21dbc (diff)
downloadllvm-d5922cf72cc18a7ac9f7afd1941ee2f7773d8469.zip
llvm-d5922cf72cc18a7ac9f7afd1941ee2f7773d8469.tar.gz
llvm-d5922cf72cc18a7ac9f7afd1941ee2f7773d8469.tar.bz2
[clang] Implement `__is_layout_compatible` (#81506)
This patch implements `__is_layout_compatible` intrinsic, which supports `std::is_layout_compatible` type trait introduced in C++20 ([P0466R5](https://wg21.link/p0466r5) "Layout-compatibility and Pointer-interconvertibility Traits"). Name matches GCC and MSVC intrinsic. Basically, this patch exposes our existing machinery for checking for layout compatibility and figuring out common initial sequences. Said machinery is a bit outdated, as it doesn't implement [CWG1719](https://cplusplus.github.io/CWG/issues/1719.html) "Layout compatibility and cv-qualification revisited" and [CWG2759](https://cplusplus.github.io/CWG/issues/2759.html) "`[[no_unique_address]` and common initial sequence". Those defect reports are considered out of scope of of this PR, but will be implemented in subsequent PRs. Partially addresses #48204
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8e76338..d951c0f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -19155,6 +19155,10 @@ static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) {
return false;
}
+bool Sema::IsLayoutCompatible(QualType T1, QualType T2) const {
+ return isLayoutCompatible(getASTContext(), T1, T2);
+}
+
//===--- CHECK: pointer_with_type_tag attribute: datatypes should match ----//
/// Given a type tag expression find the type tag itself.