rsmith added inline comments. ================ Comment at: lib/AST/ExprConstant.cpp:4791-4802 @@ -4790,1 +4790,14 @@ +CallStackFrame *getNearestContainingCallFrame(CallStackFrame *CurFrame, + const VarDecl *VD) { + if (auto *FD = + dyn_cast<FunctionDecl>(VD->getDeclContext()->getRedeclContext())) { + FD = FD->getFirstDecl(); + for (CallStackFrame *It = CurFrame; It; It = It->Caller) { + if (It->Callee && FD == It->Callee->getFirstDecl()) + return It; + } + } + return nullptr; +} + ---------------- This doesn't seem right to me: in the case where the variable is not in the expected frame, there seems to be no reason to expect it would be in a caller's frame rather than in some unrelated place, nor to special-case that situation. (And this does the wrong thing for constexpr lambdas, where the captured variable need not be in the *innermost* call frame for the function in which the variable was declared.)
Instead, how about changing the `VD->hasLocalStorage() && ...` condition below to also check that the `DeclContext` of the `VarDecl` is the callee of the current call, and leave `Frame` null otherwise. Repository: rL LLVM https://reviews.llvm.org/D23493 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits