[cfe-commits] r167597 - in /cfe/trunk: lib/AST/ExprCXX.cpp unittests/AST/SourceLocationTest.cpp
David Blaikie
dblaikie at gmail.com
Thu Nov 8 14:53:48 PST 2012
Author: dblaikie
Date: Thu Nov 8 16:53:48 2012
New Revision: 167597
URL: http://llvm.org/viewvc/llvm-project?rev=167597&view=rev
Log:
Fix a source range regression in C++ new expressions with call initializers.
Introduced in r167507, discovered in review by Abramo Bagnara.
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=167597&r1=167596&r2=167597&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Thu Nov 8 16:53:48 2012
@@ -130,6 +130,14 @@
SubExprs[i++] = placementArgs[j];
}
+
+ switch (getInitializationStyle()) {
+ case CallInit:
+ this->Range.setEnd(DirectInitRange.getEnd()); break;
+ case ListInit:
+ this->Range.setEnd(getInitializer()->getSourceRange().getEnd()); break;
+ default: break;
+ }
}
void CXXNewExpr::AllocateArgsArray(ASTContext &C, bool isArray,
Modified: cfe/trunk/unittests/AST/SourceLocationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/SourceLocationTest.cpp?rev=167597&r1=167596&r2=167597&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/SourceLocationTest.cpp (original)
+++ cfe/trunk/unittests/AST/SourceLocationTest.cpp Thu Nov 8 16:53:48 2012
@@ -258,6 +258,12 @@
EXPECT_TRUE(Verifier.match("void f() { new int[10]; }", newExpr()));
}
+TEST(CXXNewExpr, ParenRange) {
+ RangeVerifier<CXXNewExpr> Verifier;
+ Verifier.expectRange(1, 12, 1, 20);
+ EXPECT_TRUE(Verifier.match("void f() { new int(); }", newExpr()));
+}
+
TEST(MemberExpr, ImplicitMemberRange) {
RangeVerifier<MemberExpr> Verifier;
Verifier.expectRange(2, 30, 2, 30);
More information about the cfe-commits
mailing list