Built libdispatch with clang interface stubs. Ran into some block related issues. Basically VarDecl symbols can leak out because I wasn't checking the case where a VarDecl is contained inside a BlockDecl (versus a method or function).
This patch checks that a VarDecl is not a child decl of a BlockDecl.
This patch also does something very similar for c++ lambdas as well.
Use isa rather than dyn_cast_or_null. Furthermore, the dyn_cast_or_null is wrong - Parent is guaranteed to be !NULL given the condition on L56.
if (const auto *VD = dyn_cast<VarDecl>(ND)) if (const auto *P = VD->getParentFunctionOrMethod()) if (isa<BlockDecl>(P) || isa<CXXMethodDecl>(P)) return true;