summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-06-15 22:51:16 +0000
committerJohn McCall <rjmccall@apple.com>2011-06-15 22:51:16 +0000
commitce45f88e451387c46bfd6b53c75c7fa72b730ba1 (patch)
tree5c65ee86b724ca981633f0453074d6b4ad4fc22f
parent5a0bee7c5f06333b68740fce3311b1a164ef93ea (diff)
downloadbcm5719-llvm-ce45f88e451387c46bfd6b53c75c7fa72b730ba1.tar.gz
bcm5719-llvm-ce45f88e451387c46bfd6b53c75c7fa72b730ba1.zip
Introduce a utility routine for checking whether a block's captures
include a specific variable. llvm-svn: 133102
-rw-r--r--clang/include/clang/AST/Decl.h2
-rw-r--r--clang/lib/AST/Decl.cpp10
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index d993d345ef9..d3fe6b8c480 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/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/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 12357c07a79..8661e7405fb 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/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());
}
OpenPOWER on IntegriCloud