aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-03-09 15:39:24 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-03-09 15:39:24 +0000
commit8fbc6d23d61213750ba1fdcb0b4b9d3d54bbc32f (patch)
tree3c8e469dc191271a6b92f1d7a96e511f6b29cb0f
parent90e25a8b2cc5d006e4ced052bcdb40c8af999456 (diff)
[AST] Define a few more key getLocStart() implementations.
- 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
-rw-r--r--include/clang/AST/Decl.h3
-rw-r--r--include/clang/AST/Expr.h2
-rw-r--r--lib/AST/Expr.cpp18
3 files changed, 23 insertions, 0 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index ccd42e6629..724b568959 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -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.
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 578dbe0a82..494aef5ae8 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -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 &&
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 8e2e64faf1..3264e4ce0e 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -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,