summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-04-23 10:47:28 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-04-23 10:47:28 +0000
commita3e1f9a02c6aeecb97009d5786713163f46cedce (patch)
tree1e2e67c6ec8f271b75b5600a36817a2ac8987eee /clang/include
parent7980348fcf3a0f1da7352728493f00ff78852afb (diff)
downloadbcm5719-llvm-a3e1f9a02c6aeecb97009d5786713163f46cedce.tar.gz
bcm5719-llvm-a3e1f9a02c6aeecb97009d5786713163f46cedce.zip
Implement basic __is_trivial type-trait support, enough to close PR9472.
This introduces a few APIs on the AST to bundle up the standard-based logic so that programmatic clients have access to exactly the same behavior. There is only one serious FIXME here: checking for non-trivial move constructors and move assignment operators. Those bits need to be added to the declaration and accessors provided. This implementation should be enough for the uses of __is_trivial in libstdc++ 4.6's C++98 library implementation. Ideas for more thorough test cases or any edge cases missing would be appreciated. =D llvm-svn: 130057
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/AST/DeclCXX.h4
-rw-r--r--clang/include/clang/AST/Type.h4
-rw-r--r--clang/include/clang/Basic/TokenKinds.def1
-rw-r--r--clang/include/clang/Basic/TypeTraits.h1
4 files changed, 10 insertions, 0 deletions
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 76510ca3148..dfd3bd6e262 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -741,6 +741,10 @@ public:
// (C++ [class.dtor]p3)
bool hasTrivialDestructor() const { return data().HasTrivialDestructor; }
+ // isTriviallyCopyable - Whether this class is considered trivially copyable
+ // (C++0x [class]p5).
+ bool isTriviallyCopyable() const;
+
/// \brief If this record is an instantiation of a member class,
/// retrieves the member class from which it was instantiated.
///
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 5d1588726b9..9ed30563598 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1171,6 +1171,10 @@ public:
/// (C++0x [basic.types]p10)
bool isLiteralType() const;
+ /// isTrivialType - Return true if this is a literal type
+ /// (C++0x [basic.types]p9)
+ bool isTrivialType() const;
+
/// Helper methods to distinguish type categories. All type predicates
/// operate on the canonical type, ignoring typedefs and qualifiers.
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 6e0dd056a1a..96f5aa9cada 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -340,6 +340,7 @@ KEYWORD(__is_enum , KEYCXX)
KEYWORD(__is_literal , KEYCXX)
KEYWORD(__is_pod , KEYCXX)
KEYWORD(__is_polymorphic , KEYCXX)
+KEYWORD(__is_trivial , KEYCXX)
KEYWORD(__is_union , KEYCXX)
// Apple Extension.
diff --git a/clang/include/clang/Basic/TypeTraits.h b/clang/include/clang/Basic/TypeTraits.h
index 791ed34bc3f..5883efe3bb0 100644
--- a/clang/include/clang/Basic/TypeTraits.h
+++ b/clang/include/clang/Basic/TypeTraits.h
@@ -33,6 +33,7 @@ namespace clang {
UTT_IsLiteral,
UTT_IsPOD,
UTT_IsPolymorphic,
+ UTT_IsTrivial,
UTT_IsUnion
};
OpenPOWER on IntegriCloud