[cfe-commits] r41666 - in /cfe/trunk: AST/Stmt.cpp Sema/SemaStmt.cpp include/clang/AST/Stmt.h
Steve Naroff
snaroff at apple.com
Fri Aug 31 16:49:35 PDT 2007
Author: snaroff
Date: Fri Aug 31 18:49:30 2007
New Revision: 41666
URL: http://llvm.org/viewvc/llvm-project?rev=41666&view=rev
Log:
Convert more statments over to SourceRanges...
Modified:
cfe/trunk/AST/Stmt.cpp
cfe/trunk/Sema/SemaStmt.cpp
cfe/trunk/include/clang/AST/Stmt.h
Modified: cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Stmt.cpp?rev=41666&r1=41665&r2=41666&view=diff
==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Fri Aug 31 18:49:30 2007
@@ -81,6 +81,14 @@
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
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=41666&r1=41665&r2=41666&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Fri Aug 31 18:49:30 2007
@@ -506,7 +506,7 @@
if (LabelDecl == 0)
LabelDecl = new LabelStmt(LabelLoc, LabelII, 0);
- return new GotoStmt(LabelDecl);
+ return new GotoStmt(LabelDecl, GotoLoc);
}
Action::StmtResult
@@ -526,7 +526,7 @@
return true;
}
- return new ContinueStmt();
+ return new ContinueStmt(ContinueLoc);
}
Action::StmtResult
@@ -538,7 +538,7 @@
return true;
}
- return new BreakStmt();
+ return new BreakStmt(BreakLoc);
}
@@ -552,7 +552,7 @@
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 @@
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 @@
if (RetValExp) CheckReturnStackAddr(RetValExp, lhsType, ReturnLoc);
- return new ReturnStmt((Expr*)RetValExp);
+ return new ReturnStmt(ReturnLoc, (Expr*)RetValExp);
}
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=41666&r1=41665&r2=41666&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Aug 31 18:49:30 2007
@@ -153,7 +153,7 @@
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 @@
///
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 @@
/// 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 @@
/// 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 @@
///
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;
More information about the cfe-commits
mailing list