[PATCH] D84637: [AST] Enhance the const expression evaluator to support error-dependent exprs.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 4 07:39:33 PDT 2020
hokein marked an inline comment as done.
hokein added inline comments.
================
Comment at: clang/lib/AST/ExprConstant.cpp:4961
}
+ if (IS->getCond()->isValueDependent())
+ return EvaluateDependentExpr(IS->getCond(), Info);
----------------
The `if` stmt (the same to `while`, `for`) is tricky -- if the condition is value-dependent, then we don't know which branch we should run into.
- returning a ESR_Succeeded may lead to a bogus diagnostic ("reach the end of the function");
- returning a ESR_Failed may lead to a bogus diagnostic ("never produce a constexpr");
I guess what we want is to stop the evaluation, and indicate that we hit a value-dependent expression and we don't know how to evaluate it, but still treat the constexpr function as potential constexpr (but no extra diagnostics being emitted), but the current `EvalStmtResult` is not sufficient, maybe we need a new enum.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84637/new/
https://reviews.llvm.org/D84637
More information about the cfe-commits
mailing list