[cfe-commits] r133102 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp
John McCall
rjmccall at apple.com
Wed Jun 15 15:51:16 PDT 2011
Author: rjmccall
Date: Wed Jun 15 17:51:16 2011
New Revision: 133102
URL: http://llvm.org/viewvc/llvm-project?rev=133102&view=rev
Log:
Introduce a utility routine for checking whether a block's captures
include a specific variable.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=133102&r1=133101&r2=133102&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Jun 15 17:51:16 2011
@@ -2956,6 +2956,8 @@
bool capturesCXXThis() const { return CapturesCXXThis; }
+ bool capturesVariable(const VarDecl *var) const;
+
void setCaptures(ASTContext &Context,
const Capture *begin,
const Capture *end,
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=133102&r1=133101&r2=133102&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Jun 15 17:51:16 2011
@@ -2376,6 +2376,16 @@
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());
}
More information about the cfe-commits
mailing list