[cfe-dev] Validation of dependent expressions
Douglas Gregor
dgregor at apple.com
Wed Feb 25 09:33:09 PST 2009
On Feb 25, 2009, at 8:37 AM, Sebastian Redl wrote:
> I've started some work on skipping validation of expressions that have
> dependent types and/or values. Am I doing it right?
Yes, you're on the right track. A few meta-comments:
1) Whenever you have an expression 'E', prefer E->isTypeDependent()
to E->getType()->isDependentType(). I think you're doing that already.
2) In addition to updating Sema's type checking for value-dependent
and type-dependent expressions, we also need to propagate those
dependencies by updating the *Expr nodes themselves compute value- and
type-dependence. For example, while updating the checking for array
subscripting, we should also update ArraySubscriptExpr's constructor
to accept (or compute) value- and type-dependence of the expression.
For example, CallExpr has been updated to do this, and it uses
CallExpr::CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args,
unsigned numargs, QualType t, SourceLocation
rparenloc)
: Expr(SC, t,
fn->isTypeDependent() || hasAnyTypeDependentArguments(args,
numargs),
fn->isValueDependent() || hasAnyValueDependentArguments
(args,numargs)),
NumArgs(numargs) {
There's a big FIXME in the Expr class that will be addressed once
*all* Expr nodes properly compute their type/value-dependence:
// FIXME: Eventually, this constructor should go away and we should
// require every subclass to provide type/value-dependence
// information.
Expr(StmtClass SC, QualType T)
: Stmt(SC), TypeDependent(false), ValueDependent(false) {
setType(T);
}
Thanks for working on this!
- Doug
More information about the cfe-dev
mailing list