diff options
| author | Akira Hatanaka <ahatanaka@apple.com> | 2018-03-28 00:12:08 +0000 |
|---|---|---|
| committer | Akira Hatanaka <ahatanaka@apple.com> | 2018-03-28 00:12:08 +0000 |
| commit | 5ee26483b020e6be104b4a56d854121a781bf515 (patch) | |
| tree | 89b123aa5f123c73ea2bdba969044b8e937a8cd1 /clang/lib | |
| parent | 2458863e28c07e7463e940134989cd3648d09a1c (diff) | |
| download | bcm5719-llvm-5ee26483b020e6be104b4a56d854121a781bf515.tar.gz bcm5719-llvm-5ee26483b020e6be104b4a56d854121a781bf515.zip | |
[ObjC] Make C++ triviality type traits available to non-trivial C
structs.
r326307 and r327870 made changes that allowed using non-trivial C
structs with fields qualified with __strong or __weak. This commit makes
the following C++ triviality type traits available to non-trivial C
structs:
__has_trivial_assign
__has_trivial_move_assign
__has_trivial_copy
__has_trivial_move_constructor
__has_trivial_constructor
__has_trivial_destructor
rdar://problem/33599681
Differential Revision: https://reviews.llvm.org/D44913
llvm-svn: 328680
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 5870c8bbcba..4ec76bde906 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -4513,6 +4513,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, // does not correctly compute triviality in the presence of multiple special // members of the same kind. Revisit this once the g++ bug is fixed. case UTT_HasTrivialDefaultConstructor: + if (T.isNonTrivialToPrimitiveDefaultInitialize()) + return false; // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: // If __is_pod (type) is true then the trait is true, else if type is // a cv class or union type (or array thereof) with a trivial default @@ -4524,6 +4526,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, !RD->hasNonTrivialDefaultConstructor(); return false; case UTT_HasTrivialMoveConstructor: + if (T.isNonTrivialToPrimitiveDestructiveMove()) + return false; // This trait is implemented by MSVC 2012 and needed to parse the // standard library headers. Specifically this is used as the logic // behind std::is_trivially_move_constructible (20.9.4.3). @@ -4533,6 +4537,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return RD->hasTrivialMoveConstructor() && !RD->hasNonTrivialMoveConstructor(); return false; case UTT_HasTrivialCopy: + if (T.isNonTrivialToPrimitiveCopy()) + return false; // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: // If __is_pod (type) is true or type is a reference type then // the trait is true, else if type is a cv class or union type @@ -4545,6 +4551,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, !RD->hasNonTrivialCopyConstructor(); return false; case UTT_HasTrivialMoveAssign: + if (T.isNonTrivialToPrimitiveDestructiveMove()) + return false; // This trait is implemented by MSVC 2012 and needed to parse the // standard library headers. Specifically it is used as the logic // behind std::is_trivially_move_assignable (20.9.4.3) @@ -4554,6 +4562,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return RD->hasTrivialMoveAssignment() && !RD->hasNonTrivialMoveAssignment(); return false; case UTT_HasTrivialAssign: + if (T.isNonTrivialToPrimitiveCopy()) + return false; // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html: // If type is const qualified or is a reference type then the // trait is false. Otherwise if __is_pod (type) is true then the @@ -4624,6 +4634,8 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return true; case UTT_HasTrivialDestructor: + if (T.isDestructedType() == QualType::DK_nontrivial_c_struct) + return false; // http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html // If __is_pod (type) is true or type is a reference type // then the trait is true, else if type is a cv class or union |

