Adds a test that verifies angle bracket locations.
Regression test to make sure TemplateSpecializationTypeLocs have the
correct locations for angle brackets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183514 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/AST/SourceLocationTest.cpp b/unittests/AST/SourceLocationTest.cpp
index f6c0edc..55356f1 100644
--- a/unittests/AST/SourceLocationTest.cpp
+++ b/unittests/AST/SourceLocationTest.cpp
@@ -155,5 +155,24 @@
"constant int2 i2 = (int2)(1, 2);", initListExpr(), Lang_OpenCL));
}
+class TemplateAngleBracketLocRangeVerifier : public RangeVerifier<TypeLoc> {
+protected:
+ virtual SourceRange getRange(const TypeLoc &Node) {
+ TemplateSpecializationTypeLoc T =
+ Node.castAs<TemplateSpecializationTypeLoc>();
+ assert(!T.isNull());
+ return SourceRange(T.getLAngleLoc(), T.getRAngleLoc());
+ }
+};
+
+TEST(TemplateSpecializationTypeLoc, AngleBracketLocations) {
+ TemplateAngleBracketLocRangeVerifier Verifier;
+ Verifier.expectRange(2, 8, 2, 10);
+ EXPECT_TRUE(Verifier.match(
+ "template<typename T> struct A {}; struct B{}; void f(\n"
+ "const A<B>&);",
+ loc(templateSpecializationType())));
+}
+
} // end namespace ast_matchers
} // end namespace clang