diff options
author | dim <dim@FreeBSD.org> | 2014-03-21 17:53:59 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-03-21 17:53:59 +0000 |
commit | 9cedb8bb69b89b0f0c529937247a6a80cabdbaec (patch) | |
tree | c978f0e9ec1ab92dc8123783f30b08a7fd1e2a39 /contrib/llvm/tools/clang/lib/AST/Stmt.cpp | |
parent | 03fdc2934eb61c44c049a02b02aa974cfdd8a0eb (diff) | |
download | FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.zip FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.tar.gz |
MFC 261991:
Upgrade our copy of llvm/clang to 3.4 release. This version supports
all of the features in the current working draft of the upcoming C++
standard, provisionally named C++1y.
The code generator's performance is greatly increased, and the loop
auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The
PowerPC backend has made several major improvements to code generation
quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ
backends have all seen major feature work.
Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.4/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html>
MFC 262121 (by emaste):
Update lldb for clang/llvm 3.4 import
This commit largely restores the lldb source to the upstream r196259
snapshot with the addition of threaded inferior support and a few bug
fixes.
Specific upstream lldb revisions restored include:
SVN git
181387 779e6ac
181703 7bef4e2
182099 b31044e
182650 f2dcf35
182683 0d91b80
183862 15c1774
183929 99447a6
184177 0b2934b
184948 4dc3761
184954 007e7bc
186990 eebd175
Sponsored by: DARPA, AFRL
MFC 262186 (by emaste):
Fix mismerge in r262121
A break statement was lost in the merge. The error had no functional
impact, but restore it to reduce the diff against upstream.
MFC 262303:
Pull in r197521 from upstream clang trunk (by rdivacky):
Use the integrated assembler by default on FreeBSD/ppc and ppc64.
Requested by: jhibbits
MFC 262611:
Pull in r196874 from upstream llvm trunk:
Fix a crash that occurs when PWD is invalid.
MCJIT needs to be able to run in hostile environments, even when PWD
is invalid. There's no need to crash MCJIT in this case.
The obvious fix is to simply leave MCContext's CompilationDir empty
when PWD can't be determined. This way, MCJIT clients,
and other clients that link with LLVM don't need a valid working directory.
If we do want to guarantee valid CompilationDir, that should be done
only for clients of getCompilationDir(). This is as simple as checking
for an empty string.
The only current use of getCompilationDir is EmitGenDwarfInfo, which
won't conceivably run with an invalid working dir. However, in the
purely hypothetically and untestable case that this happens, the
AT_comp_dir will be omitted from the compilation_unit DIE.
This should help fix assertions occurring with ports-mgmt/tinderbox,
when it is using jails, and sometimes invalidates clang's current
working directory.
Reported by: decke
MFC 262809:
Pull in r203007 from upstream clang trunk:
Don't produce an alias between destructors with different calling conventions.
Fixes pr19007.
(Please note that is an LLVM PR identifier, not a FreeBSD one.)
This should fix Firefox and/or libxul crashes (due to problems with
regparm/stdcall calling conventions) on i386.
Reported by: multiple users on freebsd-current
PR: bin/187103
MFC 263048:
Repair recognition of "CC" as an alias for the C++ compiler, since it
was silently broken by upstream for a Windows-specific use-case.
Apparently some versions of CMake still rely on this archaic feature...
Reported by: rakuco
MFC 263049:
Garbage collect the old way of adding the libstdc++ include directories
in clang's InitHeaderSearch.cpp. This has been superseded by David
Chisnall's commit in r255321.
Moreover, if libc++ is used, the libstdc++ include directories should
not be in the search path at all. These directories are now only used
if you pass -stdlib=libstdc++.
Diffstat (limited to 'contrib/llvm/tools/clang/lib/AST/Stmt.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/Stmt.cpp | 266 |
1 files changed, 172 insertions, 94 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/Stmt.cpp b/contrib/llvm/tools/clang/lib/AST/Stmt.cpp index 5b29c07..de85161 100644 --- a/contrib/llvm/tools/clang/lib/AST/Stmt.cpp +++ b/contrib/llvm/tools/clang/lib/AST/Stmt.cpp @@ -18,6 +18,7 @@ #include "clang/AST/Stmt.h" #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" +#include "clang/AST/StmtOpenMP.h" #include "clang/AST/Type.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/TargetInfo.h" @@ -48,16 +49,11 @@ static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) { return StmtClassInfo[E]; } -void *Stmt::operator new(size_t bytes, ASTContext& C, - unsigned alignment) throw() { +void *Stmt::operator new(size_t bytes, const ASTContext& C, + unsigned alignment) { return ::operator new(bytes, C, alignment); } -void *Stmt::operator new(size_t bytes, ASTContext* C, - unsigned alignment) throw() { - return ::operator new(bytes, *C, alignment); -} - const char *Stmt::getStmtClassName() const { return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name; } @@ -139,6 +135,7 @@ namespace { template <class T> good implements_children(children_t T::*) { return good(); } + LLVM_ATTRIBUTE_UNUSED static inline bad implements_children(children_t Stmt::*) { return bad(); } @@ -147,6 +144,7 @@ namespace { template <class T> good implements_getLocStart(getLocStart_t T::*) { return good(); } + LLVM_ATTRIBUTE_UNUSED static inline bad implements_getLocStart(getLocStart_t Stmt::*) { return bad(); } @@ -155,20 +153,22 @@ namespace { template <class T> good implements_getLocEnd(getLocEnd_t T::*) { return good(); } + LLVM_ATTRIBUTE_UNUSED static inline bad implements_getLocEnd(getLocEnd_t Stmt::*) { return bad(); } #define ASSERT_IMPLEMENTS_children(type) \ - (void) sizeof(is_good(implements_children(&type::children))) + (void) is_good(implements_children(&type::children)) #define ASSERT_IMPLEMENTS_getLocStart(type) \ - (void) sizeof(is_good(implements_getLocStart(&type::getLocStart))) + (void) is_good(implements_getLocStart(&type::getLocStart)) #define ASSERT_IMPLEMENTS_getLocEnd(type) \ - (void) sizeof(is_good(implements_getLocEnd(&type::getLocEnd))) + (void) is_good(implements_getLocEnd(&type::getLocEnd)) } /// Check whether the various Stmt classes implement their member /// functions. +LLVM_ATTRIBUTE_UNUSED static inline void check_implementations() { #define ABSTRACT_STMT(type) #define STMT(type, base) \ @@ -252,7 +252,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(); @@ -268,7 +268,8 @@ CompoundStmt::CompoundStmt(ASTContext &C, ArrayRef<Stmt*> Stmts, std::copy(Stmts.begin(), Stmts.end(), Body); } -void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) { +void CompoundStmt::setStmts(const ASTContext &C, Stmt **Stmts, + unsigned NumStmts) { if (this->Body) C.Deallocate(Body); this->CompoundStmtBits.NumStmts = NumStmts; @@ -281,7 +282,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) + @@ -290,7 +291,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), @@ -298,29 +300,7 @@ AttributedStmt *AttributedStmt::CreateEmpty(ASTContext &C, unsigned NumAttrs) { return new (Mem) AttributedStmt(EmptyShell(), NumAttrs); } -bool Stmt::hasImplicitControlFlow() const { - switch (StmtBits.sClass) { - default: - return false; - - case CallExprClass: - case ConditionalOperatorClass: - case ChooseExprClass: - case StmtExprClass: - case DeclStmtClass: - return true; - - case Stmt::BinaryOperatorClass: { - const BinaryOperator* B = cast<BinaryOperator>(this); - if (B->isLogicalOp() || B->getOpcode() == BO_Comma) - return true; - else - return false; - } - } -} - -std::string AsmStmt::generateAsmString(ASTContext &C) const { +std::string AsmStmt::generateAsmString(const ASTContext &C) const { if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this)) return gccAsmStmt->generateAsmString(C); if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this)) @@ -406,14 +386,14 @@ StringRef GCCAsmStmt::getInputConstraint(unsigned i) const { return getInputConstraintLiteral(i)->getString(); } -void GCCAsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C, - IdentifierInfo **Names, - StringLiteral **Constraints, - Stmt **Exprs, - unsigned NumOutputs, - unsigned NumInputs, - StringLiteral **Clobbers, - unsigned NumClobbers) { +void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C, + IdentifierInfo **Names, + StringLiteral **Constraints, + Stmt **Exprs, + unsigned NumOutputs, + unsigned NumInputs, + StringLiteral **Clobbers, + unsigned NumClobbers) { this->NumOutputs = NumOutputs; this->NumInputs = NumInputs; this->NumClobbers = NumClobbers; @@ -461,7 +441,7 @@ int GCCAsmStmt::getNamedOperand(StringRef SymbolicName) const { /// it into pieces. If the asm string is erroneous, emit errors and return /// true, otherwise return false. unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces, - ASTContext &C, unsigned &DiagOffs) const { + const ASTContext &C, unsigned &DiagOffs) const { StringRef Str = getAsmString()->getString(); const char *StrStart = Str.begin(); const char *StrEnd = Str.end(); @@ -599,7 +579,7 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces, } /// Assemble final IR asm string (GCC-style). -std::string GCCAsmStmt::generateAsmString(ASTContext &C) const { +std::string GCCAsmStmt::generateAsmString(const ASTContext &C) const { // Analyze the asm string to decompose it into its pieces. We know that Sema // has already done this, so it is guaranteed to be successful. SmallVector<GCCAsmStmt::AsmStringPiece, 4> Pieces; @@ -620,7 +600,7 @@ std::string GCCAsmStmt::generateAsmString(ASTContext &C) const { } /// Assemble final IR asm string (MS-style). -std::string MSAsmStmt::generateAsmString(ASTContext &C) const { +std::string MSAsmStmt::generateAsmString(const ASTContext &C) const { // FIXME: This needs to be translated into the IR string representation. return AsmStr; } @@ -646,12 +626,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) { @@ -670,7 +650,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, @@ -684,15 +664,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, @@ -731,7 +710,7 @@ ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, SourceLocation RPL) : Stmt(ObjCForCollectionStmtClass) { SubExprs[ELEM] = Elem; - SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(Collect); + SubExprs[COLLECTION] = Collect; SubExprs[BODY] = Body; ForLoc = FCL; RParenLoc = RPL; @@ -752,7 +731,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, @@ -765,9 +744,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>()); @@ -782,7 +761,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)); @@ -791,7 +770,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)); @@ -815,8 +794,8 @@ CXXForRangeStmt::CXXForRangeStmt(DeclStmt *Range, DeclStmt *BeginEndStmt, : Stmt(CXXForRangeStmtClass), ForLoc(FL), ColonLoc(CL), RParenLoc(RPL) { SubExprs[RANGE] = Range; SubExprs[BEGINEND] = BeginEndStmt; - SubExprs[COND] = reinterpret_cast<Stmt*>(Cond); - SubExprs[INC] = reinterpret_cast<Stmt*>(Inc); + SubExprs[COND] = Cond; + SubExprs[INC] = Inc; SubExprs[LOOPVAR] = LoopVar; SubExprs[BODY] = Body; } @@ -842,12 +821,12 @@ 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) { setConditionVariable(C, var); - SubExprs[COND] = reinterpret_cast<Stmt*>(cond); + SubExprs[COND] = cond; SubExprs[THEN] = then; SubExprs[ELSE] = elsev; } @@ -860,7 +839,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; @@ -871,15 +850,15 @@ 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) { SubExprs[INIT] = Init; setConditionVariable(C, condVar); - SubExprs[COND] = reinterpret_cast<Stmt*>(Cond); - SubExprs[INC] = reinterpret_cast<Stmt*>(Inc); + SubExprs[COND] = Cond; + SubExprs[INC] = Inc; SubExprs[BODY] = Body; } @@ -891,7 +870,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; @@ -902,11 +881,11 @@ 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); - SubExprs[COND] = reinterpret_cast<Stmt*>(cond); + SubExprs[COND] = cond; SubExprs[BODY] = NULL; } @@ -918,7 +897,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; @@ -935,11 +914,11 @@ 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); - SubExprs[COND] = reinterpret_cast<Stmt*>(cond); + SubExprs[COND] = cond; SubExprs[BODY] = body; WhileLoc = WL; } @@ -952,7 +931,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; @@ -991,10 +970,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); } @@ -1013,14 +990,12 @@ SEHExceptStmt::SEHExceptStmt(SourceLocation Loc, : Stmt(SEHExceptStmtClass), Loc(Loc) { - Children[FILTER_EXPR] = reinterpret_cast<Stmt*>(FilterExpr); + Children[FILTER_EXPR] = FilterExpr; 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); } @@ -1031,8 +1006,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); } @@ -1079,7 +1053,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, @@ -1107,7 +1081,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) { @@ -1128,7 +1102,7 @@ Stmt::child_range CapturedStmt::children() { bool CapturedStmt::capturesVariable(const VarDecl *Var) const { for (const_capture_iterator I = capture_begin(), E = capture_end(); I != E; ++I) { - if (I->capturesThis()) + if (!I->capturesVariable()) continue; // This does not handle variable redeclarations. This should be @@ -1140,3 +1114,107 @@ bool CapturedStmt::capturesVariable(const VarDecl *Var) const { return false; } + +StmtRange OMPClause::children() { + switch(getClauseKind()) { + default : break; +#define OPENMP_CLAUSE(Name, Class) \ + case OMPC_ ## Name : return static_cast<Class *>(this)->children(); +#include "clang/Basic/OpenMPKinds.def" + } + llvm_unreachable("unknown OMPClause"); +} + +OMPPrivateClause *OMPPrivateClause::Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc, + ArrayRef<Expr *> VL) { + void *Mem = C.Allocate(sizeof(OMPPrivateClause) + sizeof(Expr *) * VL.size(), + llvm::alignOf<OMPPrivateClause>()); + OMPPrivateClause *Clause = new (Mem) OMPPrivateClause(StartLoc, LParenLoc, + EndLoc, VL.size()); + Clause->setVarRefs(VL); + return Clause; +} + +OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, + unsigned N) { + void *Mem = C.Allocate(sizeof(OMPPrivateClause) + sizeof(Expr *) * N, + llvm::alignOf<OMPPrivateClause>()); + return new (Mem) OMPPrivateClause(N); +} + +OMPFirstprivateClause *OMPFirstprivateClause::Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc, + ArrayRef<Expr *> VL) { + void *Mem = C.Allocate(sizeof(OMPFirstprivateClause) + + sizeof(Expr *) * VL.size(), + llvm::alignOf<OMPFirstprivateClause>()); + OMPFirstprivateClause *Clause = new (Mem) OMPFirstprivateClause(StartLoc, + LParenLoc, + EndLoc, + VL.size()); + Clause->setVarRefs(VL); + return Clause; +} + +OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C, + unsigned N) { + void *Mem = C.Allocate(sizeof(OMPFirstprivateClause) + sizeof(Expr *) * N, + llvm::alignOf<OMPFirstprivateClause>()); + return new (Mem) OMPFirstprivateClause(N); +} + +OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc, + ArrayRef<Expr *> VL) { + void *Mem = C.Allocate(sizeof(OMPSharedClause) + sizeof(Expr *) * VL.size(), + llvm::alignOf<OMPSharedClause>()); + OMPSharedClause *Clause = new (Mem) OMPSharedClause(StartLoc, LParenLoc, + EndLoc, VL.size()); + Clause->setVarRefs(VL); + return Clause; +} + +OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, + unsigned N) { + void *Mem = C.Allocate(sizeof(OMPSharedClause) + sizeof(Expr *) * N, + llvm::alignOf<OMPSharedClause>()); + return new (Mem) OMPSharedClause(N); +} + +void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) { + assert(Clauses.size() == this->Clauses.size() && + "Number of clauses is not the same as the preallocated buffer"); + std::copy(Clauses.begin(), Clauses.end(), this->Clauses.begin()); +} + +OMPParallelDirective *OMPParallelDirective::Create( + const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, + Stmt *AssociatedStmt) { + void *Mem = C.Allocate(sizeof(OMPParallelDirective) + + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *), + llvm::alignOf<OMPParallelDirective>()); + OMPParallelDirective *Dir = new (Mem) OMPParallelDirective(StartLoc, EndLoc, + Clauses.size()); + Dir->setClauses(Clauses); + Dir->setAssociatedStmt(AssociatedStmt); + return Dir; +} + +OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C, + unsigned N, + EmptyShell) { + void *Mem = C.Allocate(sizeof(OMPParallelDirective) + + sizeof(OMPClause *) * N + sizeof(Stmt *), + llvm::alignOf<OMPParallelDirective>()); + return new (Mem) OMPParallelDirective(N); +} |