[cfe-commits] r126114 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/ExprCXX.h lib/AST/Expr.cpp lib/AST/ExprCXX.cpp
John McCall
rjmccall at apple.com
Sun Feb 20 22:23:05 PST 2011
Author: rjmccall
Date: Mon Feb 21 00:23:05 2011
New Revision: 126114
URL: http://llvm.org/viewvc/llvm-project?rev=126114&view=rev
Log:
Pseudo-revirtualize CallExpr::getSourceRange by making it follow the
logic from CXXMemberCallExpr and by making it check for
CXXOperatorCallExpr in order to defer. This is not really an awesome solution,
but I don't have a better idea.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=126114&r1=126113&r2=126114&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Feb 21 00:23:05 2011
@@ -1843,9 +1843,7 @@
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
- SourceRange getSourceRange() const {
- return SourceRange(getCallee()->getLocStart(), RParenLoc);
- }
+ SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() >= firstCallExprConstant &&
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=126114&r1=126113&r2=126114&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Feb 21 00:23:05 2011
@@ -108,8 +108,6 @@
/// FIXME: Returns 0 for member pointer call exprs.
CXXRecordDecl *getRecordDecl();
- SourceRange getSourceRange() const;
-
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXMemberCallExprClass;
}
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=126114&r1=126113&r2=126114&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Feb 21 00:23:05 2011
@@ -836,6 +836,19 @@
return FnType->getResultType();
}
+SourceRange CallExpr::getSourceRange() const {
+ if (isa<CXXOperatorCallExpr>(this))
+ return cast<CXXOperatorCallExpr>(this)->getSourceRange();
+
+ SourceLocation begin = getCallee()->getLocStart();
+ if (begin.isInvalid() && getNumArgs() > 0)
+ begin = getArg(0)->getLocStart();
+ SourceLocation end = getRParenLoc();
+ if (end.isInvalid() && getNumArgs() > 0)
+ end = getArg(getNumArgs() - 1)->getLocEnd();
+ return SourceRange(begin, end);
+}
+
OffsetOfExpr *OffsetOfExpr::Create(ASTContext &C, QualType type,
SourceLocation OperatorLoc,
TypeSourceInfo *tsi,
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=126114&r1=126113&r2=126114&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Feb 21 00:23:05 2011
@@ -335,6 +335,9 @@
}
SourceRange CXXConstructExpr::getSourceRange() const {
+ if (isa<CXXTemporaryObjectExpr>(this))
+ return cast<CXXTemporaryObjectExpr>(this)->getSourceRange();
+
if (ParenRange.isValid())
return SourceRange(Loc, ParenRange.getEnd());
@@ -397,13 +400,6 @@
return ThisArg->getType()->getAsCXXRecordDecl();
}
-SourceRange CXXMemberCallExpr::getSourceRange() const {
- SourceLocation LocStart = getCallee()->getLocStart();
- if (LocStart.isInvalid() && getNumArgs() > 0)
- LocStart = getArg(0)->getLocStart();
- return SourceRange(LocStart, getRParenLoc());
-}
-
//===----------------------------------------------------------------------===//
// Named casts
More information about the cfe-commits
mailing list