forked from OSchip/llvm-project
Pull out conversion on LHS of -> and . into its own function. This happens
implicitly in LookupMemberExpr and explicitly in cases where template instantiation doesn't redo the lookup. llvm-svn: 143046
This commit is contained in:
parent
16133782dc
commit
cab9a7d51c
|
@ -2443,6 +2443,7 @@ public:
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
bool SuppressQualifierCheck = false);
|
bool SuppressQualifierCheck = false);
|
||||||
|
|
||||||
|
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow);
|
||||||
ExprResult LookupMemberExpr(LookupResult &R, ExprResult &Base,
|
ExprResult LookupMemberExpr(LookupResult &R, ExprResult &Base,
|
||||||
bool &IsArrow, SourceLocation OpLoc,
|
bool &IsArrow, SourceLocation OpLoc,
|
||||||
CXXScopeSpec &SS,
|
CXXScopeSpec &SS,
|
||||||
|
|
|
@ -970,6 +970,17 @@ static bool isPointerToRecordType(QualType T) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Perform conversions on the LHS of a member access expression.
|
||||||
|
ExprResult
|
||||||
|
Sema::PerformMemberExprBaseConversion(Expr *Base, bool IsArrow) {
|
||||||
|
ExprResult BaseResult = DefaultFunctionArrayConversion(Base);
|
||||||
|
|
||||||
|
if (!BaseResult.isInvalid() && IsArrow)
|
||||||
|
BaseResult = DefaultLvalueConversion(BaseResult.take());
|
||||||
|
|
||||||
|
return BaseResult;
|
||||||
|
}
|
||||||
|
|
||||||
/// Look up the given member of the given non-type-dependent
|
/// Look up the given member of the given non-type-dependent
|
||||||
/// expression. This can return in one of two ways:
|
/// expression. This can return in one of two ways:
|
||||||
/// * If it returns a sentinel null-but-valid result, the caller will
|
/// * If it returns a sentinel null-but-valid result, the caller will
|
||||||
|
@ -988,16 +999,10 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
||||||
assert(BaseExpr.get() && "no base expression");
|
assert(BaseExpr.get() && "no base expression");
|
||||||
|
|
||||||
// Perform default conversions.
|
// Perform default conversions.
|
||||||
BaseExpr = DefaultFunctionArrayConversion(BaseExpr.take());
|
BaseExpr = PerformMemberExprBaseConversion(BaseExpr.take(), IsArrow);
|
||||||
if (BaseExpr.isInvalid())
|
if (BaseExpr.isInvalid())
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
|
||||||
if (IsArrow) {
|
|
||||||
BaseExpr = DefaultLvalueConversion(BaseExpr.take());
|
|
||||||
if (BaseExpr.isInvalid())
|
|
||||||
return ExprError();
|
|
||||||
}
|
|
||||||
|
|
||||||
QualType BaseType = BaseExpr.get()->getType();
|
QualType BaseType = BaseExpr.get()->getType();
|
||||||
assert(!BaseType->isDependentType());
|
assert(!BaseType->isDependentType());
|
||||||
|
|
||||||
|
|
|
@ -1468,6 +1468,8 @@ public:
|
||||||
NamedDecl *FoundDecl,
|
NamedDecl *FoundDecl,
|
||||||
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
||||||
NamedDecl *FirstQualifierInScope) {
|
NamedDecl *FirstQualifierInScope) {
|
||||||
|
ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
|
||||||
|
isArrow);
|
||||||
if (!Member->getDeclName()) {
|
if (!Member->getDeclName()) {
|
||||||
// We have a reference to an unnamed field. This is always the
|
// We have a reference to an unnamed field. This is always the
|
||||||
// base of an anonymous struct/union member access, i.e. the
|
// base of an anonymous struct/union member access, i.e. the
|
||||||
|
@ -1476,17 +1478,12 @@ public:
|
||||||
assert(Member->getType()->isRecordType() &&
|
assert(Member->getType()->isRecordType() &&
|
||||||
"unnamed member not of record type?");
|
"unnamed member not of record type?");
|
||||||
|
|
||||||
ExprResult BaseResult =
|
BaseResult =
|
||||||
getSema().PerformObjectMemberConversion(Base,
|
getSema().PerformObjectMemberConversion(BaseResult.take(),
|
||||||
QualifierLoc.getNestedNameSpecifier(),
|
QualifierLoc.getNestedNameSpecifier(),
|
||||||
FoundDecl, Member);
|
FoundDecl, Member);
|
||||||
if (BaseResult.isInvalid())
|
if (BaseResult.isInvalid())
|
||||||
return ExprError();
|
return ExprError();
|
||||||
if (isArrow) {
|
|
||||||
BaseResult = getSema().DefaultLvalueConversion(BaseResult.take());
|
|
||||||
if (BaseResult.isInvalid())
|
|
||||||
return ExprError();
|
|
||||||
}
|
|
||||||
Base = BaseResult.take();
|
Base = BaseResult.take();
|
||||||
ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
|
ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
|
||||||
MemberExpr *ME =
|
MemberExpr *ME =
|
||||||
|
@ -1500,14 +1497,6 @@ public:
|
||||||
CXXScopeSpec SS;
|
CXXScopeSpec SS;
|
||||||
SS.Adopt(QualifierLoc);
|
SS.Adopt(QualifierLoc);
|
||||||
|
|
||||||
ExprResult BaseResult = getSema().DefaultFunctionArrayConversion(Base);
|
|
||||||
if (BaseResult.isInvalid())
|
|
||||||
return ExprError();
|
|
||||||
if (isArrow) {
|
|
||||||
BaseResult = getSema().DefaultLvalueConversion(BaseResult.get());
|
|
||||||
if (BaseResult.isInvalid())
|
|
||||||
return ExprError();
|
|
||||||
}
|
|
||||||
Base = BaseResult.take();
|
Base = BaseResult.take();
|
||||||
QualType BaseType = Base->getType();
|
QualType BaseType = Base->getType();
|
||||||
|
|
||||||
|
@ -2134,8 +2123,7 @@ public:
|
||||||
///
|
///
|
||||||
/// By default, performs semantic analysis to build the new expression.
|
/// By default, performs semantic analysis to build the new expression.
|
||||||
/// Subclasses may override this routine to provide different behavior.
|
/// Subclasses may override this routine to provide different behavior.
|
||||||
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE,
|
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType,
|
||||||
QualType BaseType,
|
|
||||||
SourceLocation OperatorLoc,
|
SourceLocation OperatorLoc,
|
||||||
bool IsArrow,
|
bool IsArrow,
|
||||||
NestedNameSpecifierLoc QualifierLoc,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
|
@ -2145,19 +2133,6 @@ public:
|
||||||
CXXScopeSpec SS;
|
CXXScopeSpec SS;
|
||||||
SS.Adopt(QualifierLoc);
|
SS.Adopt(QualifierLoc);
|
||||||
|
|
||||||
if (BaseE) {
|
|
||||||
ExprResult BaseResult = getSema().DefaultFunctionArrayConversion(BaseE);
|
|
||||||
if (BaseResult.isInvalid())
|
|
||||||
return ExprError();
|
|
||||||
if (IsArrow) {
|
|
||||||
BaseResult = getSema().DefaultLvalueConversion(BaseResult.take());
|
|
||||||
if (BaseResult.isInvalid())
|
|
||||||
return ExprError();
|
|
||||||
}
|
|
||||||
BaseE = BaseResult.take();
|
|
||||||
BaseType = BaseE->getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
|
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
|
||||||
OperatorLoc, IsArrow,
|
OperatorLoc, IsArrow,
|
||||||
SS, FirstQualifierInScope,
|
SS, FirstQualifierInScope,
|
||||||
|
@ -7707,6 +7682,11 @@ TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old)
|
||||||
Base = getDerived().TransformExpr(Old->getBase());
|
Base = getDerived().TransformExpr(Old->getBase());
|
||||||
if (Base.isInvalid())
|
if (Base.isInvalid())
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
Base = getSema().PerformMemberExprBaseConversion(Base.take(),
|
||||||
|
Old->isArrow());
|
||||||
|
if (Base.isInvalid())
|
||||||
|
return ExprError();
|
||||||
|
BaseType = Base.get()->getType();
|
||||||
} else {
|
} else {
|
||||||
BaseType = getDerived().TransformType(Old->getBaseType());
|
BaseType = getDerived().TransformType(Old->getBaseType());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue