return getID()->getName();
}
+// 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);
+}
+
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
if (LabelDecl == 0)
LabelDecl = new LabelStmt(LabelLoc, LabelII, 0);
- return new GotoStmt(LabelDecl);
+ return new GotoStmt(LabelDecl, GotoLoc);
}
Action::StmtResult
return true;
}
- return new ContinueStmt();
+ return new ContinueStmt(ContinueLoc);
}
Action::StmtResult
return true;
}
- return new BreakStmt();
+ return new BreakStmt(BreakLoc);
}
Diag(ReturnLoc, diag::ext_return_has_expr,
CurFunctionDecl->getIdentifier()->getName(),
RetValExp->getSourceRange());
- return new ReturnStmt(RetValExp);
+ return new ReturnStmt(ReturnLoc, RetValExp);
} else {
if (!RetValExp) {
const char *funcName = CurFunctionDecl->getIdentifier()->getName();
Diag(ReturnLoc, diag::ext_return_missing_expr, funcName);
else // C90 6.6.6.4p4
Diag(ReturnLoc, diag::warn_return_missing_expr, funcName);
- return new ReturnStmt((Expr*)0);
+ return new ReturnStmt(ReturnLoc, (Expr*)0);
}
}
// we have a non-void function with an expression, continue checking
if (RetValExp) CheckReturnStackAddr(RetValExp, lhsType, ReturnLoc);
- return new ReturnStmt((Expr*)RetValExp);
+ return new ReturnStmt(ReturnLoc, (Expr*)RetValExp);
}
SourceLocation getSemiLoc() const { return SemiLoc; }
- virtual SourceRange getSourceRange() const { return SourceRange(); }
+ virtual SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == NullStmtClass;
///
class GotoStmt : public Stmt {
LabelStmt *Label;
+ SourceLocation GotoLoc;
public:
- GotoStmt(LabelStmt *label) : Stmt(GotoStmtClass), Label(label) {}
+ GotoStmt(LabelStmt *label, SourceLocation GL) : Stmt(GotoStmtClass),
+ Label(label), GotoLoc(GL) {}
LabelStmt *getLabel() const { return Label; }
- virtual SourceRange getSourceRange() const { return SourceRange(); }
-
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(GotoLoc, Label->getLocEnd());
+ }
static bool classof(const Stmt *T) {
return T->getStmtClass() == GotoStmtClass;
}
/// ContinueStmt - This represents a continue.
///
class ContinueStmt : public Stmt {
+ SourceLocation ContinueLoc;
public:
- ContinueStmt() : Stmt(ContinueStmtClass) {}
+ ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
- virtual SourceRange getSourceRange() const { return SourceRange(); }
-
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(ContinueLoc);
+ }
static bool classof(const Stmt *T) {
return T->getStmtClass() == ContinueStmtClass;
}
/// BreakStmt - This represents a break.
///
class BreakStmt : public Stmt {
+ SourceLocation BreakLoc;
public:
- BreakStmt() : Stmt(BreakStmtClass) {}
+ BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {}
- virtual SourceRange getSourceRange() const { return SourceRange(); }
+ virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == BreakStmtClass;
///
class ReturnStmt : public Stmt {
Expr *RetExpr;
+ SourceLocation RetLoc;
public:
- ReturnStmt(Expr *E = 0) : Stmt(ReturnStmtClass), RetExpr(E) {}
+ ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass),
+ RetExpr(E), RetLoc(RL) {}
const Expr *getRetValue() const { return RetExpr; }
Expr *getRetValue() { return RetExpr; }
- virtual SourceRange getSourceRange() const { return SourceRange(); }
+ virtual SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == ReturnStmtClass;