RIscRIpt marked an inline comment as done. RIscRIpt added inline comments.
================ Comment at: clang/lib/Sema/Sema.cpp:1495-1499 + DeclContext *DC = CurContext; + while (DC && !isa<BlockDecl>(DC) && !isa<CapturedDecl>(DC) && + !isa<FunctionDecl>(DC) && !isa<ObjCMethodDecl>(DC)) + DC = DC->getParent(); + return dyn_cast_or_null<Decl>(DC); ---------------- cor3ntin wrote: > I think this is reimplementing `getCurFunctionOrMethodDecl` > maybe we want to do > > ``` > if(Decl* DC = getCurFunctionOrMethodDecl()) > return DC; > return dyn_cast_or_null<Decl>(CurrentContext); > ``` > > Or something like that Well, unfortunately, not really. The previous implementation did call `getCurFunctionOrMethodDecl()`, but it returned nullptr when we were inside a RecordDecl. If you examine the implementation of `getFunctionLevelDeclContext(bool AllowLambda)`, it halts if `isa<RecordDecl>(DC)`. I tried patching `getFunctionLevelDeclContext()` to skip RecordDecl, but this triggered around 70 clang/tests. I didn't want to delve into understanding the failure of each test. If you believe there's an issue with our current code, I can allocate time to investigate each specific test case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158591/new/ https://reviews.llvm.org/D158591 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits