r184139 - Fix source range of CXXNewExpr with parentheses around the type. PR15569.
Eli Friedman
eli.friedman at gmail.com
Mon Jun 17 15:35:11 PDT 2013
Author: efriedma
Date: Mon Jun 17 17:35:10 2013
New Revision: 184139
URL: http://llvm.org/viewvc/llvm-project?rev=184139&view=rev
Log:
Fix source range of CXXNewExpr with parentheses around the type. PR15569.
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/unittests/AST/SourceLocationTest.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=184139&r1=184138&r2=184139&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Jun 17 17:35:10 2013
@@ -134,7 +134,10 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bo
this->Range.setEnd(DirectInitRange.getEnd()); break;
case ListInit:
this->Range.setEnd(getInitializer()->getSourceRange().getEnd()); break;
- default: break;
+ default:
+ if (TypeIdParens.isValid())
+ this->Range.setEnd(TypeIdParens.getEnd());
+ break;
}
}
Modified: cfe/trunk/unittests/AST/SourceLocationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/SourceLocationTest.cpp?rev=184139&r1=184138&r2=184139&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/SourceLocationTest.cpp (original)
+++ cfe/trunk/unittests/AST/SourceLocationTest.cpp Mon Jun 17 17:35:10 2013
@@ -174,5 +174,11 @@ TEST(TemplateSpecializationTypeLoc, Angl
loc(templateSpecializationType())));
}
+TEST(CXXNewExpr, TypeParenRange) {
+ RangeVerifier<CXXNewExpr> Verifier;
+ Verifier.expectRange(1, 10, 1, 18);
+ EXPECT_TRUE(Verifier.match("int* a = new (int);", newExpr()));
+}
+
} // end namespace ast_matchers
} // end namespace clang
More information about the cfe-commits
mailing list