Introduce a utility routine for checking whether a block's captures

include a specific variable.

llvm-svn: 133102
This commit is contained in:
John McCall 2011-06-15 22:51:16 +00:00
parent 5a0bee7c5f
commit ce45f88e45
2 changed files with 12 additions and 0 deletions

View File

@ -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,

View File

@ -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());
}