summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-12-03 00:13:20 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-12-03 00:13:20 +0000
commit79eba1ca3bf8284de46c6e3d14671a1cb1deaed2 (patch)
tree20e87e4afc19ba9f67b5e82d9a994e967c33b60d /clang/lib/AST
parent37e4c41283aae2160ea6f7d33030d19a07af7d7e (diff)
downloadbcm5719-llvm-79eba1ca3bf8284de46c6e3d14671a1cb1deaed2.tar.gz
bcm5719-llvm-79eba1ca3bf8284de46c6e3d14671a1cb1deaed2.zip
Introduce the notion of literal types, as specified in C++0x.
llvm-svn: 90361
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ExprCXX.cpp1
-rw-r--r--clang/lib/AST/Type.cpp34
2 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 7a6fbdca8bc..a9f96adae13 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -199,6 +199,7 @@ bool UnaryTypeTraitExpr::EvaluateTrait(ASTContext& C) const {
switch(UTT) {
default: assert(false && "Unknown type trait or not implemented");
case UTT_IsPOD: return QueriedType->isPODType();
+ case UTT_IsLiteral: return QueriedType->isLiteralType();
case UTT_IsClass: // Fallthrough
case UTT_IsUnion:
if (const RecordType *Record = QueriedType->getAs<RecordType>()) {
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 5a2434da3c3..70387c73a7f 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/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()) {
OpenPOWER on IntegriCloud