summaryrefslogtreecommitdiffstats
path: root/unittests/AST/ASTTypeTraitsTest.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-01-18 16:23:48 +0000
committerdim <dim@FreeBSD.org>2015-01-18 16:23:48 +0000
commitc86b984ea8ecb3e944dc3de48539f4c1f65851ea (patch)
tree3eb853da77d46cc77c4b017525a422f9ddb1385b /unittests/AST/ASTTypeTraitsTest.cpp
parentc696171ff15f0ee60dea4abfd99a135473c95656 (diff)
downloadFreeBSD-src-c86b984ea8ecb3e944dc3de48539f4c1f65851ea.zip
FreeBSD-src-c86b984ea8ecb3e944dc3de48539f4c1f65851ea.tar.gz
Vendor import of clang RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_360/rc1@226102
Diffstat (limited to 'unittests/AST/ASTTypeTraitsTest.cpp')
-rw-r--r--unittests/AST/ASTTypeTraitsTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/unittests/AST/ASTTypeTraitsTest.cpp b/unittests/AST/ASTTypeTraitsTest.cpp
index 0e73f76..eeb01cc 100644
--- a/unittests/AST/ASTTypeTraitsTest.cpp
+++ b/unittests/AST/ASTTypeTraitsTest.cpp
@@ -26,6 +26,12 @@ template <typename T> static ASTNodeKind DNT() {
return ASTNodeKind::getFromNodeKind<T>();
}
+TEST(ASTNodeKind, IsNone) {
+ EXPECT_TRUE(ASTNodeKind().isNone());
+ EXPECT_FALSE(DNT<Decl>().isNone());
+ EXPECT_FALSE(DNT<VarDecl>().isNone());
+}
+
TEST(ASTNodeKind, Bases) {
EXPECT_TRUE(DNT<Decl>().isBaseOf(DNT<VarDecl>()));
EXPECT_FALSE(DNT<Decl>().isSame(DNT<VarDecl>()));
@@ -60,6 +66,39 @@ TEST(ASTNodeKind, DiffBase) {
EXPECT_FALSE(DNT<Type>().isSame(DNT<QualType>()));
}
+TEST(ASTNodeKind, MostDerivedType) {
+ EXPECT_TRUE(DNT<BinaryOperator>().isSame(
+ ASTNodeKind::getMostDerivedType(DNT<Expr>(), DNT<BinaryOperator>())));
+ EXPECT_TRUE(DNT<BinaryOperator>().isSame(
+ ASTNodeKind::getMostDerivedType(DNT<BinaryOperator>(), DNT<Expr>())));
+ EXPECT_TRUE(DNT<VarDecl>().isSame(
+ ASTNodeKind::getMostDerivedType(DNT<VarDecl>(), DNT<VarDecl>())));
+
+ // Not related. Returns nothing.
+ EXPECT_TRUE(
+ ASTNodeKind::getMostDerivedType(DNT<IfStmt>(), DNT<VarDecl>()).isNone());
+ EXPECT_TRUE(ASTNodeKind::getMostDerivedType(DNT<IfStmt>(),
+ DNT<BinaryOperator>()).isNone());
+}
+
+TEST(ASTNodeKind, MostDerivedCommonAncestor) {
+ EXPECT_TRUE(DNT<Expr>().isSame(ASTNodeKind::getMostDerivedCommonAncestor(
+ DNT<Expr>(), DNT<BinaryOperator>())));
+ EXPECT_TRUE(DNT<Expr>().isSame(ASTNodeKind::getMostDerivedCommonAncestor(
+ DNT<BinaryOperator>(), DNT<Expr>())));
+ EXPECT_TRUE(DNT<VarDecl>().isSame(ASTNodeKind::getMostDerivedCommonAncestor(
+ DNT<VarDecl>(), DNT<VarDecl>())));
+
+ // A little related. Returns the ancestor.
+ EXPECT_TRUE(
+ DNT<NamedDecl>().isSame(ASTNodeKind::getMostDerivedCommonAncestor(
+ DNT<CXXMethodDecl>(), DNT<RecordDecl>())));
+
+ // Not related. Returns nothing.
+ EXPECT_TRUE(ASTNodeKind::getMostDerivedCommonAncestor(
+ DNT<IfStmt>(), DNT<VarDecl>()).isNone());
+}
+
struct Foo {};
TEST(ASTNodeKind, UnknownKind) {
OpenPOWER on IntegriCloud