aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-03 00:35:38 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-03 00:35:38 +0000
commit40749ee585abc84fbb3c8fdbd8aaac062f153062 (patch)
treeeff7f3f3a45a005227e3bb4e7108b27b1adc359f /lib/AST/ExprCXX.cpp
parent0582c897ec7261b4c6af0fe26dc2a0b6b54d266c (diff)
Improve source-location information for CXXConstructExpr nodes, by
ensuring that they cover all of their child nodes. There's still a clang_getCursor()-related issue with CXXFunctionalCastExprs with CXXConstructExprs as children (see FIXME in the test case); I'll look at that separately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprCXX.cpp')
-rw-r--r--lib/AST/ExprCXX.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index a07d7840f0..60785d471a 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -347,9 +347,22 @@ StmtIterator DependentScopeDeclRefExpr::child_end() {
}
SourceRange CXXConstructExpr::getSourceRange() const {
- return ParenRange.isValid() ?
- SourceRange(Loc, ParenRange.getEnd()) :
- SourceRange(Loc);
+ if (ParenRange.isValid())
+ return SourceRange(Loc, ParenRange.getEnd());
+
+ SourceLocation End = Loc;
+ for (unsigned I = getNumArgs(); I > 0; --I) {
+ const Expr *Arg = getArg(I-1);
+ if (!Arg->isDefaultArgument()) {
+ SourceLocation NewEnd = Arg->getLocEnd();
+ if (NewEnd.isValid()) {
+ End = NewEnd;
+ break;
+ }
+ }
+ }
+
+ return SourceRange(Loc, End);
}
SourceRange CXXOperatorCallExpr::getSourceRange() const {