summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-06-17 22:35:10 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-06-17 22:35:10 +0000
commit2dcbdc0606b5eeec43bf13c79f0116979b37c1f7 (patch)
tree86070cee23a69921c18767ea7534df09162420fd /clang
parentd9a5608dd7acc3f0bc180d5002e17699fd8d6a49 (diff)
downloadbcm5719-llvm-2dcbdc0606b5eeec43bf13c79f0116979b37c1f7.tar.gz
bcm5719-llvm-2dcbdc0606b5eeec43bf13c79f0116979b37c1f7.zip
Fix source range of CXXNewExpr with parentheses around the type. PR15569.
llvm-svn: 184139
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/ExprCXX.cpp5
-rw-r--r--clang/unittests/AST/SourceLocationTest.cpp6
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 59e780ae0a1..55bd1990f60 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -134,7 +134,10 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
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;
}
}
diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp
index 990e6dfc85a..669fcd48a47 100644
--- a/clang/unittests/AST/SourceLocationTest.cpp
+++ b/clang/unittests/AST/SourceLocationTest.cpp
@@ -174,5 +174,11 @@ TEST(TemplateSpecializationTypeLoc, AngleBracketLocations) {
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
OpenPOWER on IntegriCloud