]> granicus.if.org Git - clang/commitdiff
Adds a test that verifies angle bracket locations.
authorManuel Klimek <klimek@google.com>
Fri, 7 Jun 2013 11:27:57 +0000 (11:27 +0000)
committerManuel Klimek <klimek@google.com>
Fri, 7 Jun 2013 11:27:57 +0000 (11:27 +0000)
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

unittests/AST/SourceLocationTest.cpp

index f6c0edc9271ba3c6dc28b84ad053af15fb1c82c4..55356f11dad3956c0cafae33a5fbdf834ff82eac 100644 (file)
@@ -155,5 +155,24 @@ TEST(InitListExpr, VectorLiteralInitListParens) {
                   "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