[PATCH] D113749: [Clang] Fix nesting of discarded and immediate contexts.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 1 08:20:38 PST 2021


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for the fix!



================
Comment at: clang/lib/Sema/SemaExpr.cpp:16575-16578
+      ExprEvalContexts[ExprEvalContexts.size() - 2]
+          .isDiscardedStatementContext();
+  ExprEvalContexts.back().InImmediateFunctionContext =
+      ExprEvalContexts[ExprEvalContexts.size() - 2]
----------------
cor3ntin wrote:
> aaron.ballman wrote:
> > It took me a moment to understand why `-2` was happening here. However, isn't this going to be UB when we go to push the first expr evaluation context?
> No, there is always one root context created during initialization of sema. Because this pattern is used in a few places, I did not add a comment.
Ah, good to know, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113749/new/

https://reviews.llvm.org/D113749



More information about the cfe-commits mailing list