diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-12-03 00:13:20 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-12-03 00:13:20 +0000 |
commit | ccf43505dbc47da041c06125f90b3bd3ac7eac97 (patch) | |
tree | d78ffe0ce06c96e858d2cdd81f49618526860384 /lib/AST/Type.cpp | |
parent | 61d89b61d4f22a226139c36a88b4fe2f7a2e368f (diff) |
Introduce the notion of literal types, as specified in C++0x.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 5a2434da3c..70387c73a7 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -639,6 +639,40 @@ bool Type::isPODType() const { } } +bool Type::isLiteralType() const { + if (isIncompleteType()) + return false; + + // C++0x [basic.types]p10: + // A type is a literal type if it is: + switch (CanonicalType->getTypeClass()) { + // We're whitelisting + default: return false; + + // -- a scalar type + case Builtin: + case Complex: + case Pointer: + case MemberPointer: + case Vector: + case ExtVector: + case ObjCObjectPointer: + case Enum: + return true; + + // -- a class type with ... + case Record: + // FIXME: Do the tests + return false; + + // -- an array of literal type + // Extension: variable arrays cannot be literal types, since they're + // runtime-sized. + case ConstantArray: + return cast<ArrayType>(CanonicalType)->getElementType()->isLiteralType(); + } +} + bool Type::isPromotableIntegerType() const { if (const BuiltinType *BT = getAs<BuiltinType>()) switch (BT->getKind()) { |