[PATCH] D62009: [clang] perform semantic checking in constant context

Tyker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 17 04:51:18 PDT 2019


Tyker added a comment.

I checked how we can propagate the information about constant context through semantic checking.
there are issues with using ConstantExpr to mark expressions as constant for semantic checking:

- #1 multpile Expr::Ignore* operation remove ConstantExpr from the expression.
- #2 Semantic checking Traverses the AST so all methods that only mark the top-level Node not will fail.
- #3 at short term: adding ConstantExpr modifies the AST structure, so adding it everywhere it is needed for semantic checking will require changing a lot of code that depend closely on the AST structure.

Note: the limitation #2 also applies to the bit in ExprBitfield solution in its current form.

propagating constant context to the expression evaluator via a boolean value will be a lot of boilerplate and in my opinion this should be propagated more "automatically".
 so I think the best solutions are:

- push a ExpressionEvaluationContext::ConstantEvaluated so Sema will propagate it and propagate from Sema to the expression evaluator via boolean values.
- put all semantic checking function's in a SemaCheckContext class and propagate via this class to the expression evaluator. this class will be usable to propagate Sema and probably other informations.
- keep the bit in ExprBitfield but make all nodes created in ExpressionEvaluationContext::ConstantEvaluated marked for constant evaluation to fixes limitation #2.


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

https://reviews.llvm.org/D62009





More information about the cfe-commits mailing list