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/AST/DeclObjC.cpp | |
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/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 0e1e833d2f..d7775d5aad 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -332,7 +332,6 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod( ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, - ArrayRef<SourceLocation> SelLocs, Selector SelInfo, QualType T, TypeSourceInfo *ResultTInfo, DeclContext *contextDecl, @@ -352,6 +351,42 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, HasRelatedResultType); } +void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C, + ArrayRef<ParmVarDecl*> Params, + ArrayRef<SourceLocation> SelLocs) { + ParamsAndSelLocs = 0; + NumParams = Params.size(); + if (Params.empty() && SelLocs.empty()) + return; + + unsigned Size = sizeof(ParmVarDecl *) * NumParams + + sizeof(SourceLocation) * SelLocs.size(); + ParamsAndSelLocs = C.Allocate(Size); + std::copy(Params.begin(), Params.end(), getParams()); + std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs()); +} + +void ObjCMethodDecl::getSelectorLocs( + SmallVectorImpl<SourceLocation> &SelLocs) const { + for (unsigned i = 0, e = getNumSelectorLocs(); i != e; ++i) + SelLocs.push_back(getSelectorLoc(i)); +} + +void ObjCMethodDecl::setMethodParams(ASTContext &C, + ArrayRef<ParmVarDecl*> Params, + ArrayRef<SourceLocation> SelLocs) { + assert((!SelLocs.empty() || isImplicit()) && + "No selector locs for non-implicit method"); + if (isImplicit()) + return setParamsAndSelLocs(C, Params, ArrayRef<SourceLocation>()); + + SelLocsKind = hasStandardSelectorLocs(getSelector(), SelLocs, Params, EndLoc); + if (SelLocsKind != SelLoc_NonStandard) + return setParamsAndSelLocs(C, Params, ArrayRef<SourceLocation>()); + + setParamsAndSelLocs(C, Params, SelLocs); +} + /// \brief A definition will return its interface declaration. /// An interface declaration will return its definition. /// Otherwise it will return itself. |