forked from OSchip/llvm-project
[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
This commit is contained in:
parent
d863d31f4b
commit
b507f27185
|
@ -868,6 +868,8 @@ public:
|
||||||
SourceLocation getLocation() const { return Loc; }
|
SourceLocation getLocation() const { return Loc; }
|
||||||
void setLocation(SourceLocation L) { Loc = L; }
|
void setLocation(SourceLocation L) { Loc = L; }
|
||||||
SourceRange getSourceRange() const;
|
SourceRange getSourceRange() const;
|
||||||
|
SourceLocation getLocStart() const;
|
||||||
|
SourceLocation getLocEnd() const;
|
||||||
|
|
||||||
/// \brief Determine whether this declaration reference was preceded by a
|
/// \brief Determine whether this declaration reference was preceded by a
|
||||||
/// C++ nested-name-specifier, e.g., \c N::foo.
|
/// C++ nested-name-specifier, e.g., \c N::foo.
|
||||||
|
@ -2392,6 +2394,8 @@ public:
|
||||||
void setMemberLoc(SourceLocation L) { MemberLoc = L; }
|
void setMemberLoc(SourceLocation L) { MemberLoc = L; }
|
||||||
|
|
||||||
SourceRange getSourceRange() const;
|
SourceRange getSourceRange() const;
|
||||||
|
SourceLocation getLocStart() const;
|
||||||
|
SourceLocation getLocEnd() const;
|
||||||
|
|
||||||
SourceLocation getExprLoc() const { return MemberLoc; }
|
SourceLocation getExprLoc() const { return MemberLoc; }
|
||||||
|
|
||||||
|
@ -2626,6 +2630,12 @@ public:
|
||||||
SourceRange getSourceRange() const {
|
SourceRange getSourceRange() const {
|
||||||
return getSubExpr()->getSourceRange();
|
return getSubExpr()->getSourceRange();
|
||||||
}
|
}
|
||||||
|
SourceLocation getLocStart() const {
|
||||||
|
return getSubExpr()->getLocStart();
|
||||||
|
}
|
||||||
|
SourceLocation getLocEnd() const {
|
||||||
|
return getSubExpr()->getLocEnd();
|
||||||
|
}
|
||||||
|
|
||||||
static bool classof(const Stmt *T) {
|
static bool classof(const Stmt *T) {
|
||||||
return T->getStmtClass() == ImplicitCastExprClass;
|
return T->getStmtClass() == ImplicitCastExprClass;
|
||||||
|
|
|
@ -360,6 +360,16 @@ SourceRange DeclRefExpr::getSourceRange() const {
|
||||||
R.setEnd(getRAngleLoc());
|
R.setEnd(getRAngleLoc());
|
||||||
return R;
|
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
|
// FIXME: Maybe this should use DeclPrinter with a special "print predefined
|
||||||
// expr" policy instead.
|
// expr" policy instead.
|
||||||
|
@ -1016,24 +1026,26 @@ MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow,
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceRange MemberExpr::getSourceRange() const {
|
SourceRange MemberExpr::getSourceRange() const {
|
||||||
SourceLocation StartLoc;
|
return SourceRange(getLocStart(), getLocEnd());
|
||||||
|
}
|
||||||
|
SourceLocation MemberExpr::getLocStart() const {
|
||||||
if (isImplicitAccess()) {
|
if (isImplicitAccess()) {
|
||||||
if (hasQualifier())
|
if (hasQualifier())
|
||||||
StartLoc = getQualifierLoc().getBeginLoc();
|
return getQualifierLoc().getBeginLoc();
|
||||||
else
|
return MemberLoc;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLocation EndLoc = hasExplicitTemplateArgs()
|
// FIXME: We don't want this to happen. Rather, we should be able to
|
||||||
? getRAngleLoc() : getMemberNameInfo().getEndLoc();
|
// detect all kinds of implicit accesses more cleanly.
|
||||||
|
SourceLocation BaseStartLoc = getBase()->getLocStart();
|
||||||
return SourceRange(StartLoc, EndLoc);
|
if (BaseStartLoc.isValid())
|
||||||
|
return BaseStartLoc;
|
||||||
|
return MemberLoc;
|
||||||
|
}
|
||||||
|
SourceLocation MemberExpr::getLocEnd() const {
|
||||||
|
if (hasExplicitTemplateArgs())
|
||||||
|
return getRAngleLoc();
|
||||||
|
return getMemberNameInfo().getEndLoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastExpr::CheckCastConsistency() const {
|
void CastExpr::CheckCastConsistency() const {
|
||||||
|
|
Loading…
Reference in New Issue