================
@@ -13727,6 +13734,16 @@ void Sema::DiagnoseUniqueObjectDuplication(const
VarDecl *VD) {
}
void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
+ // RAII helper to ensure DeclForInitializer is cleared on all exit paths
+ struct ClearDeclForInitializer {
+ Sema &S;
+ ClearDeclForInitializer(Sema &S) : S(S) {}
+ ~ClearDeclForInitializer() {
+ if (!S.ExprEvalContexts.empty())
+ S.ExprEvalContexts.back().DeclForInitializer = nullptr;
+ }
+ } Clearer(*this);
----------------
cor3ntin wrote:
It would be simpler to use `make_scope_exit` here
https://github.com/llvm/llvm-project/pull/163885
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits