From: Manuel Klimek Date: Fri, 7 Jun 2013 11:27:57 +0000 (+0000) Subject: Adds a test that verifies angle bracket locations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e6e515fc74ecb6d98689a93b5569763c53c107a;p=clang 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 f6c0edc927..55356f11da 100644 --- a/unittests/AST/SourceLocationTest.cpp +++ b/unittests/AST/SourceLocationTest.cpp @@ -155,5 +155,24 @@ TEST(InitListExpr, VectorLiteralInitListParens) { "constant int2 i2 = (int2)(1, 2);", initListExpr(), Lang_OpenCL)); } +class TemplateAngleBracketLocRangeVerifier : public RangeVerifier { +protected: + virtual SourceRange getRange(const TypeLoc &Node) { + TemplateSpecializationTypeLoc T = + Node.castAs(); + 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 struct A {}; struct B{}; void f(\n" + "const A&);", + loc(templateSpecializationType()))); +} + } // end namespace ast_matchers } // end namespace clang