alexfh updated this revision to Diff 53566. alexfh added a comment. - Added a test
http://reviews.llvm.org/D19059 Files: lib/AST/ASTTypeTraits.cpp unittests/AST/ASTTypeTraitsTest.cpp unittests/ASTMatchers/Dynamic/ParserTest.cpp unittests/ASTMatchers/Dynamic/RegistryTest.cpp Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp =================================================================== --- unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -449,26 +449,25 @@ // Overloaded EXPECT_TRUE(hasCompletion( Comps, "hasParent(", - "Matcher<TemplateArgument|NestedNameSpecifierLoc|Decl|...> " - "hasParent(Matcher<TemplateArgument|NestedNameSpecifierLoc|Decl|...>)")); + "Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...> " + "hasParent(Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...>)")); // Variadic. EXPECT_TRUE(hasCompletion(Comps, "whileStmt(", "Matcher<Stmt> whileStmt(Matcher<WhileStmt>...)")); // Polymorphic. EXPECT_TRUE(hasCompletion( Comps, "hasDescendant(", - "Matcher<TemplateArgument|NestedNameSpecifier|NestedNameSpecifierLoc|...>" - " hasDescendant(Matcher<TemplateArgument|NestedNameSpecifier|" - "NestedNameSpecifierLoc|...>)")); + "Matcher<NestedNameSpecifierLoc|QualType|TypeLoc|...> " + "hasDescendant(Matcher<NestedNameSpecifierLoc|QualType|TypeLoc|...>)")); CompVector WhileComps = getCompletions("whileStmt", 0); EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(", "Matcher<WhileStmt> hasBody(Matcher<Stmt>)")); - EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(", - "Matcher<Stmt> " - "hasParent(Matcher<TemplateArgument|" - "NestedNameSpecifierLoc|Decl|...>)")); + EXPECT_TRUE(hasCompletion( + WhileComps, "hasParent(", + "Matcher<Stmt> " + "hasParent(Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...>)")); EXPECT_TRUE( hasCompletion(WhileComps, "allOf(", "Matcher<T> allOf(Matcher<T>...)")); Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp =================================================================== --- unittests/ASTMatchers/Dynamic/ParserTest.cpp +++ unittests/ASTMatchers/Dynamic/ParserTest.cpp @@ -320,7 +320,7 @@ EXPECT_EQ("arent(", Comps[2].TypedText); EXPECT_EQ( "Matcher<Decl> " - "hasParent(Matcher<TemplateArgument|NestedNameSpecifierLoc|Decl|...>)", + "hasParent(Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...>)", Comps[2].MatcherDecl); } Index: unittests/AST/ASTTypeTraitsTest.cpp =================================================================== --- unittests/AST/ASTTypeTraitsTest.cpp +++ unittests/AST/ASTTypeTraitsTest.cpp @@ -107,10 +107,20 @@ } TEST(ASTNodeKind, Name) { - EXPECT_EQ("Decl", DNT<Decl>().asStringRef()); - EXPECT_EQ("CallExpr", DNT<CallExpr>().asStringRef()); - EXPECT_EQ("ConstantArrayType", DNT<ConstantArrayType>().asStringRef()); EXPECT_EQ("<None>", ASTNodeKind().asStringRef()); +#define VERIFY_NAME(Node) EXPECT_EQ(#Node, DNT<Node>().asStringRef()); + VERIFY_NAME(TemplateArgument); + VERIFY_NAME(NestedNameSpecifierLoc); + VERIFY_NAME(QualType); + VERIFY_NAME(TypeLoc); + VERIFY_NAME(CXXCtorInitializer); + VERIFY_NAME(NestedNameSpecifier); + VERIFY_NAME(Decl); + VERIFY_NAME(Stmt); + VERIFY_NAME(Type); + VERIFY_NAME(CallExpr); + VERIFY_NAME(ConstantArrayType); +#undef VERIFY_NAME } TEST(DynTypedNode, DeclSourceRange) { Index: lib/AST/ASTTypeTraits.cpp =================================================================== --- lib/AST/ASTTypeTraits.cpp +++ lib/AST/ASTTypeTraits.cpp @@ -22,12 +22,12 @@ const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = { { NKI_None, "<None>" }, - { NKI_None, "CXXCtorInitializer" }, { NKI_None, "TemplateArgument" }, - { NKI_None, "NestedNameSpecifier" }, { NKI_None, "NestedNameSpecifierLoc" }, { NKI_None, "QualType" }, { NKI_None, "TypeLoc" }, + { NKI_None, "CXXCtorInitializer" }, + { NKI_None, "NestedNameSpecifier" }, { NKI_None, "Decl" }, #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" }, #include "clang/AST/DeclNodes.inc"
Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp =================================================================== --- unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -449,26 +449,25 @@ // Overloaded EXPECT_TRUE(hasCompletion( Comps, "hasParent(", - "Matcher<TemplateArgument|NestedNameSpecifierLoc|Decl|...> " - "hasParent(Matcher<TemplateArgument|NestedNameSpecifierLoc|Decl|...>)")); + "Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...> " + "hasParent(Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...>)")); // Variadic. EXPECT_TRUE(hasCompletion(Comps, "whileStmt(", "Matcher<Stmt> whileStmt(Matcher<WhileStmt>...)")); // Polymorphic. EXPECT_TRUE(hasCompletion( Comps, "hasDescendant(", - "Matcher<TemplateArgument|NestedNameSpecifier|NestedNameSpecifierLoc|...>" - " hasDescendant(Matcher<TemplateArgument|NestedNameSpecifier|" - "NestedNameSpecifierLoc|...>)")); + "Matcher<NestedNameSpecifierLoc|QualType|TypeLoc|...> " + "hasDescendant(Matcher<NestedNameSpecifierLoc|QualType|TypeLoc|...>)")); CompVector WhileComps = getCompletions("whileStmt", 0); EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(", "Matcher<WhileStmt> hasBody(Matcher<Stmt>)")); - EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(", - "Matcher<Stmt> " - "hasParent(Matcher<TemplateArgument|" - "NestedNameSpecifierLoc|Decl|...>)")); + EXPECT_TRUE(hasCompletion( + WhileComps, "hasParent(", + "Matcher<Stmt> " + "hasParent(Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...>)")); EXPECT_TRUE( hasCompletion(WhileComps, "allOf(", "Matcher<T> allOf(Matcher<T>...)")); Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp =================================================================== --- unittests/ASTMatchers/Dynamic/ParserTest.cpp +++ unittests/ASTMatchers/Dynamic/ParserTest.cpp @@ -320,7 +320,7 @@ EXPECT_EQ("arent(", Comps[2].TypedText); EXPECT_EQ( "Matcher<Decl> " - "hasParent(Matcher<TemplateArgument|NestedNameSpecifierLoc|Decl|...>)", + "hasParent(Matcher<NestedNameSpecifierLoc|TypeLoc|Decl|...>)", Comps[2].MatcherDecl); } Index: unittests/AST/ASTTypeTraitsTest.cpp =================================================================== --- unittests/AST/ASTTypeTraitsTest.cpp +++ unittests/AST/ASTTypeTraitsTest.cpp @@ -107,10 +107,20 @@ } TEST(ASTNodeKind, Name) { - EXPECT_EQ("Decl", DNT<Decl>().asStringRef()); - EXPECT_EQ("CallExpr", DNT<CallExpr>().asStringRef()); - EXPECT_EQ("ConstantArrayType", DNT<ConstantArrayType>().asStringRef()); EXPECT_EQ("<None>", ASTNodeKind().asStringRef()); +#define VERIFY_NAME(Node) EXPECT_EQ(#Node, DNT<Node>().asStringRef()); + VERIFY_NAME(TemplateArgument); + VERIFY_NAME(NestedNameSpecifierLoc); + VERIFY_NAME(QualType); + VERIFY_NAME(TypeLoc); + VERIFY_NAME(CXXCtorInitializer); + VERIFY_NAME(NestedNameSpecifier); + VERIFY_NAME(Decl); + VERIFY_NAME(Stmt); + VERIFY_NAME(Type); + VERIFY_NAME(CallExpr); + VERIFY_NAME(ConstantArrayType); +#undef VERIFY_NAME } TEST(DynTypedNode, DeclSourceRange) { Index: lib/AST/ASTTypeTraits.cpp =================================================================== --- lib/AST/ASTTypeTraits.cpp +++ lib/AST/ASTTypeTraits.cpp @@ -22,12 +22,12 @@ const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = { { NKI_None, "<None>" }, - { NKI_None, "CXXCtorInitializer" }, { NKI_None, "TemplateArgument" }, - { NKI_None, "NestedNameSpecifier" }, { NKI_None, "NestedNameSpecifierLoc" }, { NKI_None, "QualType" }, { NKI_None, "TypeLoc" }, + { NKI_None, "CXXCtorInitializer" }, + { NKI_None, "NestedNameSpecifier" }, { NKI_None, "Decl" }, #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" }, #include "clang/AST/DeclNodes.inc"
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits