diff options
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 81 |
1 files changed, 38 insertions, 43 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 9b271c81acd..ff9e2721d29 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -248,7 +248,7 @@ SourceLocation Stmt::getLocEnd() const { llvm_unreachable("unknown statement kind"); } -CompoundStmt::CompoundStmt(ASTContext &C, ArrayRef<Stmt*> Stmts, +CompoundStmt::CompoundStmt(const ASTContext &C, ArrayRef<Stmt*> Stmts, SourceLocation LB, SourceLocation RB) : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) { CompoundStmtBits.NumStmts = Stmts.size(); @@ -277,7 +277,7 @@ const char *LabelStmt::getName() const { return getDecl()->getIdentifier()->getNameStart(); } -AttributedStmt *AttributedStmt::Create(ASTContext &C, SourceLocation Loc, +AttributedStmt *AttributedStmt::Create(const ASTContext &C, SourceLocation Loc, ArrayRef<const Attr*> Attrs, Stmt *SubStmt) { void *Mem = C.Allocate(sizeof(AttributedStmt) + @@ -286,7 +286,8 @@ AttributedStmt *AttributedStmt::Create(ASTContext &C, SourceLocation Loc, return new (Mem) AttributedStmt(Loc, Attrs, SubStmt); } -AttributedStmt *AttributedStmt::CreateEmpty(ASTContext &C, unsigned NumAttrs) { +AttributedStmt *AttributedStmt::CreateEmpty(const ASTContext &C, + unsigned NumAttrs) { assert(NumAttrs > 0 && "NumAttrs should be greater than zero"); void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr*) * (NumAttrs - 1), @@ -620,12 +621,12 @@ QualType CXXCatchStmt::getCaughtType() const { // Constructors //===----------------------------------------------------------------------===// -GCCAsmStmt::GCCAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, - bool isvolatile, unsigned numoutputs, unsigned numinputs, - IdentifierInfo **names, StringLiteral **constraints, - Expr **exprs, StringLiteral *asmstr, - unsigned numclobbers, StringLiteral **clobbers, - SourceLocation rparenloc) +GCCAsmStmt::GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, + bool issimple, bool isvolatile, unsigned numoutputs, + unsigned numinputs, IdentifierInfo **names, + StringLiteral **constraints, Expr **exprs, + StringLiteral *asmstr, unsigned numclobbers, + StringLiteral **clobbers, SourceLocation rparenloc) : AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs, numinputs, numclobbers), RParenLoc(rparenloc), AsmStr(asmstr) { @@ -644,7 +645,7 @@ GCCAsmStmt::GCCAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, std::copy(clobbers, clobbers + NumClobbers, Clobbers); } -MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, +MSAsmStmt::MSAsmStmt(const ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc, bool issimple, bool isvolatile, ArrayRef<Token> asmtoks, unsigned numoutputs, unsigned numinputs, @@ -658,15 +659,14 @@ MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, initialize(C, asmstr, asmtoks, constraints, exprs, clobbers); } -static StringRef copyIntoContext(ASTContext &C, StringRef str) { +static StringRef copyIntoContext(const ASTContext &C, StringRef str) { size_t size = str.size(); char *buffer = new (C) char[size]; memcpy(buffer, str.data(), size); return StringRef(buffer, size); } -void MSAsmStmt::initialize(ASTContext &C, - StringRef asmstr, +void MSAsmStmt::initialize(const ASTContext &C, StringRef asmstr, ArrayRef<Token> asmtoks, ArrayRef<StringRef> constraints, ArrayRef<Expr*> exprs, @@ -726,7 +726,7 @@ ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmts[NumCatchStmts + 1] = atFinallyStmt; } -ObjCAtTryStmt *ObjCAtTryStmt::Create(ASTContext &Context, +ObjCAtTryStmt *ObjCAtTryStmt::Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, @@ -739,9 +739,9 @@ ObjCAtTryStmt *ObjCAtTryStmt::Create(ASTContext &Context, atFinallyStmt); } -ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(ASTContext &Context, - unsigned NumCatchStmts, - bool HasFinally) { +ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(const ASTContext &Context, + unsigned NumCatchStmts, + bool HasFinally) { unsigned Size = sizeof(ObjCAtTryStmt) + (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *); void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>()); @@ -756,7 +756,7 @@ SourceLocation ObjCAtTryStmt::getLocEnd() const { return getTryBody()->getLocEnd(); } -CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc, +CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef<Stmt*> handlers) { std::size_t Size = sizeof(CXXTryStmt); Size += ((handlers.size() + 1) * sizeof(Stmt)); @@ -765,7 +765,7 @@ CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc, return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers); } -CXXTryStmt *CXXTryStmt::Create(ASTContext &C, EmptyShell Empty, +CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, EmptyShell Empty, unsigned numHandlers) { std::size_t Size = sizeof(CXXTryStmt); Size += ((numHandlers + 1) * sizeof(Stmt)); @@ -816,7 +816,7 @@ const VarDecl *CXXForRangeStmt::getLoopVariable() const { return const_cast<CXXForRangeStmt*>(this)->getLoopVariable(); } -IfStmt::IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, +IfStmt::IfStmt(const ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, Stmt *then, SourceLocation EL, Stmt *elsev) : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL) { @@ -834,7 +834,7 @@ VarDecl *IfStmt::getConditionVariable() const { return cast<VarDecl>(DS->getSingleDecl()); } -void IfStmt::setConditionVariable(ASTContext &C, VarDecl *V) { +void IfStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { SubExprs[VAR] = 0; return; @@ -845,7 +845,7 @@ void IfStmt::setConditionVariable(ASTContext &C, VarDecl *V) { VarRange.getEnd()); } -ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, +ForStmt::ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP) : Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP) @@ -865,7 +865,7 @@ VarDecl *ForStmt::getConditionVariable() const { return cast<VarDecl>(DS->getSingleDecl()); } -void ForStmt::setConditionVariable(ASTContext &C, VarDecl *V) { +void ForStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { SubExprs[CONDVAR] = 0; return; @@ -876,7 +876,7 @@ void ForStmt::setConditionVariable(ASTContext &C, VarDecl *V) { VarRange.getEnd()); } -SwitchStmt::SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond) +SwitchStmt::SwitchStmt(const ASTContext &C, VarDecl *Var, Expr *cond) : Stmt(SwitchStmtClass), FirstCase(0), AllEnumCasesCovered(0) { setConditionVariable(C, Var); @@ -892,7 +892,7 @@ VarDecl *SwitchStmt::getConditionVariable() const { return cast<VarDecl>(DS->getSingleDecl()); } -void SwitchStmt::setConditionVariable(ASTContext &C, VarDecl *V) { +void SwitchStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { SubExprs[VAR] = 0; return; @@ -909,7 +909,7 @@ Stmt *SwitchCase::getSubStmt() { return cast<DefaultStmt>(this)->getSubStmt(); } -WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, +WhileStmt::WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, SourceLocation WL) : Stmt(WhileStmtClass) { setConditionVariable(C, Var); @@ -926,7 +926,7 @@ VarDecl *WhileStmt::getConditionVariable() const { return cast<VarDecl>(DS->getSingleDecl()); } -void WhileStmt::setConditionVariable(ASTContext &C, VarDecl *V) { +void WhileStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { SubExprs[VAR] = 0; return; @@ -965,10 +965,8 @@ SEHTryStmt::SEHTryStmt(bool IsCXXTry, Children[HANDLER] = Handler; } -SEHTryStmt* SEHTryStmt::Create(ASTContext &C, - bool IsCXXTry, - SourceLocation TryLoc, - Stmt *TryBlock, +SEHTryStmt* SEHTryStmt::Create(const ASTContext &C, bool IsCXXTry, + SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler) { return new(C) SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler); } @@ -991,10 +989,8 @@ SEHExceptStmt::SEHExceptStmt(SourceLocation Loc, Children[BLOCK] = Block; } -SEHExceptStmt* SEHExceptStmt::Create(ASTContext &C, - SourceLocation Loc, - Expr *FilterExpr, - Stmt *Block) { +SEHExceptStmt* SEHExceptStmt::Create(const ASTContext &C, SourceLocation Loc, + Expr *FilterExpr, Stmt *Block) { return new(C) SEHExceptStmt(Loc,FilterExpr,Block); } @@ -1005,8 +1001,7 @@ SEHFinallyStmt::SEHFinallyStmt(SourceLocation Loc, Block(Block) {} -SEHFinallyStmt* SEHFinallyStmt::Create(ASTContext &C, - SourceLocation Loc, +SEHFinallyStmt* SEHFinallyStmt::Create(const ASTContext &C, SourceLocation Loc, Stmt *Block) { return new(C)SEHFinallyStmt(Loc,Block); } @@ -1053,7 +1048,7 @@ CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures) getStoredStmts()[NumCaptures] = 0; } -CapturedStmt *CapturedStmt::Create(ASTContext &Context, Stmt *S, +CapturedStmt *CapturedStmt::Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef<Capture> Captures, ArrayRef<Expr *> CaptureInits, @@ -1081,7 +1076,7 @@ CapturedStmt *CapturedStmt::Create(ASTContext &Context, Stmt *S, return new (Mem) CapturedStmt(S, Kind, Captures, CaptureInits, CD, RD); } -CapturedStmt *CapturedStmt::CreateDeserialized(ASTContext &Context, +CapturedStmt *CapturedStmt::CreateDeserialized(const ASTContext &Context, unsigned NumCaptures) { unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1); if (NumCaptures > 0) { @@ -1115,7 +1110,7 @@ bool CapturedStmt::capturesVariable(const VarDecl *Var) const { return false; } -OMPPrivateClause *OMPPrivateClause::Create(ASTContext &C, +OMPPrivateClause *OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, @@ -1128,7 +1123,7 @@ OMPPrivateClause *OMPPrivateClause::Create(ASTContext &C, return Clause; } -OMPPrivateClause *OMPPrivateClause::CreateEmpty(ASTContext &C, +OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, unsigned N) { void *Mem = C.Allocate(sizeof(OMPPrivateClause) + sizeof(Expr *) * N, llvm::alignOf<OMPPrivateClause>()); @@ -1142,7 +1137,7 @@ void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) { } OMPParallelDirective *OMPParallelDirective::Create( - ASTContext &C, + const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, @@ -1157,7 +1152,7 @@ OMPParallelDirective *OMPParallelDirective::Create( return Dir; } -OMPParallelDirective *OMPParallelDirective::CreateEmpty(ASTContext &C, +OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C, unsigned N, EmptyShell) { void *Mem = C.Allocate(sizeof(OMPParallelDirective) + |