Hoist all of the type-specific trait logic for __is_standard_layout into
a Type method isStandardLayoutType, to keep our user API matching the
type trait builtins as closely as possible. Also, implement it in terms
of other Type APIs rather than in terms of other type traits. This
models the implementation on that of isLiteralType and isTrivialType.
There remain some common problems with these traits still, so this is
a bit of a WIP. However, we can now fix all of these traits at the same
time and in a consistent manner.
llvm-svn: 130602
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d975a15..d877520 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2438,22 +2438,7 @@
case UTT_IsSigned:
return T->isSignedIntegerType();
case UTT_IsStandardLayout:
- // Error if T is an incomplete type.
- if (Self.RequireCompleteType(KeyLoc, T, diag::err_incomplete_typeid))
- return false;
-
- // A standard layout type is:
- // - a scalar type
- // - an array of standard layout types
- // - a standard layout class type:
- if (EvaluateUnaryTypeTrait(Self, UTT_IsScalar, T, KeyLoc))
- return true;
- if (EvaluateUnaryTypeTrait(Self, UTT_IsScalar, C.getBaseElementType(T),
- KeyLoc))
- return true;
- if (const RecordType *RT = C.getBaseElementType(T)->getAs<RecordType>())
- return RT->hasStandardLayout();
- return false;
+ return T->isStandardLayoutType();
case UTT_IsUnsigned:
return T->isUnsignedIntegerType();
case UTT_IsVoid: