summaryrefslogtreecommitdiff
path: root/include/clang/AST/StmtCXX.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/StmtCXX.h')
-rw-r--r--include/clang/AST/StmtCXX.h56
1 files changed, 30 insertions, 26 deletions
diff --git a/include/clang/AST/StmtCXX.h b/include/clang/AST/StmtCXX.h
index 34553741eb38..d3a3cf783c66 100644
--- a/include/clang/AST/StmtCXX.h
+++ b/include/clang/AST/StmtCXX.h
@@ -41,9 +41,9 @@ public:
CXXCatchStmt(EmptyShell Empty)
: Stmt(CXXCatchStmtClass), ExceptionDecl(nullptr), HandlerBlock(nullptr) {}
- SourceLocation getLocStart() const LLVM_READONLY { return CatchLoc; }
- SourceLocation getLocEnd() const LLVM_READONLY {
- return HandlerBlock->getLocEnd();
+ SourceLocation getBeginLoc() const LLVM_READONLY { return CatchLoc; }
+ SourceLocation getEndLoc() const LLVM_READONLY {
+ return HandlerBlock->getEndLoc();
}
SourceLocation getCatchLoc() const { return CatchLoc; }
@@ -86,12 +86,11 @@ public:
static CXXTryStmt *Create(const ASTContext &C, EmptyShell Empty,
unsigned numHandlers);
- SourceLocation getLocStart() const LLVM_READONLY { return getTryLoc(); }
- SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
+ SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); }
SourceLocation getTryLoc() const { return TryLoc; }
SourceLocation getEndLoc() const {
- return getStmts()[NumHandlers]->getLocEnd();
+ return getStmts()[NumHandlers]->getEndLoc();
}
CompoundStmt *getTryBlock() {
@@ -119,14 +118,15 @@ public:
};
/// CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for
-/// statement, represented as 'for (range-declarator : range-expression)'.
+/// statement, represented as 'for (range-declarator : range-expression)'
+/// or 'for (init-statement range-declarator : range-expression)'.
///
/// This is stored in a partially-desugared form to allow full semantic
/// analysis of the constituent components. The original syntactic components
/// can be extracted using getLoopVariable and getRangeInit.
class CXXForRangeStmt : public Stmt {
SourceLocation ForLoc;
- enum { RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
+ enum { INIT, RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
// SubExprs[RANGE] is an expression or declstmt.
// SubExprs[COND] and SubExprs[INC] are expressions.
Stmt *SubExprs[END];
@@ -136,16 +136,17 @@ class CXXForRangeStmt : public Stmt {
friend class ASTStmtReader;
public:
- CXXForRangeStmt(DeclStmt *Range, DeclStmt *Begin, DeclStmt *End,
- Expr *Cond, Expr *Inc, DeclStmt *LoopVar, Stmt *Body,
- SourceLocation FL, SourceLocation CAL, SourceLocation CL,
- SourceLocation RPL);
+ CXXForRangeStmt(Stmt *InitStmt, DeclStmt *Range, DeclStmt *Begin,
+ DeclStmt *End, Expr *Cond, Expr *Inc, DeclStmt *LoopVar,
+ Stmt *Body, SourceLocation FL, SourceLocation CAL,
+ SourceLocation CL, SourceLocation RPL);
CXXForRangeStmt(EmptyShell Empty) : Stmt(CXXForRangeStmtClass, Empty) { }
-
+ Stmt *getInit() { return SubExprs[INIT]; }
VarDecl *getLoopVariable();
Expr *getRangeInit();
+ const Stmt *getInit() const { return SubExprs[INIT]; }
const VarDecl *getLoopVariable() const;
const Expr *getRangeInit() const;
@@ -180,6 +181,7 @@ public:
}
const Stmt *getBody() const { return SubExprs[BODY]; }
+ void setInit(Stmt *S) { SubExprs[INIT] = S; }
void setRangeInit(Expr *E) { SubExprs[RANGE] = reinterpret_cast<Stmt*>(E); }
void setRangeStmt(Stmt *S) { SubExprs[RANGE] = S; }
void setBeginStmt(Stmt *S) { SubExprs[BEGINSTMT] = S; }
@@ -194,9 +196,9 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
- SourceLocation getLocStart() const LLVM_READONLY { return ForLoc; }
- SourceLocation getLocEnd() const LLVM_READONLY {
- return SubExprs[BODY]->getLocEnd();
+ SourceLocation getBeginLoc() const LLVM_READONLY { return ForLoc; }
+ SourceLocation getEndLoc() const LLVM_READONLY {
+ return SubExprs[BODY]->getEndLoc();
}
static bool classof(const Stmt *T) {
@@ -280,8 +282,10 @@ public:
return reinterpret_cast<CompoundStmt *>(SubStmt);
}
- SourceLocation getLocStart() const LLVM_READONLY { return KeywordLoc; }
- SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
+ SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
+ SourceLocation getEndLoc() const LLVM_READONLY {
+ return SubStmt->getEndLoc();
+ }
child_range children() {
return child_range(&SubStmt, &SubStmt+1);
@@ -399,12 +403,12 @@ public:
return {getStoredStmts() + SubStmt::FirstParamMove, NumParams};
}
- SourceLocation getLocStart() const LLVM_READONLY {
- return getBody() ? getBody()->getLocStart()
- : getPromiseDecl()->getLocStart();
+ SourceLocation getBeginLoc() const LLVM_READONLY {
+ return getBody() ? getBody()->getBeginLoc()
+ : getPromiseDecl()->getBeginLoc();
}
- SourceLocation getLocEnd() const LLVM_READONLY {
- return getBody() ? getBody()->getLocEnd() : getPromiseDecl()->getLocEnd();
+ SourceLocation getEndLoc() const LLVM_READONLY {
+ return getBody() ? getBody()->getEndLoc() : getPromiseDecl()->getEndLoc();
}
child_range children() {
@@ -464,9 +468,9 @@ public:
bool isImplicit() const { return IsImplicit; }
void setIsImplicit(bool value = true) { IsImplicit = value; }
- SourceLocation getLocStart() const LLVM_READONLY { return CoreturnLoc; }
- SourceLocation getLocEnd() const LLVM_READONLY {
- return getOperand() ? getOperand()->getLocEnd() : getLocStart();
+ SourceLocation getBeginLoc() const LLVM_READONLY { return CoreturnLoc; }
+ SourceLocation getEndLoc() const LLVM_READONLY {
+ return getOperand() ? getOperand()->getEndLoc() : getBeginLoc();
}
child_range children() {