r185765 - Fixed source location info for UnaryTransformTypeLoc nodes.
Enea Zaffanella
zaffanella at cs.unipr.it
Sat Jul 6 11:54:59 PDT 2013
Author: enea
Date: Sat Jul 6 13:54:58 2013
New Revision: 185765
URL: http://llvm.org/viewvc/llvm-project?rev=185765&view=rev
Log:
Fixed source location info for UnaryTransformTypeLoc nodes.
Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/unittests/AST/SourceLocationTest.cpp
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=185765&r1=185764&r2=185765&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sat Jul 6 13:54:58 2013
@@ -3186,6 +3186,16 @@ AST_TYPE_MATCHER(TypedefType, typedefTyp
/// 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
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=185765&r1=185764&r2=185765&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Jul 6 13:54:58 2013
@@ -827,6 +827,7 @@ void Parser::ParseUnderlyingTypeSpecifie
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
Modified: cfe/trunk/unittests/AST/SourceLocationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/SourceLocationTest.cpp?rev=185765&r1=185764&r2=185765&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/SourceLocationTest.cpp (original)
+++ cfe/trunk/unittests/AST/SourceLocationTest.cpp Sat Jul 6 13:54:58 2013
@@ -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
More information about the cfe-commits
mailing list