]> granicus.if.org Git - clang/commitdiff
[AST] Define a few more key getLocStart() implementations.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 9 Mar 2012 15:39:24 +0000 (15:39 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 9 Mar 2012 15:39:24 +0000 (15:39 +0000)
 - This cuts the # of getSourceRange calls by 60% on
   OGF/NSBezierPath-OAExtensions.m.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152412 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ccd42e66293effdb8f31b2abefd229dcd730744d..724b56895967f3d0bb98603fe7919bd8081df27e 100644 (file)
@@ -633,6 +633,9 @@ public:
   SourceLocation getOuterLocStart() const;
 
   virtual SourceRange getSourceRange() const;
+  SourceLocation getLocStart() const {
+    return getOuterLocStart();
+  }
 
   /// \brief Retrieve the nested-name-specifier that qualifies the name of this
   /// declaration, if it was present in the source.
index 578dbe0a821910cde39d1f1bedfce4afc96f0920..494aef5ae86a38fcff543963dec5ba30acfaa52b 100644 (file)
@@ -2127,6 +2127,8 @@ public:
   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
 
   SourceRange getSourceRange() const;
+  SourceLocation getLocStart() const;
+  SourceLocation getLocEnd() const;
 
   static bool classof(const Stmt *T) {
     return T->getStmtClass() >= firstCallExprConstant &&
index 8e2e64faf1dbb880385fece570767a54bb06bebc..3264e4ce0e240d17b9be33bd252d39fcf0ea1c6c 100644 (file)
@@ -905,6 +905,24 @@ SourceRange CallExpr::getSourceRange() const {
     end = getArg(getNumArgs() - 1)->getLocEnd();
   return SourceRange(begin, end);
 }
+SourceLocation CallExpr::getLocStart() const {
+  if (isa<CXXOperatorCallExpr>(this))
+    return cast<CXXOperatorCallExpr>(this)->getSourceRange().getBegin();
+
+  SourceLocation begin = getCallee()->getLocStart();
+  if (begin.isInvalid() && getNumArgs() > 0)
+    begin = getArg(0)->getLocStart();
+  return begin;
+}
+SourceLocation CallExpr::getLocEnd() const {
+  if (isa<CXXOperatorCallExpr>(this))
+    return cast<CXXOperatorCallExpr>(this)->getSourceRange().getEnd();
+
+  SourceLocation end = getRParenLoc();
+  if (end.isInvalid() && getNumArgs() > 0)
+    end = getArg(getNumArgs() - 1)->getLocEnd();
+  return end;
+}
 
 OffsetOfExpr *OffsetOfExpr::Create(ASTContext &C, QualType type, 
                                    SourceLocation OperatorLoc,