From 49ace5cd62ed988ddb0b0493b9e88146eb6f074c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 23 Dec 2009 04:00:48 +0000 Subject: Fix CXXConstructExpr::getSourceRange() to not include the source ranges of CXXDefaultArgExprs when computing its range (since these expressions have no source range, and using them will make the encompassing range invalid). llvm-svn: 91984 --- clang/lib/AST/ExprCXX.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/lib') diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 9c14f741fdd..5444a7748cb 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -282,6 +282,18 @@ bool UnaryTypeTraitExpr::EvaluateTrait(ASTContext& C) const { } } +SourceRange CXXConstructExpr::getSourceRange() const { + // FIXME: Should we know where the parentheses are, if there are any? + for (std::reverse_iterator I(&Args[NumArgs]), E(&Args[0]); I!=E;++I) { + // Ignore CXXDefaultExprs when computing the range, as they don't + // have a range. + if (!isa(*I)) + return SourceRange(Loc, (*I)->getLocEnd()); + } + + return SourceRange(Loc); +} + SourceRange CXXOperatorCallExpr::getSourceRange() const { OverloadedOperatorKind Kind = getOperator(); if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) { -- cgit v1.2.3