summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-03-09 15:39:15 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-03-09 15:39:15 +0000
commitb507f2718575a55a936372ed946feeac643be95b (patch)
treed108cda5443b0c698bc2d376cac11ee968ea0918 /clang/lib/AST/Expr.cpp
parentd863d31f4bc8dc652c368b809c4a330eeb56772b (diff)
downloadbcm5719-llvm-b507f2718575a55a936372ed946feeac643be95b.tar.gz
bcm5719-llvm-b507f2718575a55a936372ed946feeac643be95b.zip
[AST] Add {DeclRefExpr,MemberExpr,ImplicitCastExpr}::{getLocStart,getLocEnd} methods.
- There are probably a lot more of these worth adding, but these are a start at hitting some of the exprs for which getSourceRange().getBegin() is a poor substitute for getLocStart(). llvm-svn: 152410
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 18cc5b37bf7..0266cd63bbc 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -360,6 +360,16 @@ SourceRange DeclRefExpr::getSourceRange() const {
R.setEnd(getRAngleLoc());
return R;
}
+SourceLocation DeclRefExpr::getLocStart() const {
+ if (hasQualifier())
+ return getQualifierLoc().getBeginLoc();
+ return getNameInfo().getLocStart();
+}
+SourceLocation DeclRefExpr::getLocEnd() const {
+ if (hasExplicitTemplateArgs())
+ return getRAngleLoc();
+ return getNameInfo().getLocEnd();
+}
// FIXME: Maybe this should use DeclPrinter with a special "print predefined
// expr" policy instead.
@@ -1016,24 +1026,26 @@ MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow,
}
SourceRange MemberExpr::getSourceRange() const {
- SourceLocation StartLoc;
+ return SourceRange(getLocStart(), getLocEnd());
+}
+SourceLocation MemberExpr::getLocStart() const {
if (isImplicitAccess()) {
if (hasQualifier())
- StartLoc = getQualifierLoc().getBeginLoc();
- else
- StartLoc = MemberLoc;
- } else {
- // FIXME: We don't want this to happen. Rather, we should be able to
- // detect all kinds of implicit accesses more cleanly.
- StartLoc = getBase()->getLocStart();
- if (StartLoc.isInvalid())
- StartLoc = MemberLoc;
+ return getQualifierLoc().getBeginLoc();
+ return MemberLoc;
}
- SourceLocation EndLoc = hasExplicitTemplateArgs()
- ? getRAngleLoc() : getMemberNameInfo().getEndLoc();
-
- return SourceRange(StartLoc, EndLoc);
+ // FIXME: We don't want this to happen. Rather, we should be able to
+ // detect all kinds of implicit accesses more cleanly.
+ SourceLocation BaseStartLoc = getBase()->getLocStart();
+ if (BaseStartLoc.isValid())
+ return BaseStartLoc;
+ return MemberLoc;
+}
+SourceLocation MemberExpr::getLocEnd() const {
+ if (hasExplicitTemplateArgs())
+ return getRAngleLoc();
+ return getMemberNameInfo().getEndLoc();
}
void CastExpr::CheckCastConsistency() const {
OpenPOWER on IntegriCloud