Pass from the parser the locations of selector identifiers when creating
objc method decls. They are not stored in the AST yet. llvm-svn: 140984
This commit is contained in:
parent
3849394b81
commit
dfd6570643
@ -193,7 +193,9 @@ private:
|
||||
public:
|
||||
static ObjCMethodDecl *Create(ASTContext &C,
|
||||
SourceLocation beginLoc,
|
||||
SourceLocation endLoc, Selector SelInfo,
|
||||
SourceLocation endLoc,
|
||||
ArrayRef<SourceLocation> SelLocs,
|
||||
Selector SelInfo,
|
||||
QualType T,
|
||||
TypeSourceInfo *ResultTInfo,
|
||||
DeclContext *contextDecl,
|
||||
|
||||
@ -5209,7 +5209,7 @@ public:
|
||||
SourceLocation EndLoc, // location of the ; or {.
|
||||
tok::TokenKind MethodType,
|
||||
ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
|
||||
SourceLocation SelectorStartLoc, Selector Sel,
|
||||
ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
|
||||
// optional arguments. The number of types/arguments is obtained
|
||||
// from the Sel.getNumArgs().
|
||||
ObjCArgInfo *ArgInfo,
|
||||
|
||||
@ -2923,6 +2923,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
|
||||
= ObjCMethodDecl::Create(Importer.getToContext(),
|
||||
Loc,
|
||||
Importer.Import(D->getLocEnd()),
|
||||
/*FIXME:*/ ArrayRef<SourceLocation>(),
|
||||
Name.getObjCSelector(),
|
||||
ResultTy, ResultTInfo, DC,
|
||||
D->isInstanceMethod(),
|
||||
|
||||
@ -332,6 +332,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod(
|
||||
ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
|
||||
SourceLocation beginLoc,
|
||||
SourceLocation endLoc,
|
||||
ArrayRef<SourceLocation> SelLocs,
|
||||
Selector SelInfo, QualType T,
|
||||
TypeSourceInfo *ResultTInfo,
|
||||
DeclContext *contextDecl,
|
||||
|
||||
@ -2134,6 +2134,7 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
|
||||
Selector cxxSelector = getContext().Selectors.getSelector(0, &II);
|
||||
ObjCMethodDecl *DTORMethod =
|
||||
ObjCMethodDecl::Create(getContext(), D->getLocation(), D->getLocation(),
|
||||
ArrayRef<SourceLocation>(),
|
||||
cxxSelector, getContext().VoidTy, 0, D,
|
||||
/*isInstance=*/true, /*isVariadic=*/false,
|
||||
/*isSynthesized=*/true, /*isImplicitlyDeclared=*/true,
|
||||
@ -2153,7 +2154,9 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
|
||||
// The constructor returns 'self'.
|
||||
ObjCMethodDecl *CTORMethod = ObjCMethodDecl::Create(getContext(),
|
||||
D->getLocation(),
|
||||
D->getLocation(), cxxSelector,
|
||||
D->getLocation(),
|
||||
ArrayRef<SourceLocation>(),
|
||||
cxxSelector,
|
||||
getContext().getObjCIdType(), 0,
|
||||
D, /*isInstance=*/true,
|
||||
/*isVariadic=*/false,
|
||||
|
||||
@ -972,6 +972,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
||||
}
|
||||
|
||||
SmallVector<IdentifierInfo *, 12> KeyIdents;
|
||||
SmallVector<SourceLocation, 12> KeyLocs;
|
||||
SmallVector<Sema::ObjCArgInfo, 12> ArgInfos;
|
||||
ParseScope PrototypeScope(this,
|
||||
Scope::FunctionPrototypeScope|Scope::DeclScope);
|
||||
@ -1027,6 +1028,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
||||
|
||||
ArgInfos.push_back(ArgInfo);
|
||||
KeyIdents.push_back(SelIdent);
|
||||
KeyLocs.push_back(selLoc);
|
||||
|
||||
// Make sure the attributes persist.
|
||||
allParamAttrs.takeAllFrom(paramAttrs.getPool());
|
||||
@ -1044,8 +1046,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
||||
}
|
||||
|
||||
// Check for another keyword selector.
|
||||
SourceLocation Loc;
|
||||
SelIdent = ParseObjCSelectorPiece(Loc);
|
||||
SelIdent = ParseObjCSelectorPiece(selLoc);
|
||||
if (!SelIdent && Tok.isNot(tok::colon))
|
||||
break;
|
||||
// We have a selector or a colon, continue parsing.
|
||||
@ -1088,7 +1089,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
|
||||
Decl *Result
|
||||
= Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
|
||||
mType, DSRet, ReturnType,
|
||||
selLoc, Sel, &ArgInfos[0],
|
||||
KeyLocs, Sel, &ArgInfos[0],
|
||||
CParamInfo.data(), CParamInfo.size(),
|
||||
methodAttrs.getList(),
|
||||
MethodImplKind, isVariadic, MethodDefinition);
|
||||
|
||||
@ -2489,7 +2489,7 @@ Decl *Sema::ActOnMethodDeclaration(
|
||||
SourceLocation MethodLoc, SourceLocation EndLoc,
|
||||
tok::TokenKind MethodType,
|
||||
ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
|
||||
SourceLocation SelectorStartLoc,
|
||||
ArrayRef<SourceLocation> SelectorLocs,
|
||||
Selector Sel,
|
||||
// optional arguments. The number of types/arguments is obtained
|
||||
// from the Sel.getNumArgs().
|
||||
@ -2523,11 +2523,12 @@ Decl *Sema::ActOnMethodDeclaration(
|
||||
} else { // get the type for "id".
|
||||
resultDeclType = Context.getObjCIdType();
|
||||
Diag(MethodLoc, diag::warn_missing_method_return_type)
|
||||
<< FixItHint::CreateInsertion(SelectorStartLoc, "(id)");
|
||||
<< FixItHint::CreateInsertion(SelectorLocs.front(), "(id)");
|
||||
}
|
||||
|
||||
ObjCMethodDecl* ObjCMethod =
|
||||
ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
|
||||
ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, SelectorLocs, Sel,
|
||||
resultDeclType,
|
||||
ResultTInfo,
|
||||
CurContext,
|
||||
MethodType == tok::minus, isVariadic,
|
||||
|
||||
@ -1518,6 +1518,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
|
||||
property->getLocation();
|
||||
|
||||
GetterMethod = ObjCMethodDecl::Create(Context, Loc, Loc,
|
||||
ArrayRef<SourceLocation>(),
|
||||
property->getGetterName(),
|
||||
property->getType(), 0, CD, /*isInstance=*/true,
|
||||
/*isVariadic=*/false, /*isSynthesized=*/true,
|
||||
@ -1555,7 +1556,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
|
||||
property->getLocation();
|
||||
|
||||
SetterMethod =
|
||||
ObjCMethodDecl::Create(Context, Loc, Loc,
|
||||
ObjCMethodDecl::Create(Context, Loc, Loc, ArrayRef<SourceLocation>(),
|
||||
property->getSetterName(), Context.VoidTy, 0,
|
||||
CD, /*isInstance=*/true, /*isVariadic=*/false,
|
||||
/*isSynthesized=*/true,
|
||||
|
||||
@ -1614,6 +1614,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
|
||||
|
||||
case DECL_OBJC_METHOD:
|
||||
D = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(),
|
||||
ArrayRef<SourceLocation>(),
|
||||
Selector(), QualType(), 0, 0);
|
||||
break;
|
||||
case DECL_OBJC_INTERFACE:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user