aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-02-21 06:23:05 +0000
committerJohn McCall <rjmccall@apple.com>2011-02-21 06:23:05 +0000
commit2882eca5a184c78f793188083f6ce539740a5cf2 (patch)
treead17d0e64304c34f27ee62b11470e6e11cc22217
parent7cc25fe47290dc302157e15b04a1f95395f43ab5 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126114 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h4
-rw-r--r--include/clang/AST/ExprCXX.h2
-rw-r--r--lib/AST/Expr.cpp13
-rw-r--r--lib/AST/ExprCXX.cpp10
4 files changed, 17 insertions, 12 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index a17205c2b6..95bfad5a16 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1843,9 +1843,7 @@ public:
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 &&
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 85ce9621d9..4a9a3d2cdf 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -108,8 +108,6 @@ public:
/// FIXME: Returns 0 for member pointer call exprs.
CXXRecordDecl *getRecordDecl();
- SourceRange getSourceRange() const;
-
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXMemberCallExprClass;
}
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 391b26ab48..1c1061b5a2 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -836,6 +836,19 @@ QualType CallExpr::getCallReturnType() const {
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,
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 28ff9fb57a..0e83fac8be 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -335,6 +335,9 @@ DependentScopeDeclRefExpr::CreateEmpty(ASTContext &C,
}
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 @@ CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() {
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