Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/AST/DeclPrinterTest.cpp
Show First 20 Lines • Show All 725 Lines • ▼ Show 20 Lines | TEST(DeclPrinter, TestCXXMethodDecl_Operator1) { | ||||
const char *OperatorNames[] = { | const char *OperatorNames[] = { | ||||
"+", "-", "*", "/", "%", "^", "&", "|", | "+", "-", "*", "/", "%", "^", "&", "|", | ||||
"=", "<", ">", "+=", "-=", "*=", "/=", "%=", | "=", "<", ">", "+=", "-=", "*=", "/=", "%=", | ||||
"^=", "&=", "|=", "<<", ">>", ">>=", "<<=", "==", "!=", | "^=", "&=", "|=", "<<", ">>", ">>=", "<<=", "==", "!=", | ||||
"<=", ">=", "&&", "||", ",", "->*", | "<=", ">=", "&&", "||", ",", "->*", | ||||
"()", "[]" | "()", "[]" | ||||
}; | }; | ||||
for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) { | for (unsigned i = 0, e = std::size(OperatorNames); i != e; ++i) { | ||||
SmallString<128> Code; | SmallString<128> Code; | ||||
Code.append("struct Z { void operator"); | Code.append("struct Z { void operator"); | ||||
Code.append(OperatorNames[i]); | Code.append(OperatorNames[i]); | ||||
Code.append("(Z z); };"); | Code.append("(Z z); };"); | ||||
SmallString<128> Expected; | SmallString<128> Expected; | ||||
Expected.append("void operator"); | Expected.append("void operator"); | ||||
Expected.append(OperatorNames[i]); | Expected.append(OperatorNames[i]); | ||||
Expected.append("(Z z)"); | Expected.append("(Z z)"); | ||||
ASSERT_TRUE(PrintedDeclCXX98Matches( | ASSERT_TRUE(PrintedDeclCXX98Matches( | ||||
Code, | Code, | ||||
cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), | cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), | ||||
Expected)); | Expected)); | ||||
} | } | ||||
} | } | ||||
TEST(DeclPrinter, TestCXXMethodDecl_Operator2) { | TEST(DeclPrinter, TestCXXMethodDecl_Operator2) { | ||||
const char *OperatorNames[] = { | const char *OperatorNames[] = { | ||||
"~", "!", "++", "--", "->" | "~", "!", "++", "--", "->" | ||||
}; | }; | ||||
for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) { | for (unsigned i = 0, e = std::size(OperatorNames); i != e; ++i) { | ||||
SmallString<128> Code; | SmallString<128> Code; | ||||
Code.append("struct Z { void operator"); | Code.append("struct Z { void operator"); | ||||
Code.append(OperatorNames[i]); | Code.append(OperatorNames[i]); | ||||
Code.append("(); };"); | Code.append("(); };"); | ||||
SmallString<128> Expected; | SmallString<128> Expected; | ||||
Expected.append("void operator"); | Expected.append("void operator"); | ||||
Expected.append(OperatorNames[i]); | Expected.append(OperatorNames[i]); | ||||
▲ Show 20 Lines • Show All 667 Lines • Show Last 20 Lines |