r183514 - Adds a test that verifies angle bracket locations.

Manuel Klimek klimek at google.com
Fri Jun 7 04:27:57 PDT 2013


Author: klimek
Date: Fri Jun  7 06:27:57 2013
New Revision: 183514

URL: http://llvm.org/viewvc/llvm-project?rev=183514&view=rev
Log:
Adds a test that verifies angle bracket locations.

Regression test to make sure TemplateSpecializationTypeLocs have the
correct locations for angle brackets.

Modified:
    cfe/trunk/unittests/AST/SourceLocationTest.cpp

Modified: cfe/trunk/unittests/AST/SourceLocationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/SourceLocationTest.cpp?rev=183514&r1=183513&r2=183514&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/SourceLocationTest.cpp (original)
+++ cfe/trunk/unittests/AST/SourceLocationTest.cpp Fri Jun  7 06:27:57 2013
@@ -155,5 +155,24 @@ TEST(InitListExpr, VectorLiteralInitList
                   "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





More information about the cfe-commits mailing list