rjmccall added inline comments.
================ Comment at: clang/include/clang/Sema/Sema.h:11444 + return nullptr; + const Decl *ContextDecl = dyn_cast<FunctionDecl>(CurContext); + if (!ContextDecl) ---------------- You really want this to match whenever we're in a local context, right? How about structuring the function like: ``` if (CurContext->isFunctionOrMethod()) return cast<Decl>(CurContext); if (!CurContext->isFileContext()) return nullptr; return getCUDACurrentNonLocalVariable(); ``` As a more general solution, I think Sema funnels all changes to CurContext through a small number of places, and you could make those places save and restore the currently initialized variable as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71227/new/ https://reviews.llvm.org/D71227 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits