Changed getLocStart() and getLocEnd() to be required for Stmts, and make
getSourceRange() optional. The default implementation for getSourceRange()
is build the range by calling getLocStart() and getLocEnd().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171067 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Erik Verbruggen 2012-12-25 14:51:39 +00:00
Родитель 38980086c0
Коммит 65d78312ce
11 изменённых файлов: 475 добавлений и 421 удалений

Просмотреть файл

@ -796,9 +796,11 @@ public:
/// \brief Retrieve the location of this expression. /// \brief Retrieve the location of this expression.
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
if (SourceExpr) return SourceExpr->getSourceRange(); return SourceExpr ? SourceExpr->getLocStart() : Loc;
return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY {
return SourceExpr ? SourceExpr->getLocEnd() : Loc;
} }
SourceLocation getExprLoc() const LLVM_READONLY { SourceLocation getExprLoc() const LLVM_READONLY {
if (SourceExpr) return SourceExpr->getExprLoc(); if (SourceExpr) return SourceExpr->getExprLoc();
@ -954,7 +956,6 @@ 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 LLVM_READONLY;
SourceLocation getLocStart() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY; SourceLocation getLocEnd() const LLVM_READONLY;
@ -1160,7 +1161,8 @@ public:
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl); static std::string ComputeName(IdentType IT, const Decl *CurrentDecl);
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == PredefinedExprClass; return T->getStmtClass() == PredefinedExprClass;
@ -1241,7 +1243,8 @@ public:
/// \brief Returns a new empty integer literal. /// \brief Returns a new empty integer literal.
static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty); static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty);
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
/// \brief Retrieve the location of the literal. /// \brief Retrieve the location of the literal.
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
@ -1286,7 +1289,8 @@ public:
return static_cast<CharacterKind>(CharacterLiteralBits.Kind); return static_cast<CharacterKind>(CharacterLiteralBits.Kind);
} }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
unsigned getValue() const { return Value; } unsigned getValue() const { return Value; }
@ -1334,7 +1338,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 LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == FloatingLiteralClass; return T->getStmtClass() == FloatingLiteralClass;
@ -1365,7 +1370,9 @@ public:
Expr *getSubExpr() { return cast<Expr>(Val); } Expr *getSubExpr() { return cast<Expr>(Val); }
void setSubExpr(Expr *E) { Val = E; } void setSubExpr(Expr *E) { Val = E; }
SourceRange getSourceRange() const LLVM_READONLY { return Val->getSourceRange(); } SourceLocation getLocStart() const LLVM_READONLY { return Val->getLocStart(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Val->getLocEnd(); }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ImaginaryLiteralClass; return T->getStmtClass() == ImaginaryLiteralClass;
} }
@ -1524,9 +1531,11 @@ public:
tokloc_iterator tokloc_begin() const { return TokLocs; } tokloc_iterator tokloc_begin() const { return TokLocs; }
tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; } tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return TokLocs[0]; }
return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]); SourceLocation getLocEnd() const LLVM_READONLY {
return TokLocs[NumConcatenated - 1];
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == StringLiteralClass; return T->getStmtClass() == StringLiteralClass;
} }
@ -1557,7 +1566,8 @@ public:
Expr *getSubExpr() { return cast<Expr>(Val); } Expr *getSubExpr() { return cast<Expr>(Val); }
void setSubExpr(Expr *E) { Val = E; } void setSubExpr(Expr *E) { Val = E; }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(L, R); } SourceLocation getLocStart() const LLVM_READONLY { return L; }
SourceLocation getLocEnd() const LLVM_READONLY { return R; }
/// \brief Get the location of the left parentheses '('. /// \brief Get the location of the left parentheses '('.
SourceLocation getLParen() const { return L; } SourceLocation getLParen() const { return L; }
@ -1669,11 +1679,11 @@ public:
/// the given unary opcode. /// the given unary opcode.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc); static OverloadedOperatorKind getOverloadedOperator(Opcode Opc);
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
if (isPostfix()) return isPostfix() ? Val->getLocStart() : Loc;
return SourceRange(Val->getLocStart(), Loc); }
else SourceLocation getLocEnd() const LLVM_READONLY {
return SourceRange(Loc, Val->getLocEnd()); return isPostfix() ? Loc : Val->getLocEnd();
} }
SourceLocation getExprLoc() const LLVM_READONLY { return Loc; } SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
@ -1791,6 +1801,8 @@ public:
/// contains the location of the period (if there is one) and the /// contains the location of the period (if there is one) and the
/// identifier. /// identifier.
SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
}; };
private: private:
@ -1870,9 +1882,8 @@ public:
return NumExprs; return NumExprs;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return OperatorLoc; }
return SourceRange(OperatorLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == OffsetOfExprClass; return T->getStmtClass() == OffsetOfExprClass;
@ -1974,9 +1985,8 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return OpLoc; }
return SourceRange(OpLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == UnaryExprOrTypeTraitExprClass; return T->getStmtClass() == UnaryExprOrTypeTraitExprClass;
@ -2048,14 +2058,17 @@ public:
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS()); return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(getLHS()->getLocStart(), RBracketLoc); return getLHS()->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return RBracketLoc; }
SourceLocation getRBracketLoc() const { return RBracketLoc; } SourceLocation getRBracketLoc() const { return RBracketLoc; }
void setRBracketLoc(SourceLocation L) { RBracketLoc = L; } void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
SourceLocation getExprLoc() const LLVM_READONLY { return getBase()->getExprLoc(); } SourceLocation getExprLoc() const LLVM_READONLY {
return getBase()->getExprLoc();
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ArraySubscriptExprClass; return T->getStmtClass() == ArraySubscriptExprClass;
@ -2187,7 +2200,6 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY; SourceLocation getLocEnd() const LLVM_READONLY;
@ -2455,7 +2467,6 @@ public:
SourceLocation getMemberLoc() const { return MemberLoc; } SourceLocation getMemberLoc() const { return MemberLoc; }
void setMemberLoc(SourceLocation L) { MemberLoc = L; } void setMemberLoc(SourceLocation L) { MemberLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY; SourceLocation getLocEnd() const LLVM_READONLY;
@ -2534,13 +2545,19 @@ public:
TInfoAndScope.setPointer(tinfo); TInfoAndScope.setPointer(tinfo);
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
// FIXME: Init should never be null. // FIXME: Init should never be null.
if (!Init) if (!Init)
return SourceRange(); return SourceLocation();
if (LParenLoc.isInvalid()) if (LParenLoc.isInvalid())
return Init->getSourceRange(); return Init->getLocStart();
return SourceRange(LParenLoc, Init->getLocEnd()); return LParenLoc;
}
SourceLocation getLocEnd() const LLVM_READONLY {
// FIXME: Init should never be null.
if (!Init)
return SourceLocation();
return Init->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -2686,9 +2703,6 @@ public:
static ImplicitCastExpr *CreateEmpty(ASTContext &Context, unsigned PathSize); static ImplicitCastExpr *CreateEmpty(ASTContext &Context, unsigned PathSize);
SourceRange getSourceRange() const LLVM_READONLY {
return getSubExpr()->getSourceRange();
}
SourceLocation getLocStart() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return getSubExpr()->getLocStart(); return getSubExpr()->getLocStart();
} }
@ -2787,9 +2801,11 @@ public:
SourceLocation getRParenLoc() const { return RPLoc; } SourceLocation getRParenLoc() const { return RPLoc; }
void setRParenLoc(SourceLocation L) { RPLoc = L; } void setRParenLoc(SourceLocation L) { RPLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return LPLoc; }
return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return getSubExpr()->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CStyleCastExprClass; return T->getStmtClass() == CStyleCastExprClass;
} }
@ -2864,8 +2880,11 @@ public:
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); } Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
void setRHS(Expr *E) { SubExprs[RHS] = E; } void setRHS(Expr *E) { SubExprs[RHS] = E; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd()); return getLHS()->getLocStart();
}
SourceLocation getLocEnd() const LLVM_READONLY {
return getRHS()->getLocEnd();
} }
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
@ -3101,9 +3120,13 @@ public:
Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); } Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); } Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd()); return getCond()->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY {
return getRHS()->getLocEnd();
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ConditionalOperatorClass; return T->getStmtClass() == ConditionalOperatorClass;
} }
@ -3182,9 +3205,13 @@ public:
return cast<Expr>(SubExprs[RHS]); return cast<Expr>(SubExprs[RHS]);
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(getCommon()->getLocStart(), getFalseExpr()->getLocEnd()); return getCommon()->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY {
return getFalseExpr()->getLocEnd();
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == BinaryConditionalOperatorClass; return T->getStmtClass() == BinaryConditionalOperatorClass;
} }
@ -3233,9 +3260,8 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; } SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; } void setLabelLoc(SourceLocation L) { LabelLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AmpAmpLoc; }
return SourceRange(AmpAmpLoc, LabelLoc); SourceLocation getLocEnd() const LLVM_READONLY { return LabelLoc; }
}
LabelDecl *getLabel() const { return Label; } LabelDecl *getLabel() const { return Label; }
void setLabel(LabelDecl *L) { Label = L; } void setLabel(LabelDecl *L) { Label = L; }
@ -3274,9 +3300,8 @@ public:
const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); } const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }
void setSubStmt(CompoundStmt *S) { SubStmt = S; } void setSubStmt(CompoundStmt *S) { SubStmt = S; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return LParenLoc; }
return SourceRange(LParenLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getLParenLoc() const { return LParenLoc; }
void setLParenLoc(SourceLocation L) { LParenLoc = L; } void setLParenLoc(SourceLocation L) { LParenLoc = L; }
@ -3322,9 +3347,9 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return BuiltinLoc; }
return SourceRange(BuiltinLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ShuffleVectorExprClass; return T->getStmtClass() == ShuffleVectorExprClass;
} }
@ -3416,9 +3441,9 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return BuiltinLoc; }
return SourceRange(BuiltinLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ChooseExprClass; return T->getStmtClass() == ChooseExprClass;
} }
@ -3452,9 +3477,9 @@ public:
SourceLocation getTokenLocation() const { return TokenLoc; } SourceLocation getTokenLocation() const { return TokenLoc; }
void setTokenLocation(SourceLocation L) { TokenLoc = L; } void setTokenLocation(SourceLocation L) { TokenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return TokenLoc; }
return SourceRange(TokenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return TokenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == GNUNullExprClass; return T->getStmtClass() == GNUNullExprClass;
} }
@ -3497,9 +3522,9 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return BuiltinLoc; }
return SourceRange(BuiltinLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == VAArgExprClass; return T->getStmtClass() == VAArgExprClass;
} }
@ -3698,7 +3723,8 @@ public:
InitListExprBits.InitializesStdInitializerList = ISIL; InitListExprBits.InitializesStdInitializerList = ISIL;
} }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == InitListExprClass; return T->getStmtClass() == InitListExprClass;
@ -3923,17 +3949,17 @@ public:
return ArrayOrRange.Index; return ArrayOrRange.Index;
} }
SourceLocation getStartLocation() const { SourceLocation getLocStart() const LLVM_READONLY {
if (Kind == FieldDesignator) if (Kind == FieldDesignator)
return getDotLoc().isInvalid()? getFieldLoc() : getDotLoc(); return getDotLoc().isInvalid()? getFieldLoc() : getDotLoc();
else else
return getLBracketLoc(); return getLBracketLoc();
} }
SourceLocation getEndLocation() const { SourceLocation getLocEnd() const LLVM_READONLY {
return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc(); return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc();
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getStartLocation(), getEndLocation()); return SourceRange(getLocStart(), getLocEnd());
} }
}; };
@ -4034,7 +4060,8 @@ public:
SourceRange getDesignatorsSourceRange() const; SourceRange getDesignatorsSourceRange() const;
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == DesignatedInitExprClass; return T->getStmtClass() == DesignatedInitExprClass;
@ -4069,9 +4096,8 @@ public:
return T->getStmtClass() == ImplicitValueInitExprClass; return T->getStmtClass() == ImplicitValueInitExprClass;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
return SourceRange(); SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
}
// Iterators // Iterators
child_range children() { return child_range(); } child_range children() { return child_range(); }
@ -4107,9 +4133,9 @@ public:
SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getLParenLoc() const { return LParenLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return LParenLoc; }
return SourceRange(LParenLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ParenListExprClass; return T->getStmtClass() == ParenListExprClass;
} }
@ -4221,9 +4247,9 @@ public:
const Expr *getResultExpr() const { return getAssocExpr(getResultIndex()); } const Expr *getResultExpr() const { return getAssocExpr(getResultIndex()); }
Expr *getResultExpr() { return getAssocExpr(getResultIndex()); } Expr *getResultExpr() { return getAssocExpr(getResultIndex()); }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return GenericLoc; }
return SourceRange(GenericLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == GenericSelectionExprClass; return T->getStmtClass() == GenericSelectionExprClass;
} }
@ -4286,9 +4312,10 @@ public:
/// aggregate Constant of ConstantInt(s). /// aggregate Constant of ConstantInt(s).
void getEncodedElementAccess(SmallVectorImpl<unsigned> &Elts) const; void getEncodedElementAccess(SmallVectorImpl<unsigned> &Elts) const;
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(getBase()->getLocStart(), AccessorLoc); return getBase()->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return AccessorLoc; }
/// isArrow - Return true if the base expression is a pointer to vector, /// isArrow - Return true if the base expression is a pointer to vector,
/// return false if the base expression is a vector. /// return false if the base expression is a vector.
@ -4328,9 +4355,8 @@ public:
const Stmt *getBody() const; const Stmt *getBody() const;
Stmt *getBody(); Stmt *getBody();
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return getCaretLocation(); }
return SourceRange(getCaretLocation(), getBody()->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return getBody()->getLocEnd(); }
}
/// getFunctionType - Return the underlying function type for this block. /// getFunctionType - Return the underlying function type for this block.
const FunctionProtoType *getFunctionType() const; const FunctionProtoType *getFunctionType() const;
@ -4377,9 +4403,8 @@ public:
/// getRParenLoc - Return the location of final right parenthesis. /// getRParenLoc - Return the location of final right parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return BuiltinLoc; }
return SourceRange(BuiltinLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == AsTypeExprClass; return T->getStmtClass() == AsTypeExprClass;
@ -4508,8 +4533,12 @@ public:
SourceLocation getExprLoc() const LLVM_READONLY { SourceLocation getExprLoc() const LLVM_READONLY {
return getSyntacticForm()->getExprLoc(); return getSyntacticForm()->getExprLoc();
} }
SourceRange getSourceRange() const LLVM_READONLY {
return getSyntacticForm()->getSourceRange(); SourceLocation getLocStart() const LLVM_READONLY {
return getSyntacticForm()->getLocStart();
}
SourceLocation getLocEnd() const LLVM_READONLY {
return getSyntacticForm()->getLocEnd();
} }
child_range children() { child_range children() {
@ -4603,9 +4632,9 @@ public:
SourceLocation getBuiltinLoc() const { return BuiltinLoc; } SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return BuiltinLoc; }
return SourceRange(BuiltinLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == AtomicExprClass; return T->getStmtClass() == AtomicExprClass;
} }

Просмотреть файл

@ -84,6 +84,8 @@ public:
/// bracket. /// bracket.
SourceLocation getOperatorLoc() const { return getRParenLoc(); } SourceLocation getOperatorLoc() const { return getRParenLoc(); }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const { return Range; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -201,9 +203,9 @@ public:
/// \brief Retrieve the location of the closing parenthesis. /// \brief Retrieve the location of the closing parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
return SourceRange(Loc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
switch (T->getStmtClass()) { switch (T->getStmtClass()) {
case CXXStaticCastExprClass: case CXXStaticCastExprClass:
@ -387,9 +389,6 @@ public:
return getArg(0)->getLocStart(); return getArg(0)->getLocStart();
} }
SourceLocation getLocEnd() const { return getRParenLoc(); } SourceLocation getLocEnd() const { return getRParenLoc(); }
SourceRange getSourceRange() const {
return SourceRange(getLocStart(), getLocEnd());
}
/// getUDSuffixLoc - Returns the location of a ud-suffix in the expression. /// getUDSuffixLoc - Returns the location of a ud-suffix in the expression.
@ -425,7 +424,8 @@ public:
bool getValue() const { return Value; } bool getValue() const { return Value; }
void setValue(bool V) { Value = V; } void setValue(bool V) { Value = V; }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -450,7 +450,8 @@ public:
explicit CXXNullPtrLiteralExpr(EmptyShell Empty) explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
: Expr(CXXNullPtrLiteralExprClass, Empty) { } : Expr(CXXNullPtrLiteralExprClass, Empty) { }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -532,6 +533,8 @@ public:
Operand = E; Operand = E;
} }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
void setSourceRange(SourceRange R) { Range = R; } void setSourceRange(SourceRange R) { Range = R; }
@ -606,6 +609,8 @@ public:
Operand = E; Operand = E;
} }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
void setSourceRange(SourceRange R) { Range = R; } void setSourceRange(SourceRange R) { Range = R; }
@ -654,7 +659,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 LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
bool isImplicit() const { return Implicit; } bool isImplicit() const { return Implicit; }
void setImplicit(bool I) { Implicit = I; } void setImplicit(bool I) { Implicit = I; }
@ -703,10 +709,11 @@ public:
/// this variable. /// this variable.
bool isThrownVariableInScope() const { return IsThrownVariableInScope; } bool isThrownVariableInScope() const { return IsThrownVariableInScope; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return ThrowLoc; }
SourceLocation getLocEnd() const LLVM_READONLY {
if (getSubExpr() == 0) if (getSubExpr() == 0)
return SourceRange(ThrowLoc, ThrowLoc); return ThrowLoc;
return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); return getSubExpr()->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -790,11 +797,10 @@ public:
/// used. /// used.
SourceLocation getUsedLocation() const { return Loc; } SourceLocation getUsedLocation() const { return Loc; }
SourceRange getSourceRange() const LLVM_READONLY { // Default argument expressions have no representation in the
// Default argument expressions have no representation in the // source, so they have an empty source range.
// source, so they have an empty source range. SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
return SourceRange(); SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
}
SourceLocation getExprLoc() const LLVM_READONLY { return Loc; } SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
@ -869,9 +875,10 @@ public:
Expr *getSubExpr() { return cast<Expr>(SubExpr); } Expr *getSubExpr() { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; } void setSubExpr(Expr *E) { SubExpr = E; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SubExpr->getSourceRange(); return SubExpr->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return SubExpr->getLocEnd();}
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1004,7 +1011,8 @@ public:
Args[Arg] = ArgExpr; Args[Arg] = ArgExpr;
} }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY;
SourceRange getParenRange() const { return ParenRange; } SourceRange getParenRange() const { return ParenRange; }
void setParenRange(SourceRange Range) { ParenRange = Range; } void setParenRange(SourceRange Range) { ParenRange = Range; }
@ -1060,9 +1068,9 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return TyBeginLoc; }
return SourceRange(TyBeginLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXFunctionalCastExprClass; return T->getStmtClass() == CXXFunctionalCastExprClass;
} }
@ -1099,7 +1107,8 @@ public:
TypeSourceInfo *getTypeSourceInfo() const { return Type; } TypeSourceInfo *getTypeSourceInfo() const { return Type; }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXTemporaryObjectExprClass; return T->getStmtClass() == CXXTemporaryObjectExprClass;
@ -1397,9 +1406,10 @@ public:
return T->getStmtClass() == LambdaExprClass; return T->getStmtClass() == LambdaExprClass;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(IntroducerRange.getBegin(), ClosingBrace); return IntroducerRange.getBegin();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return ClosingBrace; }
child_range children() { child_range children() {
return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1); return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1);
@ -1438,7 +1448,8 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXScalarValueInitExprClass; return T->getStmtClass() == CXXScalarValueInitExprClass;
@ -1625,6 +1636,8 @@ public:
SourceRange getSourceRange() const LLVM_READONLY { SourceRange getSourceRange() const LLVM_READONLY {
return Range; return Range;
} }
SourceLocation getLocStart() const LLVM_READONLY { return getStartLoc(); }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXNewExprClass; return T->getStmtClass() == CXXNewExprClass;
@ -1692,9 +1705,8 @@ public:
/// return an invalid type. /// return an invalid type.
QualType getDestroyedType() const; QualType getDestroyedType() const;
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
return SourceRange(Loc, Argument->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {return Argument->getLocEnd();}
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDeleteExprClass; return T->getStmtClass() == CXXDeleteExprClass;
@ -1882,7 +1894,8 @@ public:
DestroyedType = PseudoDestructorTypeStorage(Info); DestroyedType = PseudoDestructorTypeStorage(Info);
} }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY {return Base->getLocStart();}
SourceLocation getLocEnd() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXPseudoDestructorExprClass; return T->getStmtClass() == CXXPseudoDestructorExprClass;
@ -1929,7 +1942,8 @@ public:
: Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
QueriedType() { } QueriedType() { }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen);} SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); } UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
@ -1994,9 +2008,8 @@ public:
: Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
LhsType(), RhsType() { } LhsType(), RhsType() { }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
return SourceRange(Loc, RParen); SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
}
BinaryTypeTrait getTrait() const { BinaryTypeTrait getTrait() const {
return static_cast<BinaryTypeTrait>(BTT); return static_cast<BinaryTypeTrait>(BTT);
@ -2101,8 +2114,9 @@ public:
return getTypeSourceInfos() + getNumArgs(); return getTypeSourceInfos() + getNumArgs();
} }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParenLoc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == TypeTraitExprClass; return T->getStmtClass() == TypeTraitExprClass;
} }
@ -2163,9 +2177,8 @@ public:
virtual ~ArrayTypeTraitExpr() { } virtual ~ArrayTypeTraitExpr() { }
virtual SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
return SourceRange(Loc, RParen); SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
}
ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); } ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
@ -2225,9 +2238,8 @@ public:
: Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false), : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false),
QueriedExpression() { } QueriedExpression() { }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
return SourceRange(Loc, RParen); SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
}
ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); } ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
@ -2516,13 +2528,15 @@ public:
/// that was looked in to find these results. /// that was looked in to find these results.
CXXRecordDecl *getNamingClass() const { return NamingClass; } CXXRecordDecl *getNamingClass() const { return NamingClass; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
SourceRange Range(getNameInfo().getSourceRange()); if (NestedNameSpecifierLoc l = getQualifierLoc())
if (getQualifierLoc()) return l.getBeginLoc();
Range.setBegin(getQualifierLoc().getBeginLoc()); return getNameInfo().getLocStart();
}
SourceLocation getLocEnd() const LLVM_READONLY {
if (hasExplicitTemplateArgs()) if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc()); return getRAngleLoc();
return Range; return getNameInfo().getLocEnd();
} }
child_range children() { return child_range(); } child_range children() { return child_range(); }
@ -2670,11 +2684,13 @@ public:
return getExplicitTemplateArgs().NumTemplateArgs; return getExplicitTemplateArgs().NumTemplateArgs;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); return QualifierLoc.getBeginLoc();
}
SourceLocation getLocEnd() const LLVM_READONLY {
if (hasExplicitTemplateArgs()) if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc()); return getRAngleLoc();
return Range; return getLocation();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -2744,9 +2760,10 @@ public:
/// when modifying an existing AST to preserve its invariants. /// when modifying an existing AST to preserve its invariants.
void setSubExpr(Expr *E) { SubExpr = E; } void setSubExpr(Expr *E) { SubExpr = E; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SubExpr->getSourceRange(); return SubExpr->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return SubExpr->getLocEnd();}
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -2859,7 +2876,8 @@ public:
*(arg_begin() + I) = E; *(arg_begin() + I) = E;
} }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXUnresolvedConstructExprClass; return T->getStmtClass() == CXXUnresolvedConstructExprClass;
@ -3093,20 +3111,18 @@ public:
return getExplicitTemplateArgs().NumTemplateArgs; return getExplicitTemplateArgs().NumTemplateArgs;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
SourceRange Range;
if (!isImplicitAccess()) if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin()); return Base->getLocStart();
else if (getQualifier()) if (getQualifier())
Range.setBegin(getQualifierLoc().getBeginLoc()); return getQualifierLoc().getBeginLoc();
else return MemberNameInfo.getBeginLoc();
Range.setBegin(MemberNameInfo.getBeginLoc());
}
SourceLocation getLocEnd() const LLVM_READONLY {
if (hasExplicitTemplateArgs()) if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc()); return getRAngleLoc();
else return MemberNameInfo.getEndLoc();
Range.setEnd(MemberNameInfo.getEndLoc());
return Range;
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3230,16 +3246,17 @@ public:
// expression refers to. // expression refers to.
SourceLocation getMemberLoc() const { return getNameLoc(); } SourceLocation getMemberLoc() const { return getNameLoc(); }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
SourceRange Range = getMemberNameInfo().getSourceRange();
if (!isImplicitAccess()) if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin()); return Base->getLocStart();
else if (getQualifierLoc()) if (NestedNameSpecifierLoc l = getQualifierLoc())
Range.setBegin(getQualifierLoc().getBeginLoc()); return l.getBeginLoc();
return getMemberNameInfo().getLocStart();
}
SourceLocation getLocEnd() const LLVM_READONLY {
if (hasExplicitTemplateArgs()) if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc()); return getRAngleLoc();
return Range; return getMemberNameInfo().getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3281,6 +3298,8 @@ public:
Expr *getOperand() const { return static_cast<Expr*>(Operand); } Expr *getOperand() const { return static_cast<Expr*>(Operand); }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
bool getValue() const { return Value; } bool getValue() const { return Value; }
@ -3357,9 +3376,10 @@ public:
return llvm::Optional<unsigned>(); return llvm::Optional<unsigned>();
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(Pattern->getLocStart(), EllipsisLoc); return Pattern->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return EllipsisLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == PackExpansionExprClass; return T->getStmtClass() == PackExpansionExprClass;
@ -3462,9 +3482,8 @@ public:
return Length; return Length;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return OperatorLoc; }
return SourceRange(OperatorLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == SizeOfPackExprClass; return T->getStmtClass() == SizeOfPackExprClass;
@ -3504,7 +3523,8 @@ public:
Param(param), Replacement(replacement), NameLoc(loc) {} Param(param), Replacement(replacement), NameLoc(loc) {}
SourceLocation getNameLoc() const { return NameLoc; } SourceLocation getNameLoc() const { return NameLoc; }
SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; } SourceLocation getLocStart() const LLVM_READONLY { return NameLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return NameLoc; }
Expr *getReplacement() const { return cast<Expr>(Replacement); } Expr *getReplacement() const { return cast<Expr>(Replacement); }
@ -3565,7 +3585,8 @@ public:
/// template arguments. /// template arguments.
TemplateArgument getArgumentPack() const; TemplateArgument getArgumentPack() const;
SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; } SourceLocation getLocStart() const LLVM_READONLY { return NameLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return NameLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass; return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
@ -3632,7 +3653,8 @@ public:
/// \brief Get an expansion of the parameter pack by index. /// \brief Get an expansion of the parameter pack by index.
ParmVarDecl *getExpansion(unsigned I) const { return begin()[I]; } ParmVarDecl *getExpansion(unsigned I) const { return begin()[I]; }
SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; } SourceLocation getLocStart() const LLVM_READONLY { return NameLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return NameLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == FunctionParmPackExprClass; return T->getStmtClass() == FunctionParmPackExprClass;
@ -3688,8 +3710,11 @@ public:
return getValueKind() == VK_LValue; return getValueKind() == VK_LValue;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return Temporary->getSourceRange(); return Temporary->getLocStart();
}
SourceLocation getLocEnd() const LLVM_READONLY {
return Temporary->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {

Просмотреть файл

@ -44,9 +44,8 @@ public:
SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
return SourceRange(AtLoc, String->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return String->getLocEnd(); }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCStringLiteralClass; return T->getStmtClass() == ObjCStringLiteralClass;
@ -72,8 +71,9 @@ public:
bool getValue() const { return Value; } bool getValue() const { return Value; }
void setValue(bool V) { Value = V; } void setValue(bool V) { Value = V; }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -112,6 +112,8 @@ public:
SourceLocation getAtLoc() const { return Range.getBegin(); } SourceLocation getAtLoc() const { return Range.getBegin(); }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const LLVM_READONLY { SourceRange getSourceRange() const LLVM_READONLY {
return Range; return Range;
} }
@ -148,6 +150,8 @@ public:
static ObjCArrayLiteral *CreateEmpty(ASTContext &C, unsigned NumElements); static ObjCArrayLiteral *CreateEmpty(ASTContext &C, unsigned NumElements);
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -310,6 +314,8 @@ public:
ObjCMethodDecl *getDictWithObjectsMethod() const ObjCMethodDecl *getDictWithObjectsMethod() const
{ return DictWithObjectsMethod; } { return DictWithObjectsMethod; }
SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceRange getSourceRange() const LLVM_READONLY { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -360,9 +366,8 @@ public:
EncodedType = EncType; EncodedType = EncType;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
return SourceRange(AtLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCEncodeExprClass; return T->getStmtClass() == ObjCEncodeExprClass;
@ -393,9 +398,8 @@ public:
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
return SourceRange(AtLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
/// getNumArgs - Return the number of actual arguments to this call. /// getNumArgs - Return the number of actual arguments to this call.
unsigned getNumArgs() const { return SelName.getNumArgs(); } unsigned getNumArgs() const { return SelName.getNumArgs(); }
@ -433,9 +437,8 @@ public:
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
return SourceRange(AtLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCProtocolExprClass; return T->getStmtClass() == ObjCProtocolExprClass;
@ -485,10 +488,10 @@ 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 LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return isFreeIvar() ? SourceRange(Loc) return isFreeIvar() ? Loc : getBase()->getLocStart();
: SourceRange(getBase()->getLocStart(), Loc);
} }
SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCIvarRefExprClass; return T->getStmtClass() == ObjCIvarRefExprClass;
@ -697,11 +700,10 @@ public:
bool isSuperReceiver() const { return Receiver.is<const Type*>(); } bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); } bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange((isObjectReceiver() ? getBase()->getLocStart() return isObjectReceiver() ? getBase()->getLocStart() :getReceiverLocation();
: getReceiverLocation()),
IdLoc);
} }
SourceLocation getLocEnd() const LLVM_READONLY { return IdLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCPropertyRefExprClass; return T->getStmtClass() == ObjCPropertyRefExprClass;
@ -796,10 +798,12 @@ public:
SourceLocation getRBracket() const { return RBracket; } SourceLocation getRBracket() const { return RBracket; }
void setRBracket(SourceLocation RB) { RBracket = RB; } void setRBracket(SourceLocation RB) { RBracket = RB; }
SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(SubExprs[BASE]->getLocStart(), RBracket); SourceLocation getLocStart() const LLVM_READONLY {
return SubExprs[BASE]->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return RBracket; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCSubscriptRefExprClass; return T->getStmtClass() == ObjCSubscriptRefExprClass;
} }
@ -1335,9 +1339,8 @@ public:
LBracLoc = R.getBegin(); LBracLoc = R.getBegin();
RBracLoc = R.getEnd(); RBracLoc = R.getEnd();
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return LBracLoc; }
return SourceRange(LBracLoc, RBracLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RBracLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCMessageExprClass; return T->getStmtClass() == ObjCMessageExprClass;
@ -1397,9 +1400,10 @@ public:
SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return SourceRange(getBase()->getLocStart(), IsaMemberLoc); return getBase()->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return IsaMemberLoc; }
SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; } SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; }
@ -1469,9 +1473,11 @@ public:
child_range children() { return child_range(&Operand, &Operand+1); } child_range children() { return child_range(&Operand, &Operand+1); }
// Source locations are determined by the subexpression. // Source locations are determined by the subexpression.
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY {
return Operand->getSourceRange(); return Operand->getLocStart();
} }
SourceLocation getLocEnd() const LLVM_READONLY { return Operand->getLocEnd();}
SourceLocation getExprLoc() const LLVM_READONLY { SourceLocation getExprLoc() const LLVM_READONLY {
return getSubExpr()->getExprLoc(); return getSubExpr()->getExprLoc();
} }
@ -1520,8 +1526,9 @@ public:
/// \brief The location of the bridge keyword. /// \brief The location of the bridge keyword.
SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; } SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return LParenLoc; }
return SourceRange(LParenLoc, getSubExpr()->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return getSubExpr()->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {

Просмотреть файл

@ -463,9 +463,8 @@ public:
SourceLocation getEndLoc() const { return EndLoc; } SourceLocation getEndLoc() const { return EndLoc; }
void setEndLoc(SourceLocation L) { EndLoc = L; } void setEndLoc(SourceLocation L) { EndLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return StartLoc; }
return SourceRange(StartLoc, EndLoc); SourceLocation getLocEnd() const LLVM_READONLY { return EndLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == DeclStmtClass; return T->getStmtClass() == DeclStmtClass;
@ -519,7 +518,8 @@ public:
bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; } bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(SemiLoc); } SourceLocation getLocStart() const LLVM_READONLY { return SemiLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return SemiLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == NullStmtClass; return T->getStmtClass() == NullStmtClass;
@ -591,9 +591,8 @@ public:
return const_reverse_body_iterator(body_begin()); return const_reverse_body_iterator(body_begin());
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return LBracLoc; }
return SourceRange(LBracLoc, RBracLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RBracLoc; }
}
SourceLocation getLBracLoc() const { return LBracLoc; } SourceLocation getLBracLoc() const { return LBracLoc; }
void setLBracLoc(SourceLocation L) { LBracLoc = L; } void setLBracLoc(SourceLocation L) { LBracLoc = L; }
@ -635,7 +634,8 @@ public:
return const_cast<SwitchCase*>(this)->getSubStmt(); return const_cast<SwitchCase*>(this)->getSubStmt();
} }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); } SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CaseStmtClass || return T->getStmtClass() == CaseStmtClass ||
@ -688,15 +688,16 @@ public:
void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); } void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); } void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
SourceLocation getLocStart() const LLVM_READONLY { return CaseLoc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocEnd() const LLVM_READONLY {
// Handle deeply nested case statements with iteration instead of recursion. // Handle deeply nested case statements with iteration instead of recursion.
const CaseStmt *CS = this; const CaseStmt *CS = this;
while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt())) while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
CS = CS2; CS = CS2;
return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd()); return CS->getSubStmt()->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CaseStmtClass; return T->getStmtClass() == CaseStmtClass;
} }
@ -728,9 +729,9 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; } SourceLocation getColonLoc() const { return ColonLoc; }
void setColonLoc(SourceLocation L) { ColonLoc = L; } void setColonLoc(SourceLocation L) { ColonLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return DefaultLoc; }
return SourceRange(DefaultLoc, SubStmt->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == DefaultStmtClass; return T->getStmtClass() == DefaultStmtClass;
} }
@ -764,9 +765,9 @@ public:
void setIdentLoc(SourceLocation L) { IdentLoc = L; } void setIdentLoc(SourceLocation L) { IdentLoc = L; }
void setSubStmt(Stmt *SS) { SubStmt = SS; } void setSubStmt(Stmt *SS) { SubStmt = SS; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return IdentLoc; }
return SourceRange(IdentLoc, SubStmt->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
}
child_range children() { return child_range(&SubStmt, &SubStmt+1); } child_range children() { return child_range(&SubStmt, &SubStmt+1); }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -812,9 +813,9 @@ public:
Stmt *getSubStmt() { return SubStmt; } Stmt *getSubStmt() { return SubStmt; }
const Stmt *getSubStmt() const { return SubStmt; } const Stmt *getSubStmt() const { return SubStmt; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AttrLoc; }
return SourceRange(AttrLoc, SubStmt->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
}
child_range children() { return child_range(&SubStmt, &SubStmt + 1); } child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -872,11 +873,12 @@ public:
SourceLocation getElseLoc() const { return ElseLoc; } SourceLocation getElseLoc() const { return ElseLoc; }
void setElseLoc(SourceLocation L) { ElseLoc = L; } void setElseLoc(SourceLocation L) { ElseLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; }
SourceLocation getLocEnd() const LLVM_READONLY {
if (SubExprs[ELSE]) if (SubExprs[ELSE])
return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd()); return SubExprs[ELSE]->getLocEnd();
else else
return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd()); return SubExprs[THEN]->getLocEnd();
} }
// Iterators over subexpressions. The iterators will include iterating // Iterators over subexpressions. The iterators will include iterating
@ -970,9 +972,11 @@ public:
return (bool) AllEnumCasesCovered; return (bool) AllEnumCasesCovered;
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return SwitchLoc; }
return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
} }
// Iterators // Iterators
child_range children() { child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR); return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
@ -1024,9 +1028,11 @@ public:
SourceLocation getWhileLoc() const { return WhileLoc; } SourceLocation getWhileLoc() const { return WhileLoc; }
void setWhileLoc(SourceLocation L) { WhileLoc = L; } void setWhileLoc(SourceLocation L) { WhileLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return WhileLoc; }
return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == WhileStmtClass; return T->getStmtClass() == WhileStmtClass;
} }
@ -1072,9 +1078,9 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return DoLoc; }
return SourceRange(DoLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == DoStmtClass; return T->getStmtClass() == DoStmtClass;
} }
@ -1143,9 +1149,11 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return ForLoc; }
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ForStmtClass; return T->getStmtClass() == ForStmtClass;
} }
@ -1177,9 +1185,9 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; } SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; } void setLabelLoc(SourceLocation L) { LabelLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return GotoLoc; }
return SourceRange(GotoLoc, LabelLoc); SourceLocation getLocEnd() const LLVM_READONLY { return LabelLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == GotoStmtClass; return T->getStmtClass() == GotoStmtClass;
} }
@ -1220,9 +1228,8 @@ public:
return const_cast<IndirectGotoStmt*>(this)->getConstantTarget(); return const_cast<IndirectGotoStmt*>(this)->getConstantTarget();
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return GotoLoc; }
return SourceRange(GotoLoc, Target->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return Target->getLocEnd(); }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == IndirectGotoStmtClass; return T->getStmtClass() == IndirectGotoStmtClass;
@ -1246,9 +1253,8 @@ public:
SourceLocation getContinueLoc() const { return ContinueLoc; } SourceLocation getContinueLoc() const { return ContinueLoc; }
void setContinueLoc(SourceLocation L) { ContinueLoc = L; } void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return ContinueLoc; }
return SourceRange(ContinueLoc); SourceLocation getLocEnd() const LLVM_READONLY { return ContinueLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ContinueStmtClass; return T->getStmtClass() == ContinueStmtClass;
@ -1271,7 +1277,8 @@ public:
SourceLocation getBreakLoc() const { return BreakLoc; } SourceLocation getBreakLoc() const { return BreakLoc; }
void setBreakLoc(SourceLocation L) { BreakLoc = L; } void setBreakLoc(SourceLocation L) { BreakLoc = L; }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BreakLoc); } SourceLocation getLocStart() const LLVM_READONLY { return BreakLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return BreakLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == BreakStmtClass; return T->getStmtClass() == BreakStmtClass;
@ -1322,7 +1329,10 @@ public:
const VarDecl *getNRVOCandidate() const { return NRVOCandidate; } const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; } void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY { return RetLoc; }
SourceLocation getLocEnd() const LLVM_READONLY {
return RetExpr ? RetExpr->getLocEnd() : RetLoc;
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ReturnStmtClass; return T->getStmtClass() == ReturnStmtClass;
@ -1374,7 +1384,8 @@ public:
bool isVolatile() const { return IsVolatile; } bool isVolatile() const { return IsVolatile; }
void setVolatile(bool V) { IsVolatile = V; } void setVolatile(bool V) { IsVolatile = V; }
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); } SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
//===--- Asm String Analysis ---===// //===--- Asm String Analysis ---===//
@ -1629,9 +1640,8 @@ public:
return Clobbers[i]; return Clobbers[i];
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AsmLoc; }
return SourceRange(AsmLoc, RParenLoc); SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == GCCAsmStmtClass; return T->getStmtClass() == GCCAsmStmtClass;
@ -1710,9 +1720,9 @@ public:
StringRef getClobber(unsigned i) const { return Clobbers[i]; } StringRef getClobber(unsigned i) const { return Clobbers[i]; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AsmLoc; }
return SourceRange(AsmLoc, EndLoc); SourceLocation getLocEnd() const LLVM_READONLY { return EndLoc; }
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == MSAsmStmtClass; return T->getStmtClass() == MSAsmStmtClass;
} }
@ -1741,9 +1751,9 @@ public:
SourceLocation ExceptLoc, SourceLocation ExceptLoc,
Expr *FilterExpr, Expr *FilterExpr,
Stmt *Block); Stmt *Block);
SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getExceptLoc(), getEndLoc()); SourceLocation getLocStart() const LLVM_READONLY { return getExceptLoc(); }
} SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getExceptLoc() const { return Loc; } SourceLocation getExceptLoc() const { return Loc; }
SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); } SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); }
@ -1782,9 +1792,8 @@ public:
SourceLocation FinallyLoc, SourceLocation FinallyLoc,
Stmt *Block); Stmt *Block);
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return getFinallyLoc(); }
return SourceRange(getFinallyLoc(), getEndLoc()); SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
}
SourceLocation getFinallyLoc() const { return Loc; } SourceLocation getFinallyLoc() const { return Loc; }
SourceLocation getEndLoc() const { return Block->getLocEnd(); } SourceLocation getEndLoc() const { return Block->getLocEnd(); }
@ -1824,9 +1833,8 @@ public:
Stmt *TryBlock, Stmt *TryBlock,
Stmt *Handler); Stmt *Handler);
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return getTryLoc(); }
return SourceRange(getTryLoc(), getEndLoc()); SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
}
SourceLocation getTryLoc() const { return TryLoc; } SourceLocation getTryLoc() const { return TryLoc; }
SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); } SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); }

Просмотреть файл

@ -38,8 +38,9 @@ public:
CXXCatchStmt(EmptyShell Empty) CXXCatchStmt(EmptyShell Empty)
: Stmt(CXXCatchStmtClass), ExceptionDecl(0), HandlerBlock(0) {} : Stmt(CXXCatchStmtClass), ExceptionDecl(0), HandlerBlock(0) {}
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return CatchLoc; }
return SourceRange(CatchLoc, HandlerBlock->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return HandlerBlock->getLocEnd();
} }
SourceLocation getCatchLoc() const { return CatchLoc; } SourceLocation getCatchLoc() const { return CatchLoc; }
@ -83,9 +84,8 @@ public:
static CXXTryStmt *Create(ASTContext &C, EmptyShell Empty, static CXXTryStmt *Create(ASTContext &C, EmptyShell Empty,
unsigned numHandlers); unsigned numHandlers);
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return getTryLoc(); }
return SourceRange(getTryLoc(), getEndLoc()); SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
}
SourceLocation getTryLoc() const { return TryLoc; } SourceLocation getTryLoc() const { return TryLoc; }
SourceLocation getEndLoc() const { SourceLocation getEndLoc() const {
@ -188,9 +188,11 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return ForLoc; }
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXForRangeStmtClass; return T->getStmtClass() == CXXForRangeStmtClass;
} }
@ -272,9 +274,8 @@ public:
return reinterpret_cast<CompoundStmt *>(SubStmt); return reinterpret_cast<CompoundStmt *>(SubStmt);
} }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return KeywordLoc; }
return SourceRange(KeywordLoc, SubStmt->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
}
child_range children() { child_range children() {
return child_range(&SubStmt, &SubStmt+1); return child_range(&SubStmt, &SubStmt+1);

Просмотреть файл

@ -55,9 +55,11 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return ForLoc; }
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCForCollectionStmtClass; return T->getStmtClass() == ObjCForCollectionStmtClass;
} }
@ -102,9 +104,8 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtCatchLoc; }
return SourceRange(AtCatchLoc, Body->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return Body->getLocEnd(); }
}
bool hasEllipsis() const { return getCatchParamDecl() == 0; } bool hasEllipsis() const { return getCatchParamDecl() == 0; }
@ -131,8 +132,9 @@ public:
Stmt *getFinallyBody() { return AtFinallyStmt; } Stmt *getFinallyBody() { return AtFinallyStmt; }
void setFinallyBody(Stmt *S) { AtFinallyStmt = S; } void setFinallyBody(Stmt *S) { AtFinallyStmt = S; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtFinallyLoc; }
return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return AtFinallyStmt->getLocEnd();
} }
SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; } SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; }
@ -236,7 +238,8 @@ public:
getStmts()[1 + NumCatchStmts] = S; getStmts()[1 + NumCatchStmts] = S;
} }
SourceRange getSourceRange() const LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY { return AtTryLoc; }
SourceLocation getLocEnd() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtTryStmtClass; return T->getStmtClass() == ObjCAtTryStmtClass;
@ -292,8 +295,9 @@ public:
} }
void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; } void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtSynchronizedLoc; }
return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY {
return getSynchBody()->getLocEnd();
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -324,11 +328,9 @@ public:
SourceLocation getThrowLoc() { return AtThrowLoc; } SourceLocation getThrowLoc() { return AtThrowLoc; }
void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; } void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtThrowLoc; }
if (Throw) SourceLocation getLocEnd() const LLVM_READONLY {
return SourceRange(AtThrowLoc, Throw->getLocEnd()); return Throw ? Throw->getLocEnd() : AtThrowLoc;
else
return SourceRange(AtThrowLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -355,9 +357,8 @@ public:
Stmt *getSubStmt() { return SubStmt; } Stmt *getSubStmt() { return SubStmt; }
void setSubStmt(Stmt *S) { SubStmt = S; } void setSubStmt(Stmt *S) { SubStmt = S; }
SourceRange getSourceRange() const LLVM_READONLY { SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
return SourceRange(AtLoc, SubStmt->getLocEnd()); SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
}
SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }

Просмотреть файл

@ -445,14 +445,6 @@ DeclRefExpr *DeclRefExpr::CreateEmpty(ASTContext &Context,
return new (Mem) DeclRefExpr(EmptyShell()); return new (Mem) DeclRefExpr(EmptyShell());
} }
SourceRange DeclRefExpr::getSourceRange() const {
SourceRange R = getNameInfo().getSourceRange();
if (hasQualifier())
R.setBegin(getQualifierLoc().getBeginLoc());
if (hasExplicitTemplateArgs())
R.setEnd(getRAngleLoc());
return R;
}
SourceLocation DeclRefExpr::getLocStart() const { SourceLocation DeclRefExpr::getLocStart() const {
if (hasQualifier()) if (hasQualifier())
return getQualifierLoc().getBeginLoc(); return getQualifierLoc().getBeginLoc();
@ -1159,21 +1151,9 @@ QualType CallExpr::getCallReturnType() const {
return FnType->getResultType(); 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);
}
SourceLocation CallExpr::getLocStart() const { SourceLocation CallExpr::getLocStart() const {
if (isa<CXXOperatorCallExpr>(this)) if (isa<CXXOperatorCallExpr>(this))
return cast<CXXOperatorCallExpr>(this)->getSourceRange().getBegin(); return cast<CXXOperatorCallExpr>(this)->getLocStart();
SourceLocation begin = getCallee()->getLocStart(); SourceLocation begin = getCallee()->getLocStart();
if (begin.isInvalid() && getNumArgs() > 0) if (begin.isInvalid() && getNumArgs() > 0)
@ -1182,7 +1162,7 @@ SourceLocation CallExpr::getLocStart() const {
} }
SourceLocation CallExpr::getLocEnd() const { SourceLocation CallExpr::getLocEnd() const {
if (isa<CXXOperatorCallExpr>(this)) if (isa<CXXOperatorCallExpr>(this))
return cast<CXXOperatorCallExpr>(this)->getSourceRange().getEnd(); return cast<CXXOperatorCallExpr>(this)->getLocEnd();
SourceLocation end = getRParenLoc(); SourceLocation end = getRParenLoc();
if (end.isInvalid() && getNumArgs() > 0) if (end.isInvalid() && getNumArgs() > 0)
@ -1310,9 +1290,6 @@ MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow,
return E; return E;
} }
SourceRange MemberExpr::getSourceRange() const {
return SourceRange(getLocStart(), getLocEnd());
}
SourceLocation MemberExpr::getLocStart() const { SourceLocation MemberExpr::getLocStart() const {
if (isImplicitAccess()) { if (isImplicitAccess()) {
if (hasQualifier()) if (hasQualifier())
@ -1808,10 +1785,10 @@ bool InitListExpr::isStringLiteralInit() const {
return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init); return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
} }
SourceRange InitListExpr::getSourceRange() const { SourceLocation InitListExpr::getLocStart() const {
if (InitListExpr *SyntacticForm = getSyntacticForm()) if (InitListExpr *SyntacticForm = getSyntacticForm())
return SyntacticForm->getSourceRange(); return SyntacticForm->getLocStart();
SourceLocation Beg = LBraceLoc, End = RBraceLoc; SourceLocation Beg = LBraceLoc;
if (Beg.isInvalid()) { if (Beg.isInvalid()) {
// Find the first non-null initializer. // Find the first non-null initializer.
for (InitExprsTy::const_iterator I = InitExprs.begin(), for (InitExprsTy::const_iterator I = InitExprs.begin(),
@ -1823,18 +1800,25 @@ SourceRange InitListExpr::getSourceRange() const {
} }
} }
} }
return Beg;
}
SourceLocation InitListExpr::getLocEnd() const {
if (InitListExpr *SyntacticForm = getSyntacticForm())
return SyntacticForm->getLocEnd();
SourceLocation End = RBraceLoc;
if (End.isInvalid()) { if (End.isInvalid()) {
// Find the first non-null initializer from the end. // Find the first non-null initializer from the end.
for (InitExprsTy::const_reverse_iterator I = InitExprs.rbegin(), for (InitExprsTy::const_reverse_iterator I = InitExprs.rbegin(),
E = InitExprs.rend(); E = InitExprs.rend();
I != E; ++I) { I != E; ++I) {
if (Stmt *S = *I) { if (Stmt *S = *I) {
End = S->getSourceRange().getEnd(); End = S->getLocEnd();
break; break;
} }
} }
} }
return SourceRange(Beg, End); return End;
} }
/// getFunctionType - Return the underlying function type for this block. /// getFunctionType - Return the underlying function type for this block.
@ -3684,11 +3668,11 @@ SourceRange DesignatedInitExpr::getDesignatorsSourceRange() const {
DesignatedInitExpr *DIE = const_cast<DesignatedInitExpr*>(this); DesignatedInitExpr *DIE = const_cast<DesignatedInitExpr*>(this);
if (size() == 1) if (size() == 1)
return DIE->getDesignator(0)->getSourceRange(); return DIE->getDesignator(0)->getSourceRange();
return SourceRange(DIE->getDesignator(0)->getStartLocation(), return SourceRange(DIE->getDesignator(0)->getLocStart(),
DIE->getDesignator(size()-1)->getEndLocation()); DIE->getDesignator(size()-1)->getLocEnd());
} }
SourceRange DesignatedInitExpr::getSourceRange() const { SourceLocation DesignatedInitExpr::getLocStart() const {
SourceLocation StartLoc; SourceLocation StartLoc;
Designator &First = Designator &First =
*const_cast<DesignatedInitExpr*>(this)->designators_begin(); *const_cast<DesignatedInitExpr*>(this)->designators_begin();
@ -3700,7 +3684,11 @@ SourceRange DesignatedInitExpr::getSourceRange() const {
} else } else
StartLoc = StartLoc =
SourceLocation::getFromRawEncoding(First.ArrayOrRange.LBracketLoc); SourceLocation::getFromRawEncoding(First.ArrayOrRange.LBracketLoc);
return SourceRange(StartLoc, getInit()->getSourceRange().getEnd()); return StartLoc;
}
SourceLocation DesignatedInitExpr::getLocEnd() const {
return getInit()->getLocEnd();
} }
Expr *DesignatedInitExpr::getArrayIndex(const Designator& D) { Expr *DesignatedInitExpr::getArrayIndex(const Designator& D) {

Просмотреть файл

@ -73,11 +73,8 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT) {
} }
// CXXScalarValueInitExpr // CXXScalarValueInitExpr
SourceRange CXXScalarValueInitExpr::getSourceRange() const { SourceLocation CXXScalarValueInitExpr::getLocStart() const {
SourceLocation Start = RParenLoc; return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc;
if (TypeInfo)
Start = TypeInfo->getTypeLoc().getBeginLoc();
return SourceRange(Start, RParenLoc);
} }
// CXXNewExpr // CXXNewExpr
@ -218,11 +215,11 @@ QualType CXXPseudoDestructorExpr::getDestroyedType() const {
return QualType(); return QualType();
} }
SourceRange CXXPseudoDestructorExpr::getSourceRange() const { SourceLocation CXXPseudoDestructorExpr::getLocEnd() const {
SourceLocation End = DestroyedType.getLocation(); SourceLocation End = DestroyedType.getLocation();
if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); End = TInfo->getTypeLoc().getLocalSourceRange().getEnd();
return SourceRange(Base->getLocStart(), End); return End;
} }
// UnresolvedLookupExpr // UnresolvedLookupExpr
@ -420,12 +417,18 @@ DependentScopeDeclRefExpr::CreateEmpty(ASTContext &C,
return E; return E;
} }
SourceRange CXXConstructExpr::getSourceRange() const { SourceLocation CXXConstructExpr::getLocStart() const {
if (isa<CXXTemporaryObjectExpr>(this)) if (isa<CXXTemporaryObjectExpr>(this))
return cast<CXXTemporaryObjectExpr>(this)->getSourceRange(); return cast<CXXTemporaryObjectExpr>(this)->getLocStart();
return Loc;
}
SourceLocation CXXConstructExpr::getLocEnd() const {
if (isa<CXXTemporaryObjectExpr>(this))
return cast<CXXTemporaryObjectExpr>(this)->getLocEnd();
if (ParenRange.isValid()) if (ParenRange.isValid())
return SourceRange(Loc, ParenRange.getEnd()); return ParenRange.getEnd();
SourceLocation End = Loc; SourceLocation End = Loc;
for (unsigned I = getNumArgs(); I > 0; --I) { for (unsigned I = getNumArgs(); I > 0; --I) {
@ -439,7 +442,7 @@ SourceRange CXXConstructExpr::getSourceRange() const {
} }
} }
return SourceRange(Loc, End); return End;
} }
SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const { SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
@ -729,9 +732,12 @@ CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
Type(Type) { Type(Type) {
} }
SourceRange CXXTemporaryObjectExpr::getSourceRange() const { SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
return SourceRange(Type->getTypeLoc().getBeginLoc(), return Type->getTypeLoc().getBeginLoc();
getParenRange().getEnd()); }
SourceLocation CXXTemporaryObjectExpr::getLocEnd() const {
return getParenRange().getEnd();
} }
CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T, CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
@ -1060,8 +1066,8 @@ CXXUnresolvedConstructExpr::CreateEmpty(ASTContext &C, unsigned NumArgs) {
return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs);
} }
SourceRange CXXUnresolvedConstructExpr::getSourceRange() const { SourceLocation CXXUnresolvedConstructExpr::getLocStart() const {
return SourceRange(Type->getTypeLoc().getBeginLoc(), RParenLoc); return Type->getTypeLoc().getBeginLoc();
} }
CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C, CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C,

Просмотреть файл

@ -142,18 +142,28 @@ namespace {
return bad(); return bad();
} }
typedef SourceRange getSourceRange_t() const; typedef SourceLocation getLocStart_t() const;
template <class T> good implements_getSourceRange(getSourceRange_t T::*) { template <class T> good implements_getLocStart(getLocStart_t T::*) {
return good(); return good();
} }
static inline bad implements_getSourceRange(getSourceRange_t Stmt::*) { static inline bad implements_getLocStart(getLocStart_t Stmt::*) {
return bad();
}
typedef SourceLocation getLocEnd_t() const;
template <class T> good implements_getLocEnd(getLocEnd_t T::*) {
return good();
}
static inline bad implements_getLocEnd(getLocEnd_t Stmt::*) {
return bad(); return bad();
} }
#define ASSERT_IMPLEMENTS_children(type) \ #define ASSERT_IMPLEMENTS_children(type) \
(void) sizeof(is_good(implements_children(&type::children))) (void) sizeof(is_good(implements_children(&type::children)))
#define ASSERT_IMPLEMENTS_getSourceRange(type) \ #define ASSERT_IMPLEMENTS_getLocStart(type) \
(void) sizeof(is_good(implements_getSourceRange(&type::getSourceRange))) (void) sizeof(is_good(implements_getLocStart(&type::getLocStart)))
#define ASSERT_IMPLEMENTS_getLocEnd(type) \
(void) sizeof(is_good(implements_getLocEnd(&type::getLocEnd)))
} }
/// Check whether the various Stmt classes implement their member /// Check whether the various Stmt classes implement their member
@ -162,7 +172,8 @@ static inline void check_implementations() {
#define ABSTRACT_STMT(type) #define ABSTRACT_STMT(type)
#define STMT(type, base) \ #define STMT(type, base) \
ASSERT_IMPLEMENTS_children(type); \ ASSERT_IMPLEMENTS_children(type); \
ASSERT_IMPLEMENTS_getSourceRange(type); ASSERT_IMPLEMENTS_getLocStart(type); \
ASSERT_IMPLEMENTS_getLocEnd(type);
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
@ -178,67 +189,51 @@ Stmt::child_range Stmt::children() {
llvm_unreachable("unknown statement kind!"); llvm_unreachable("unknown statement kind!");
} }
// Amusing macro metaprogramming hack: check whether a class provides
// a more specific implementation of getSourceRange.
//
// See also Expr.cpp:getExprLoc().
namespace {
/// This implementation is used when a class provides a custom
/// implementation of getSourceRange.
template <class S, class T>
SourceRange getSourceRangeImpl(const Stmt *stmt,
SourceRange (T::*v)() const) {
return static_cast<const S*>(stmt)->getSourceRange();
}
/// This implementation is used when a class doesn't provide a custom
/// implementation of getSourceRange. Overload resolution should pick it over
/// the implementation above because it's more specialized according to
/// function template partial ordering.
template <class S>
SourceRange getSourceRangeImpl(const Stmt *stmt,
SourceRange (Stmt::*v)() const) {
return SourceRange(static_cast<const S*>(stmt)->getLocStart(),
static_cast<const S*>(stmt)->getLocEnd());
}
}
SourceRange Stmt::getSourceRange() const { SourceRange Stmt::getSourceRange() const {
switch (getStmtClass()) { switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class"); case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type) #define ABSTRACT_STMT(type)
#define STMT(type, base) \ #define STMT(type, base) \
case Stmt::type##Class: \ case Stmt::type##Class: \
return static_cast<const type*>(this)->getSourceRange(); return getSourceRangeImpl<type>(this, &type::getSourceRange);
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
llvm_unreachable("unknown statement kind!"); llvm_unreachable("unknown statement kind!");
} }
// Amusing macro metaprogramming hack: check whether a class provides
// a more specific implementation of getLocStart() and getLocEnd().
//
// See also Expr.cpp:getExprLoc().
namespace {
/// This implementation is used when a class provides a custom
/// implementation of getLocStart.
template <class S, class T>
SourceLocation getLocStartImpl(const Stmt *stmt,
SourceLocation (T::*v)() const) {
return static_cast<const S*>(stmt)->getLocStart();
}
/// This implementation is used when a class doesn't provide a custom
/// implementation of getLocStart. Overload resolution should pick it over
/// the implementation above because it's more specialized according to
/// function template partial ordering.
template <class S>
SourceLocation getLocStartImpl(const Stmt *stmt,
SourceLocation (Stmt::*v)() const) {
return static_cast<const S*>(stmt)->getSourceRange().getBegin();
}
/// This implementation is used when a class provides a custom
/// implementation of getLocEnd.
template <class S, class T>
SourceLocation getLocEndImpl(const Stmt *stmt,
SourceLocation (T::*v)() const) {
return static_cast<const S*>(stmt)->getLocEnd();
}
/// This implementation is used when a class doesn't provide a custom
/// implementation of getLocEnd. Overload resolution should pick it over
/// the implementation above because it's more specialized according to
/// function template partial ordering.
template <class S>
SourceLocation getLocEndImpl(const Stmt *stmt,
SourceLocation (Stmt::*v)() const) {
return static_cast<const S*>(stmt)->getSourceRange().getEnd();
}
}
SourceLocation Stmt::getLocStart() const { SourceLocation Stmt::getLocStart() const {
// llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
switch (getStmtClass()) { switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class"); case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type) #define ABSTRACT_STMT(type)
#define STMT(type, base) \ #define STMT(type, base) \
case Stmt::type##Class: \ case Stmt::type##Class: \
return getLocStartImpl<type>(this, &type::getLocStart); return static_cast<const type*>(this)->getLocStart();
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
llvm_unreachable("unknown statement kind"); llvm_unreachable("unknown statement kind");
@ -250,7 +245,7 @@ SourceLocation Stmt::getLocEnd() const {
#define ABSTRACT_STMT(type) #define ABSTRACT_STMT(type)
#define STMT(type, base) \ #define STMT(type, base) \
case Stmt::type##Class: \ case Stmt::type##Class: \
return getLocEndImpl<type>(this, &type::getLocEnd); return static_cast<const type*>(this)->getLocEnd();
#include "clang/AST/StmtNodes.inc" #include "clang/AST/StmtNodes.inc"
} }
llvm_unreachable("unknown statement kind"); llvm_unreachable("unknown statement kind");
@ -302,14 +297,6 @@ AttributedStmt *AttributedStmt::CreateEmpty(ASTContext &C, unsigned NumAttrs) {
return new (Mem) AttributedStmt(EmptyShell(), NumAttrs); return new (Mem) AttributedStmt(EmptyShell(), NumAttrs);
} }
// This is defined here to avoid polluting Stmt.h with importing Expr.h
SourceRange ReturnStmt::getSourceRange() const {
if (RetExpr)
return SourceRange(RetLoc, RetExpr->getLocEnd());
else
return SourceRange(RetLoc);
}
bool Stmt::hasImplicitControlFlow() const { bool Stmt::hasImplicitControlFlow() const {
switch (StmtBits.sClass) { switch (StmtBits.sClass) {
default: default:
@ -773,16 +760,12 @@ ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(ASTContext &Context,
return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally); return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
} }
SourceRange ObjCAtTryStmt::getSourceRange() const { SourceLocation ObjCAtTryStmt::getLocEnd() const {
SourceLocation EndLoc;
if (HasFinally) if (HasFinally)
EndLoc = getFinallyStmt()->getLocEnd(); return getFinallyStmt()->getLocEnd();
else if (NumCatchStmts) if (NumCatchStmts)
EndLoc = getCatchStmt(NumCatchStmts - 1)->getLocEnd(); return getCatchStmt(NumCatchStmts - 1)->getLocEnd();
else return getTryBody()->getLocEnd();
EndLoc = getTryBody()->getLocEnd();
return SourceRange(AtTryLoc, EndLoc);
} }
CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc, CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc,

Просмотреть файл

@ -511,8 +511,14 @@ void JumpScopeChecker::VerifyJumps() {
for (SwitchCase *SC = SS->getSwitchCaseList(); SC; for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase()) { SC = SC->getNextSwitchCase()) {
assert(LabelAndGotoScopes.count(SC) && "Case not visited?"); assert(LabelAndGotoScopes.count(SC) && "Case not visited?");
CheckJump(SS, SC, SC->getLocStart(), SourceLocation Loc;
diag::err_switch_into_protected_scope, 0, if (CaseStmt *CS = dyn_cast<CaseStmt>(SC))
Loc = CS->getLocStart();
else if (DefaultStmt *DS = dyn_cast<DefaultStmt>(SC))
Loc = DS->getLocStart();
else
Loc = SC->getLocStart();
CheckJump(SS, SC, Loc, diag::err_switch_into_protected_scope, 0,
diag::warn_cxx98_compat_switch_into_protected_scope); diag::warn_cxx98_compat_switch_into_protected_scope);
} }
} }

Просмотреть файл

@ -1632,8 +1632,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
StructuredList = IsFirstDesignator? SyntacticToSemantic.lookup(IList) StructuredList = IsFirstDesignator? SyntacticToSemantic.lookup(IList)
: getStructuredSubobjectInit(IList, Index, CurrentObjectType, : getStructuredSubobjectInit(IList, Index, CurrentObjectType,
StructuredList, StructuredIndex, StructuredList, StructuredIndex,
SourceRange(D->getStartLocation(), SourceRange(D->getLocStart(),
DIE->getSourceRange().getEnd())); DIE->getLocEnd()));
assert(StructuredList && "Expected a structured initializer list"); assert(StructuredList && "Expected a structured initializer list");
} }
@ -1801,10 +1801,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
if (!VerifyOnly) { if (!VerifyOnly) {
DesignatedInitExpr::Designator *NextD DesignatedInitExpr::Designator *NextD
= DIE->getDesignator(DesigIdx + 1); = DIE->getDesignator(DesigIdx + 1);
SemaRef.Diag(NextD->getStartLocation(), SemaRef.Diag(NextD->getLocStart(),
diag::err_designator_into_flexible_array_member) diag::err_designator_into_flexible_array_member)
<< SourceRange(NextD->getStartLocation(), << SourceRange(NextD->getLocStart(),
DIE->getSourceRange().getEnd()); DIE->getLocEnd());
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member) SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
<< *Field; << *Field;
} }