diff options
author | Enea Zaffanella <zaffanella@cs.unipr.it> | 2013-07-06 18:54:58 +0000 |
---|---|---|
committer | Enea Zaffanella <zaffanella@cs.unipr.it> | 2013-07-06 18:54:58 +0000 |
commit | a90af72e8f7e4d88f16148ff2c995c68d67f496c (patch) | |
tree | d9f52f998a0f2f9886225f01c9bec38209849df3 | |
parent | e557da26db4cd4824e9051a8e517e80a82a9bdaa (diff) | |
download | bcm5719-llvm-a90af72e8f7e4d88f16148ff2c995c68d67f496c.tar.gz bcm5719-llvm-a90af72e8f7e4d88f16148ff2c995c68d67f496c.zip |
Fixed source location info for UnaryTransformTypeLoc nodes.
llvm-svn: 185765
-rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchers.h | 10 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 1 | ||||
-rw-r--r-- | clang/unittests/AST/SourceLocationTest.cpp | 21 |
3 files changed, 32 insertions, 0 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index d6c19b7dfa2..110638a278d 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -3186,6 +3186,16 @@ AST_TYPE_MATCHER(TypedefType, typedefType); /// instantiation in \c A and the type of the variable declaration in \c B. AST_TYPE_MATCHER(TemplateSpecializationType, templateSpecializationType); +/// \brief Matches types nodes representing unary type transformations. +/// +/// Given: +/// \code +/// typedef __underlying_type(T) type; +/// \endcode +/// unaryTransformType() +/// matches "__underlying_type(T)" +AST_TYPE_MATCHER(UnaryTransformType, unaryTransformType); + /// \brief Matches record types (e.g. structs, classes). /// /// Given diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 67f9c3c7a7c..070c9a0120d 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -827,6 +827,7 @@ void Parser::ParseUnderlyingTypeSpecifier(DeclSpec &DS) { if (DS.SetTypeSpecType(DeclSpec::TST_underlyingType, StartLoc, PrevSpec, DiagID, Result.release())) Diag(StartLoc, DiagID) << PrevSpec; + DS.setTypeofParensRange(T.getRange()); } /// ParseBaseTypeSpecifier - Parse a C++ base-type-specifier which is either a diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp index 669fcd48a47..be63085b8a5 100644 --- a/clang/unittests/AST/SourceLocationTest.cpp +++ b/clang/unittests/AST/SourceLocationTest.cpp @@ -180,5 +180,26 @@ TEST(CXXNewExpr, TypeParenRange) { EXPECT_TRUE(Verifier.match("int* a = new (int);", newExpr())); } +class UnaryTransformTypeLocParensRangeVerifier : public RangeVerifier<TypeLoc> { +protected: + virtual SourceRange getRange(const TypeLoc &Node) { + UnaryTransformTypeLoc T = + Node.getUnqualifiedLoc().castAs<UnaryTransformTypeLoc>(); + assert(!T.isNull()); + return SourceRange(T.getLParenLoc(), T.getRParenLoc()); + } +}; + +TEST(UnaryTransformTypeLoc, ParensRange) { + UnaryTransformTypeLocParensRangeVerifier Verifier; + Verifier.expectRange(3, 26, 3, 28); + EXPECT_TRUE(Verifier.match( + "template <typename T>\n" + "struct S {\n" + "typedef __underlying_type(T) type;\n" + "};", + loc(unaryTransformType()))); +} + } // end namespace ast_matchers } // end namespace clang |