Index: unittests/AST/SourceLocationTest.cpp =================================================================== --- unittests/AST/SourceLocationTest.cpp +++ unittests/AST/SourceLocationTest.cpp @@ -263,6 +263,84 @@ unresolvedUsingValueDecl())); } +TEST(FriendDecl, FriendFunctionLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(2, 13); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend void f();\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendFunctionRange) { + RangeVerifier Verifier; + Verifier.expectRange(2, 1, 2, 15); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend void f();\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendClassLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(2, 8); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend class B;\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendClassRange) { + RangeVerifier Verifier; + Verifier.expectRange(2, 1, 2, 14); + EXPECT_TRUE(Verifier.match("struct A {\n" + "friend class B;\n" + "};\n", + friendDecl())); +} + +TEST(FriendDecl, FriendTemplateParameterLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(3, 8); + EXPECT_TRUE(Verifier.match("template \n" + "struct A {\n" + "friend T;\n" + "};\n", + friendDecl(), Lang_CXX11)); +} + +TEST(FriendDecl, FriendTemplateParameterRange) { + RangeVerifier Verifier; + Verifier.expectRange(3, 1, 3, 8); + EXPECT_TRUE(Verifier.match("template \n" + "struct A {\n" + "friend T;\n" + "};\n", + friendDecl(), Lang_CXX11)); +} + +TEST(FriendDecl, FriendDecltypeLocation) { + LocationVerifier Verifier; + Verifier.expectLocation(4, 8); + EXPECT_TRUE(Verifier.match("struct A;\n" + "A foo();\n" + "struct A {\n" + "friend decltype(foo());\n" + "};\n", + friendDecl(), Lang_CXX11)); +} + +TEST(FriendDecl, FriendDecltypeRange) { + RangeVerifier Verifier; + Verifier.expectRange(4, 1, 4, 8); + EXPECT_TRUE(Verifier.match("struct A;\n" + "A foo();\n" + "struct A {\n" + "friend decltype(foo());\n" + "};\n", + friendDecl(), Lang_CXX11)); +} + TEST(FriendDecl, InstantiationSourceRange) { RangeVerifier Verifier; Verifier.expectRange(4, 3, 4, 35);