Convert more statments over to SourceRanges...

llvm-svn: 41666
This commit is contained in:
Steve Naroff 2007-08-31 23:49:30 +00:00
parent 689d17d282
commit dc9f36e6c4
3 changed files with 33 additions and 17 deletions

View File

@ -81,6 +81,14 @@ const char *LabelStmt::getName() const {
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
//===----------------------------------------------------------------------===//

View File

@ -506,7 +506,7 @@ Sema::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
if (LabelDecl == 0)
LabelDecl = new LabelStmt(LabelLoc, LabelII, 0);
return new GotoStmt(LabelDecl);
return new GotoStmt(LabelDecl, GotoLoc);
}
Action::StmtResult
@ -526,7 +526,7 @@ Sema::ParseContinueStmt(SourceLocation ContinueLoc, Scope *CurScope) {
return true;
}
return new ContinueStmt();
return new ContinueStmt(ContinueLoc);
}
Action::StmtResult
@ -538,7 +538,7 @@ Sema::ParseBreakStmt(SourceLocation BreakLoc, Scope *CurScope) {
return true;
}
return new BreakStmt();
return new BreakStmt(BreakLoc);
}
@ -552,7 +552,7 @@ Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
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();
@ -560,7 +560,7 @@ Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
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
@ -608,6 +608,6 @@ Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
if (RetValExp) CheckReturnStackAddr(RetValExp, lhsType, ReturnLoc);
return new ReturnStmt((Expr*)RetValExp);
return new ReturnStmt(ReturnLoc, (Expr*)RetValExp);
}

View File

@ -153,7 +153,7 @@ public:
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;
@ -520,13 +520,16 @@ public:
///
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;
}
@ -563,11 +566,13 @@ public:
/// 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;
}
@ -581,10 +586,11 @@ public:
/// 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;
@ -601,13 +607,15 @@ public:
///
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;