[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 07:27:44 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Sema/Sema.h:1300-1301
 
+    bool InDiscardedStatement : 1;
+    bool InImmediateFunctionContext : 1;
+
----------------
No real benefit to making these bit-fields, and it'd be good to add some documentation about why the fields exist.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:16571-16573
+  // Discarded statements and immediate contexts nested in other
+  // Discarded statements or immediate context are themselves
+  // discarded statements or immediate context respectively.
----------------



================
Comment at: clang/lib/Sema/SemaExpr.cpp:16575-16578
+      ExprEvalContexts[ExprEvalContexts.size() - 2]
+          .isDiscardedStatementContext();
+  ExprEvalContexts.back().InImmediateFunctionContext =
+      ExprEvalContexts[ExprEvalContexts.size() - 2]
----------------
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?


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