diff options
author | John McCall <rjmccall@apple.com> | 2011-06-15 22:51:16 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-06-15 22:51:16 +0000 |
commit | 204e13395d83524e9a557c3f3fd6df2e2f353b9d (patch) | |
tree | bb49ede0f64e9145fe32fbdb9758d6ab7cede613 | |
parent | add80bb3957dba1d9389304453c0a4c975768bd7 (diff) |
Introduce a utility routine for checking whether a block's captures
include a specific variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133102 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Decl.h | 2 | ||||
-rw-r--r-- | lib/AST/Decl.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index d993d345ef..d3fe6b8c48 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -2956,6 +2956,8 @@ public: bool capturesCXXThis() const { return CapturesCXXThis; } + bool capturesVariable(const VarDecl *var) const; + void setCaptures(ASTContext &Context, const Capture *begin, const Capture *end, diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 12357c07a7..8661e7405f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2376,6 +2376,16 @@ void BlockDecl::setCaptures(ASTContext &Context, Captures = static_cast<Capture*>(buffer); } +bool BlockDecl::capturesVariable(const VarDecl *variable) const { + for (capture_const_iterator + i = capture_begin(), e = capture_end(); i != e; ++i) + // Only auto vars can be captured, so no redeclaration worries. + if (i->getVariable() == variable) + return true; + + return false; +} + SourceRange BlockDecl::getSourceRange() const { return SourceRange(getLocation(), Body? Body->getLocEnd() : getLocation()); } |