]> granicus.if.org Git - clang/commitdiff
Pseudo-revirtualize CallExpr::getSourceRange by making it follow the
authorJohn McCall <rjmccall@apple.com>
Mon, 21 Feb 2011 06:23:05 +0000 (06:23 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 21 Feb 2011 06:23:05 +0000 (06:23 +0000)
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

include/clang/AST/Expr.h
include/clang/AST/ExprCXX.h
lib/AST/Expr.cpp
lib/AST/ExprCXX.cpp

index a17205c2b6b9f9bd8df96c77652af4fa9d847445..95bfad5a16c280dfb43e8a89c3d0cf709f47a830 100644 (file)
@@ -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 &&
index 85ce9621d9286daf9ddc2ea3e42490f414031a52..4a9a3d2cdf69700277a9f58d835924ba51dff258 100644 (file)
@@ -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;
   }
index 391b26ab48ea56f8490a62ae2307b8bedcff1f19..1c1061b5a2296500d555a2cca76c8364b27e2adf 100644 (file)
@@ -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, 
index 28ff9fb57afcbb94568149ce1cc8e5ae50d198e0..0e83fac8be2dcc2d058ea69afd80090280911c47 100644 (file)
@@ -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