diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-03 06:37:04 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-03 06:37:04 +0000 |
commit | 491306a83c4f0f49f95a3bcbca8580cb98a91c7a (patch) | |
tree | 2011c1e6e59dcea3f9eaad6f2160eb7e8295e3c2 /lib/Sema | |
parent | b994e6c7d57b00e3e0f69d152065e2cf85d1de33 (diff) |
Allow getting all source locations of selector identifiers in a ObjCMethodDecl.
Instead of always storing all source locations for the selector identifiers
we check whether all the identifiers are in a "standard" position; "standard" position is
-Immediately before the arguments: -(id)first:(int)x second:(int)y;
-With a space between the arguments: -(id)first: (int)x second: (int)y;
-For nullary selectors, immediately before ';': -(void)release;
In such cases we infer the locations instead of storing them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140989 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 15 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 6 |
4 files changed, 15 insertions, 13 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f4b6ce92e5..2988f11898 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2003,7 +2003,8 @@ void Sema::mergeObjCMethodDecls(ObjCMethodDecl *newMethod, mergeDeclAttributes(newMethod, oldMethod, Context, mergeDeprecation); // Merge attributes from the parameters. - for (ObjCMethodDecl::param_iterator oi = oldMethod->param_begin(), + ObjCMethodDecl::param_const_iterator oi = oldMethod->param_begin(); + for (ObjCMethodDecl::param_iterator ni = newMethod->param_begin(), ne = newMethod->param_end(); ni != ne; ++ni, ++oi) mergeParamDeclAttributes(*ni, *oi, Context); diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 3a34ffb543..b4def893af 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -171,10 +171,11 @@ void Sema::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, Diag(Overridden->getLocation(), diag::note_previous_decl) << "method"; } - for (ObjCMethodDecl::param_iterator oi = Overridden->param_begin(), - ni = NewMethod->param_begin(), ne = NewMethod->param_end(); + ObjCMethodDecl::param_const_iterator oi = Overridden->param_begin(); + for (ObjCMethodDecl::param_iterator + ni = NewMethod->param_begin(), ne = NewMethod->param_end(); ni != ne; ++ni, ++oi) { - ParmVarDecl *oldDecl = (*oi); + const ParmVarDecl *oldDecl = (*oi); ParmVarDecl *newDecl = (*ni); if (newDecl->hasAttr<NSConsumedAttr>() != oldDecl->hasAttr<NSConsumedAttr>()) { @@ -1860,12 +1861,12 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *left, != right->hasAttr<NSConsumesSelfAttr>())) return false; - ObjCMethodDecl::param_iterator + ObjCMethodDecl::param_const_iterator li = left->param_begin(), le = left->param_end(), ri = right->param_begin(); for (; li != le; ++li, ++ri) { assert(ri != right->param_end() && "Param mismatch"); - ParmVarDecl *lparm = *li, *rparm = *ri; + const ParmVarDecl *lparm = *li, *rparm = *ri; if (!matchTypes(Context, strategy, lparm->getType(), rparm->getType())) return false; @@ -2527,7 +2528,7 @@ Decl *Sema::ActOnMethodDeclaration( } ObjCMethodDecl* ObjCMethod = - ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, SelectorLocs, Sel, + ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType, ResultTInfo, CurContext, @@ -2610,7 +2611,7 @@ Decl *Sema::ActOnMethodDeclaration( Params.push_back(Param); } - ObjCMethod->setMethodParams(Context, Params.data(), Params.size()); + ObjCMethod->setMethodParams(Context, Params, SelectorLocs); ObjCMethod->setObjCDeclQualifier( CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier())); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d5d073fd6f..1675568a56 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7412,7 +7412,7 @@ void Sema::ConvertPropertyForLValue(ExprResult &LHS, ExprResult &RHS, // setter, RHS expression is being passed to the setter argument. So, // type conversion (and comparison) is RHS to setter's argument type. if (const ObjCMethodDecl *SetterMD = PropRef->getImplicitPropertySetter()) { - ObjCMethodDecl::param_iterator P = SetterMD->param_begin(); + ObjCMethodDecl::param_const_iterator P = SetterMD->param_begin(); LHSTy = (*P)->getType(); Consumed = (getLangOptions().ObjCAutoRefCount && (*P)->hasAttr<NSConsumedAttr>()); @@ -7431,7 +7431,7 @@ void Sema::ConvertPropertyForLValue(ExprResult &LHS, ExprResult &RHS, const ObjCMethodDecl *setter = PropRef->getExplicitProperty()->getSetterMethodDecl(); if (setter) { - ObjCMethodDecl::param_iterator P = setter->param_begin(); + ObjCMethodDecl::param_const_iterator P = setter->param_begin(); LHSTy = (*P)->getType(); Consumed = (*P)->hasAttr<NSConsumedAttr>(); } diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index a6f21fbf96..80c4409074 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1518,7 +1518,6 @@ 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, @@ -1556,7 +1555,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, property->getLocation(); SetterMethod = - ObjCMethodDecl::Create(Context, Loc, Loc, ArrayRef<SourceLocation>(), + ObjCMethodDecl::Create(Context, Loc, Loc, property->getSetterName(), Context.VoidTy, 0, CD, /*isInstance=*/true, /*isVariadic=*/false, /*isSynthesized=*/true, @@ -1577,7 +1576,8 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, SC_None, SC_None, 0); - SetterMethod->setMethodParams(Context, &Argument, 1); + SetterMethod->setMethodParams(Context, Argument, + ArrayRef<SourceLocation>()); AddPropertyAttrs(*this, SetterMethod, property); |