[PATCH] D37322: [Sema] Correct typos in LHS, RHS before building a binop expression.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 12 15:36:19 PDT 2017
vsapsai added a comment.
In https://reviews.llvm.org/D37322#859065, @ahatanak wrote:
> Is it possible to avoid creating CXXDependentScopeMemberExpr in the first place? It seems to me that we shouldn't be creating a CXXDependentScopeMemberExpr for an ObjC property access.
>
> Or perhaps there are reasons to type-correct it later?
In `Sema::ActOnMemberAccessExpr` we handle dependent member expressions before other member references
if (Base->getType()->isDependentType() || Name.isDependentName() ||
isDependentScopeSpecifier(SS)) {
return ActOnDependentMemberExpr(Base, Base->getType(), IsArrow, OpLoc, SS,
TemplateKWLoc, FirstQualifierInScope,
NameInfo, TemplateArgs);
}
ActOnMemberAccessExtraArgs ExtraArgs = {S, Id, ObjCImpDecl};
return BuildMemberReferenceExpr(Base, Base->getType(), OpLoc, IsArrow, SS,
TemplateKWLoc, FirstQualifierInScope,
NameInfo, TemplateArgs, S, &ExtraArgs);
In this case variable `Base` is a `TypoExpr` and it is created as type-dependent regardless of the current language.
TypoExpr(QualType T)
: Expr(TypoExprClass, T, VK_LValue, OK_Ordinary,
/*isTypeDependent*/ true,
/*isValueDependent*/ true,
/*isInstantiationDependent*/ true,
/*containsUnexpandedParameterPack*/ false) {
assert(T->isDependentType() && "TypoExpr given a non-dependent type");
}
As a result we end up with `CXXDependentScopeMemberExpr` when reference a member of a `TypoExpr`. I'm not entirely sure but it looks like it was designed to work this way.
https://reviews.llvm.org/D37322
More information about the cfe-commits
mailing list