forked from OSchip/llvm-project
improve invalid member reference diagnostics to print the type and
have better source ranges. Before: t.m:11:53: error: member reference is not to a structure or union CGFloat maxOffsetY = [_outlineLayer contentSize].height - [_outlineLayer frame].size.height; ^~~~~~~ after: t.m:11:54: error: member reference base type ('id') is not a structure or union CGFloat maxOffsetY = [_outlineLayer contentSize].height - [_outlineLayer frame].size.height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ llvm-svn: 53834
This commit is contained in:
parent
3f44d70771
commit
0c373078e2
|
@ -879,8 +879,8 @@ DIAG(err_typecheck_subscript, ERROR,
|
||||||
"array subscript is not an integer")
|
"array subscript is not an integer")
|
||||||
DIAG(err_typecheck_subscript_not_object, ERROR,
|
DIAG(err_typecheck_subscript_not_object, ERROR,
|
||||||
"illegal subscript of non-object type '%0'")
|
"illegal subscript of non-object type '%0'")
|
||||||
DIAG(err_typecheck_member_reference_structUnion, ERROR,
|
DIAG(err_typecheck_member_reference_struct_union, ERROR,
|
||||||
"member reference is not to a structure or union")
|
"member reference base type ('%0') is not a structure or union")
|
||||||
DIAG(err_typecheck_member_reference_ivar, ERROR,
|
DIAG(err_typecheck_member_reference_ivar, ERROR,
|
||||||
"'%0' does not have a member named '%1'")
|
"'%0' does not have a member named '%1'")
|
||||||
DIAG(err_typecheck_member_reference_arrow, ERROR,
|
DIAG(err_typecheck_member_reference_arrow, ERROR,
|
||||||
|
|
|
@ -588,8 +588,8 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
|
||||||
if (const PointerType *PT = BaseType->getAsPointerType())
|
if (const PointerType *PT = BaseType->getAsPointerType())
|
||||||
BaseType = PT->getPointeeType();
|
BaseType = PT->getPointeeType();
|
||||||
else
|
else
|
||||||
return Diag(OpLoc, diag::err_typecheck_member_reference_arrow,
|
return Diag(MemberLoc, diag::err_typecheck_member_reference_arrow,
|
||||||
SourceRange(MemberLoc));
|
BaseType.getAsString(), BaseExpr->getSourceRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle field access to simple records. This also handles access to fields
|
// Handle field access to simple records. This also handles access to fields
|
||||||
|
@ -602,8 +602,8 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
|
||||||
// The record definition is complete, now make sure the member is valid.
|
// The record definition is complete, now make sure the member is valid.
|
||||||
FieldDecl *MemberDecl = RDecl->getMember(&Member);
|
FieldDecl *MemberDecl = RDecl->getMember(&Member);
|
||||||
if (!MemberDecl)
|
if (!MemberDecl)
|
||||||
return Diag(OpLoc, diag::err_typecheck_no_member, Member.getName(),
|
return Diag(MemberLoc, diag::err_typecheck_no_member, Member.getName(),
|
||||||
SourceRange(MemberLoc));
|
BaseExpr->getSourceRange());
|
||||||
|
|
||||||
// Figure out the type of the member; see C99 6.5.2.3p3
|
// Figure out the type of the member; see C99 6.5.2.3p3
|
||||||
// FIXME: Handle address space modifiers
|
// FIXME: Handle address space modifiers
|
||||||
|
@ -622,9 +622,9 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
|
||||||
if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member))
|
if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member))
|
||||||
return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr,
|
return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr,
|
||||||
OpKind == tok::arrow);
|
OpKind == tok::arrow);
|
||||||
return Diag(OpLoc, diag::err_typecheck_member_reference_ivar,
|
return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar,
|
||||||
IFTy->getDecl()->getName(), Member.getName(),
|
IFTy->getDecl()->getName(), Member.getName(),
|
||||||
BaseExpr->getSourceRange(), SourceRange(MemberLoc));
|
BaseExpr->getSourceRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Objective-C property access, which is "Obj.property" where Obj is a
|
// Handle Objective-C property access, which is "Obj.property" where Obj is a
|
||||||
|
@ -665,16 +665,16 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
|
||||||
// Component access limited to variables (reject vec4.rg.g).
|
// Component access limited to variables (reject vec4.rg.g).
|
||||||
if (!isa<DeclRefExpr>(BaseExpr) && !isa<ArraySubscriptExpr>(BaseExpr) &&
|
if (!isa<DeclRefExpr>(BaseExpr) && !isa<ArraySubscriptExpr>(BaseExpr) &&
|
||||||
!isa<ExtVectorElementExpr>(BaseExpr))
|
!isa<ExtVectorElementExpr>(BaseExpr))
|
||||||
return Diag(OpLoc, diag::err_ext_vector_component_access,
|
return Diag(MemberLoc, diag::err_ext_vector_component_access,
|
||||||
SourceRange(MemberLoc));
|
BaseExpr->getSourceRange());
|
||||||
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
|
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
|
||||||
if (ret.isNull())
|
if (ret.isNull())
|
||||||
return true;
|
return true;
|
||||||
return new ExtVectorElementExpr(ret, BaseExpr, Member, MemberLoc);
|
return new ExtVectorElementExpr(ret, BaseExpr, Member, MemberLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Diag(OpLoc, diag::err_typecheck_member_reference_structUnion,
|
return Diag(MemberLoc, diag::err_typecheck_member_reference_struct_union,
|
||||||
SourceRange(MemberLoc));
|
BaseType.getAsString(), BaseExpr->getSourceRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
|
/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
|
||||||
|
|
Loading…
Reference in New Issue