diff options
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 946d1bae21e..486f2d6ab77 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3757,26 +3757,17 @@ void BlockDecl::setParams(ArrayRef<ParmVarDecl *> NewParamInfo) { } } -void BlockDecl::setCaptures(ASTContext &Context, - const Capture *begin, - const Capture *end, - bool capturesCXXThis) { - CapturesCXXThis = capturesCXXThis; - - if (begin == end) { - NumCaptures = 0; - Captures = nullptr; +void BlockDecl::setCaptures(ASTContext &Context, ArrayRef<Capture> Captures, + bool CapturesCXXThis) { + this->CapturesCXXThis = CapturesCXXThis; + this->NumCaptures = Captures.size(); + + if (Captures.empty()) { + this->Captures = nullptr; return; } - NumCaptures = end - begin; - - // Avoid new Capture[] because we don't want to provide a default - // constructor. - size_t allocationSize = NumCaptures * sizeof(Capture); - void *buffer = Context.Allocate(allocationSize, /*alignment*/sizeof(void*)); - memcpy(buffer, begin, allocationSize); - Captures = static_cast<Capture*>(buffer); + this->Captures = Captures.copy(Context).data(); } bool BlockDecl::capturesVariable(const VarDecl *variable) const { |