[cfe-commits] r91984 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/AST/ExprCXX.cpp
Ted Kremenek
kremenek at apple.com
Tue Dec 22 20:00:49 PST 2009
Author: kremenek
Date: Tue Dec 22 22:00:48 2009
New Revision: 91984
URL: http://llvm.org/viewvc/llvm-project?rev=91984&view=rev
Log:
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).
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=91984&r1=91983&r2=91984&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Dec 22 22:00:48 2009
@@ -561,13 +561,7 @@
Args[Arg] = ArgExpr;
}
- virtual SourceRange getSourceRange() const {
- // FIXME: Should we know where the parentheses are, if there are any?
- if (NumArgs == 0)
- return SourceRange(Loc);
-
- return SourceRange(Loc, Args[NumArgs - 1]->getLocEnd());
- }
+ virtual SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXConstructExprClass ||
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=91984&r1=91983&r2=91984&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Dec 22 22:00:48 2009
@@ -282,6 +282,18 @@
}
}
+SourceRange CXXConstructExpr::getSourceRange() const {
+ // FIXME: Should we know where the parentheses are, if there are any?
+ for (std::reverse_iterator<Stmt**> I(&Args[NumArgs]), E(&Args[0]); I!=E;++I) {
+ // Ignore CXXDefaultExprs when computing the range, as they don't
+ // have a range.
+ if (!isa<CXXDefaultArgExpr>(*I))
+ return SourceRange(Loc, (*I)->getLocEnd());
+ }
+
+ return SourceRange(Loc);
+}
+
SourceRange CXXOperatorCallExpr::getSourceRange() const {
OverloadedOperatorKind Kind = getOperator();
if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
More information about the cfe-commits
mailing list