diff options
Diffstat (limited to 'clang/unittests/AST/DeclPrinterTest.cpp')
-rw-r--r-- | clang/unittests/AST/DeclPrinterTest.cpp | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp index 43cc48da829..758b34cd437 100644 --- a/clang/unittests/AST/DeclPrinterTest.cpp +++ b/clang/unittests/AST/DeclPrinterTest.cpp @@ -120,7 +120,7 @@ bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code, StringRef ExpectedPrinted) { return PrintedDeclMatches(Code, ArrayRef<const char *>(), - nameableDeclaration(hasName(DeclName)).bind("id"), + namedDecl(hasName(DeclName)).bind("id"), ExpectedPrinted); } @@ -139,7 +139,7 @@ bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code, StringRef ExpectedPrinted) { return PrintedDeclMatches(Code, ArrayRef<const char *>("-std=c++11"), - nameableDeclaration(hasName(DeclName)).bind("id"), + namedDecl(hasName(DeclName)).bind("id"), ExpectedPrinted); } @@ -399,7 +399,7 @@ TEST(DeclPrinter, TestFunctionDecl14) { "void A(T t) { }" "template<>" "void A(int N) { }", - function(hasName("A"), isExplicitTemplateSpecialization()).bind("id"), + functionDecl(hasName("A"), isExplicitTemplateSpecialization()).bind("id"), "void A(int N)")); // WRONG; Should be: "template <> void A(int N);")); } @@ -410,7 +410,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl1) { "struct A {" " A();" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A();" } @@ -420,7 +420,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl2) { "struct A {" " A(int a);" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A(int a);" } @@ -430,7 +430,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl3) { "struct A {" " A(const A &a);" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A(const A &a);" } @@ -440,7 +440,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl4) { "struct A {" " A(const A &a, int = 0);" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A(const A &a, int = 0);" } @@ -450,7 +450,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl5) { "struct A {" " A(const A &&a);" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A(const A &&a);" } @@ -460,7 +460,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl6) { "struct A {" " explicit A(int a);" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "explicit A(int a);" } @@ -471,7 +471,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl7) { " constexpr A();" "};", ArrayRef<const char *>("-std=c++11"), - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "constexpr A();" } @@ -482,7 +482,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl8) { " A() = default;" "};", ArrayRef<const char *>("-std=c++11"), - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A() = default;" } @@ -493,7 +493,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl9) { " A() = delete;" "};", ArrayRef<const char *>("-std=c++11"), - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), " = delete")); // WRONG; Should be: "A() = delete;" } @@ -504,7 +504,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl10) { "struct A {" " A(const A &a);" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "")); // WRONG; Should be: "A(const A &a);" } @@ -515,7 +515,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl11) { "struct A : public T... {" " A(T&&... ts) : T(ts)... {}" "};", - constructor(ofClass(hasName("A"))).bind("id"), + constructorDecl(ofClass(hasName("A"))).bind("id"), "A<T...>(T &&ts...) : T(ts)")); // WRONG; Should be: "A(T&&... ts) : T(ts)..." } @@ -526,7 +526,7 @@ TEST(DeclPrinter, TestCXXDestructorDecl1) { "struct A {" " ~A();" "};", - destructor(ofClass(hasName("A"))).bind("id"), + destructorDecl(ofClass(hasName("A"))).bind("id"), "void ~A()")); // WRONG; Should be: "~A();" } @@ -536,7 +536,7 @@ TEST(DeclPrinter, TestCXXDestructorDecl2) { "struct A {" " virtual ~A();" "};", - destructor(ofClass(hasName("A"))).bind("id"), + destructorDecl(ofClass(hasName("A"))).bind("id"), "virtual void ~A()")); // WRONG; Should be: "virtual ~A();" } @@ -546,7 +546,7 @@ TEST(DeclPrinter, TestCXXConversionDecl1) { "struct A {" " operator int();" "};", - method(ofClass(hasName("A"))).bind("id"), + methodDecl(ofClass(hasName("A"))).bind("id"), "int operator int()")); // WRONG; Should be: "operator int();" } @@ -556,7 +556,7 @@ TEST(DeclPrinter, TestCXXConversionDecl2) { "struct A {" " operator bool();" "};", - method(ofClass(hasName("A"))).bind("id"), + methodDecl(ofClass(hasName("A"))).bind("id"), "bool operator _Bool()")); // WRONG; Should be: "operator bool();" } @@ -567,7 +567,7 @@ TEST(DeclPrinter, TestCXXConversionDecl3) { "struct A {" " operator Z();" "};", - method(ofClass(hasName("A"))).bind("id"), + methodDecl(ofClass(hasName("A"))).bind("id"), "Z operator struct Z()")); // WRONG; Should be: "operator Z();" } @@ -579,7 +579,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction1) { " void *operator new(std::size_t);" "};", ArrayRef<const char *>("-std=c++11"), - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), "void *operator new(std::size_t)")); // Should be: with semicolon } @@ -591,7 +591,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction2) { " void *operator new[](std::size_t);" "};", ArrayRef<const char *>("-std=c++11"), - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), "void *operator new[](std::size_t)")); // Should be: with semicolon } @@ -602,7 +602,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction3) { " void operator delete(void *);" "};", ArrayRef<const char *>("-std=c++11"), - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), "void operator delete(void *) noexcept")); // Should be: with semicolon, without noexcept? } @@ -612,7 +612,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction4) { "struct Z {" " void operator delete(void *);" "};", - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), "void operator delete(void *)")); // Should be: with semicolon } @@ -623,7 +623,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction5) { " void operator delete[](void *);" "};", ArrayRef<const char *>("-std=c++11"), - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), "void operator delete[](void *) noexcept")); // Should be: with semicolon, without noexcept? } @@ -651,7 +651,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_Operator1) { ASSERT_TRUE(PrintedDeclMatches( Code, - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), Expected)); } } @@ -675,7 +675,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_Operator2) { ASSERT_TRUE(PrintedDeclMatches( Code, - method(ofClass(hasName("Z"))).bind("id"), + methodDecl(ofClass(hasName("Z"))).bind("id"), Expected)); } } @@ -902,7 +902,7 @@ TEST(DeclPrinter, TestClassTemplateDecl1) { ASSERT_TRUE(PrintedDeclMatches( "template<typename T>" "struct A { T a; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <typename T> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -911,7 +911,7 @@ TEST(DeclPrinter, TestClassTemplateDecl2) { ASSERT_TRUE(PrintedDeclMatches( "template<typename T = int>" "struct A { T a; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <typename T = int> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -920,7 +920,7 @@ TEST(DeclPrinter, TestClassTemplateDecl3) { ASSERT_TRUE(PrintedDeclMatches( "template<class T>" "struct A { T a; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <class T> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -929,7 +929,7 @@ TEST(DeclPrinter, TestClassTemplateDecl4) { ASSERT_TRUE(PrintedDeclMatches( "template<typename T, typename U>" "struct A { T a; U b; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <typename T, typename U> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -938,7 +938,7 @@ TEST(DeclPrinter, TestClassTemplateDecl5) { ASSERT_TRUE(PrintedDeclMatches( "template<int N>" "struct A { int a[N]; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <int N> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -947,7 +947,7 @@ TEST(DeclPrinter, TestClassTemplateDecl6) { ASSERT_TRUE(PrintedDeclMatches( "template<int N = 42>" "struct A { int a[N]; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <int N = 42> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -957,7 +957,7 @@ TEST(DeclPrinter, TestClassTemplateDecl7) { "typedef int MyInt;" "template<MyInt N>" "struct A { int a[N]; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <MyInt N> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -965,7 +965,7 @@ TEST(DeclPrinter, TestClassTemplateDecl7) { TEST(DeclPrinter, TestClassTemplateDecl8) { ASSERT_TRUE(PrintedDeclMatches( "template<template<typename U> class T> struct A { };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <template <typename U> class T> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -974,7 +974,7 @@ TEST(DeclPrinter, TestClassTemplateDecl9) { ASSERT_TRUE(PrintedDeclMatches( "template<typename T> struct Z { };" "template<template<typename U> class T = Z> struct A { };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <template <typename U> class T> struct A {\n}")); // Should be: with semicolon, with { ... } } @@ -983,7 +983,7 @@ TEST(DeclPrinter, TestClassTemplateDecl10) { ASSERT_TRUE(PrintedDeclCXX11Matches( "template<typename... T>" "struct A { int a; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <typename ... T> struct A {\n}")); // Should be: with semicolon, with { ... }, without spaces before '...' } @@ -992,7 +992,7 @@ TEST(DeclPrinter, TestClassTemplateDecl11) { ASSERT_TRUE(PrintedDeclCXX11Matches( "template<typename... T>" "struct A : public T... { int a; };", - classTemplate(hasName("A")).bind("id"), + classTemplateDecl(hasName("A")).bind("id"), "template <typename ... T> struct A : public T... {\n}")); // Should be: with semicolon, with { ... }, without spaces before '...' } @@ -1003,7 +1003,7 @@ TEST(DeclPrinter, TestClassTemplatePartialSpecializationDecl1) { "struct A { T a; U b; };" "template<typename T>" "struct A<T, int> { T a; };", - classTemplateSpecialization().bind("id"), + classTemplateSpecializationDecl().bind("id"), "struct A {\n}")); // WRONG; Should be: "template<typename T> struct A<T, int> { ... }" } @@ -1014,7 +1014,7 @@ TEST(DeclPrinter, TestClassTemplatePartialSpecializationDecl2) { "struct A { T a; };" "template<typename T>" "struct A<T *> { T a; };", - classTemplateSpecialization().bind("id"), + classTemplateSpecializationDecl().bind("id"), "struct A {\n}")); // WRONG; Should be: "template<typename T> struct A<T *> { ... }" } @@ -1025,7 +1025,7 @@ TEST(DeclPrinter, TestClassTemplateSpecializationDecl1) { "struct A { T a; };" "template<>" "struct A<int> { int a; };", - classTemplateSpecialization().bind("id"), + classTemplateSpecializationDecl().bind("id"), "struct A {\n}")); // WRONG; Should be: "template<> struct A<int> { ... }" } @@ -1034,7 +1034,7 @@ TEST(DeclPrinter, TestFunctionTemplateDecl1) { ASSERT_TRUE(PrintedDeclMatches( "template<typename T>" "void A(T &t);", - functionTemplate(hasName("A")).bind("id"), + functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T &t)")); // Should be: with semicolon } @@ -1043,7 +1043,7 @@ TEST(DeclPrinter, TestFunctionTemplateDecl2) { ASSERT_TRUE(PrintedDeclMatches( "template<typename T>" "void A(T &t) { }", - functionTemplate(hasName("A")).bind("id"), + functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T &t)")); // Should be: with semicolon } @@ -1052,7 +1052,7 @@ TEST(DeclPrinter, TestFunctionTemplateDecl3) { ASSERT_TRUE(PrintedDeclCXX11Matches( "template<typename... T>" "void A(T... a);", - functionTemplate(hasName("A")).bind("id"), + functionTemplateDecl(hasName("A")).bind("id"), "template <typename ... T> void A(T a...)")); // WRONG; Should be: "template <typename ... T> void A(T... a)" // (not "T a...") @@ -1062,7 +1062,7 @@ TEST(DeclPrinter, TestFunctionTemplateDecl3) { TEST(DeclPrinter, TestFunctionTemplateDecl4) { ASSERT_TRUE(PrintedDeclMatches( "struct Z { template<typename T> void A(T t); };", - functionTemplate(hasName("A")).bind("id"), + functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T t)")); // Should be: with semicolon } @@ -1070,7 +1070,7 @@ TEST(DeclPrinter, TestFunctionTemplateDecl4) { TEST(DeclPrinter, TestFunctionTemplateDecl5) { ASSERT_TRUE(PrintedDeclMatches( "struct Z { template<typename T> void A(T t) {} };", - functionTemplate(hasName("A")).bind("id"), + functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T t)")); // Should be: with semicolon } @@ -1080,7 +1080,7 @@ TEST(DeclPrinter, TestFunctionTemplateDecl6) { "template<typename T >struct Z {" " template<typename U> void A(U t) {}" "};", - functionTemplate(hasName("A")).bind("id"), + functionTemplateDecl(hasName("A")).bind("id"), "template <typename U> void A(U t)")); // Should be: with semicolon } |