forked from OSchip/llvm-project
Refactor some of handleObjCBridgeAttr to make it more concise and the diagnostic reusable.
llvm-svn: 195322
This commit is contained in:
parent
07787f8747
commit
2d3379e394
|
@ -2433,8 +2433,8 @@ def err_ns_bridged_not_interface : Error<
|
|||
"parameter of 'ns_bridged' attribute does not name an Objective-C class">;
|
||||
|
||||
// objc_bridge attribute diagnostics.
|
||||
def err_objc_bridge_not_id : Error<
|
||||
"parameter of 'objc_bridge' attribute must be a single name of an Objective-C class">;
|
||||
def err_objc_attr_not_id : Error<
|
||||
"parameter of %0 attribute must be a single name of an Objective-C %select{class|protocol}1">;
|
||||
def err_objc_cf_bridged_not_interface : Error<
|
||||
"CF object of type %0 is bridged to '%1', which is not an Objective-C class">;
|
||||
def err_objc_ns_bridged_invalid_cfobject : Error<
|
||||
|
|
|
@ -4347,19 +4347,18 @@ static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D,
|
|||
: ExpectedStructOrUnion);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Attr.getNumArgs() != 1) {
|
||||
S.Diag(D->getLocStart(), diag::err_objc_bridge_not_id);
|
||||
return;
|
||||
}
|
||||
IdentifierLoc *Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0;
|
||||
|
||||
IdentifierLoc *Parm = 0;
|
||||
if (Attr.getNumArgs() == 1)
|
||||
Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0;
|
||||
|
||||
if (!Parm) {
|
||||
S.Diag(D->getLocStart(), diag::err_objc_bridge_not_id);
|
||||
S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
|
||||
return;
|
||||
}
|
||||
|
||||
D->addAttr(::new (S.Context)
|
||||
ObjCBridgeAttr(Attr.getRange(), S.Context, Parm ? Parm->Ident : 0,
|
||||
ObjCBridgeAttr(Attr.getRange(), S.Context, Parm->Ident,
|
||||
Attr.getAttributeSpellingListIndex()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue