summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorAleksei Sidorin <a.sidorin@samsung.com>2017-11-26 17:04:06 +0000
committerAleksei Sidorin <a.sidorin@samsung.com>2017-11-26 17:04:06 +0000
commitdace80474949dad7ff70ab721adadf47966fdeb7 (patch)
treeebdc941cd01e1680276bd362640e5810bbe81535 /unittests
parent30a844e21fc426ee4b4de22a142babe3705a63fe (diff)
[ASTImporter] Support TypeTraitExpr
Patch by Takafumi Kubota! Differential Revision: https://reviews.llvm.org/D39722 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/AST/ASTImporterTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/unittests/AST/ASTImporterTest.cpp b/unittests/AST/ASTImporterTest.cpp
index 7b41c5d579..2a8f70c214 100644
--- a/unittests/AST/ASTImporterTest.cpp
+++ b/unittests/AST/ASTImporterTest.cpp
@@ -525,6 +525,47 @@ TEST(ImportType, ImportPackExpansion) {
declRefExpr()))))))))));
}
+/// \brief Matches __builtin_types_compatible_p:
+/// GNU extension to check equivalent types
+/// Given
+/// \code
+/// __builtin_types_compatible_p(int, int)
+/// \endcode
+// will generate TypeTraitExpr <...> 'int'
+const internal::VariadicDynCastAllOfMatcher<Stmt, TypeTraitExpr> typeTraitExpr;
+
+TEST(ImportExpr, ImportTypeTraitExpr) {
+ MatchVerifier<Decl> Verifier;
+ EXPECT_TRUE(testImport("void declToImport() { "
+ " __builtin_types_compatible_p(int, int);"
+ "}",
+ Lang_C, "", Lang_C, Verifier,
+ functionDecl(
+ hasBody(
+ compoundStmt(
+ has(
+ typeTraitExpr(hasType(asString("int")))))))));
+}
+
+TEST(ImportExpr, ImportTypeTraitExprValDep) {
+ MatchVerifier<Decl> Verifier;
+ EXPECT_TRUE(testImport("template<typename T> struct declToImport {"
+ " void m() { __is_pod(T); }"
+ "};"
+ "void f() { declToImport<int>().m(); }",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ classTemplateDecl(
+ has(
+ cxxRecordDecl(
+ has(
+ functionDecl(
+ hasBody(
+ compoundStmt(
+ has(
+ typeTraitExpr(
+ hasType(booleanType())
+ )))))))))));
+}
} // end namespace ast_matchers
} // end namespace clang